Fseek: Difference between revisions

From Scriptwiki
Jump to navigation Jump to search
Doomie (talk | contribs)
little save due to many crashes of my pc
 
m fseek -w and -r are fucked
 
(2 intermediate revisions by one other user not shown)
Line 11: Line 11:
| l      || ''/fseek -l <name> <linenumber>''. Moves the pointer to the begin of the specified line.
| l      || ''/fseek -l <name> <linenumber>''. Moves the pointer to the begin of the specified line.
|-
|-
| n      || ''/fseek -n <name> <next line>''. Moves the pointer to the begin of the next line.
| n      || ''/fseek -n <name>''. Moves the pointer to the begin of the next line.
|-
|-
| w      || ''/fseek -w <name> <wildcard>''. Moves the pointer to the next occurence of a string matching  this wildcard from the current position of the pointer (see example below).
| w      || ''/fseek -w <name> <wildcard>''. Moves the pointer to the next occurrence of a string matching  this wildcard from the current position of the pointer (see example below).
|-
|-
| r      || ''/fseek -r <name> <regex>''. Moves the pointer to the next occurence of a string matching the regex.
| r      || ''/fseek -r <name> <regex>''. Moves the pointer to the next occurrence of a string matching the regex.
|}
|}
'''Note''' that mIRC will internally set the pointer to byte 0 and scan for <linenumber> - 1 CR/LF combinations when using the -l switch.
== Example ==
Let's imagine with have the following file "moo.txt" in our mircdir:
This is my first line containing moo!
This is just a senseless text file.
mooooo
thats the end.
moo?
We have opened this file using ''[[Fopen|/fopen]] moo moo.txt''
/fseek -l moo 2
This example would set the position of the pointer to the begin of the second line (infront of ''This is just a senseless text file.'').
/fseek -n moo
This example would set the pointer to the begin of the next line (infront of 'mooooo').
/fseek -w moo *the*
This example would move the pointer to the beginning of the next line matching *the* (that is line 4 in our example). In case the wildcard text matches the current line and the pointer did not pass the wildcard text yet, the pointer will stay at the current position.
[[Category:File Handling]][[Category:Commands]]

Latest revision as of 19:45, 25 July 2010

Sets the read/write pointer to the specified position in the file.

/fseek <name> <position>


The following switches can also be used to move the file pointer:

Switch Meaning
l /fseek -l <name> <linenumber>. Moves the pointer to the begin of the specified line.
n /fseek -n <name>. Moves the pointer to the begin of the next line.
w /fseek -w <name> <wildcard>. Moves the pointer to the next occurrence of a string matching this wildcard from the current position of the pointer (see example below).
r /fseek -r <name> <regex>. Moves the pointer to the next occurrence of a string matching the regex.

Note that mIRC will internally set the pointer to byte 0 and scan for <linenumber> - 1 CR/LF combinations when using the -l switch.

Example

Let's imagine with have the following file "moo.txt" in our mircdir:

This is my first line containing moo!
This is just a senseless text file.
mooooo
thats the end.
moo?

We have opened this file using /fopen moo moo.txt


/fseek -l moo 2

This example would set the position of the pointer to the begin of the second line (infront of This is just a senseless text file.).


/fseek -n moo

This example would set the pointer to the begin of the next line (infront of 'mooooo').


/fseek -w moo *the*

This example would move the pointer to the beginning of the next line matching *the* (that is line 4 in our example). In case the wildcard text matches the current line and the pointer did not pass the wildcard text yet, the pointer will stay at the current position.