From WikiChip
Difference between revisions of "mirc/file handling"
< mirc

(Created page with "'''File Handling''' allows you to manipulate files on disk using seperate, simple operations. This allows for efficiency. To understand how it works, you must be familiar wit...")
 
Line 26: Line 26:
 
{{mIRC|/fseek}} sets the read/write pointer to the specified <position in the file, unless you use a switch:
 
{{mIRC|/fseek}} sets the read/write pointer to the specified <position in the file, unless you use a switch:
  
* -l -
+
* -l - sets the pointer to the beginning of the Nth line, use <position> to specify the Nth line
 +
* -n - sets the pointer to the beginning of the next line (from the current position of the read/write pointer), this does not take a parameter
 +
* -w - sets the pointer to the beginning of the line matching the wildcard expression, use <position> to specify the wildcard expression
 +
* -r - sets the pointer to the beginning of the line matching the regular expression, use <position> to specify the regular expression

Revision as of 09:45, 19 September 2014

File Handling allows you to manipulate files on disk using seperate, simple operations. This allows for efficiency.

To understand how it works, you must be familiar with text file operations such as /write and $read.

Let's take a looke at /write, /write is powerful tool which allows you to write to a file according to severals predefined options.

A simple "/write filename.txt line" involves the following file handling operations:

  • /fopen
  • /fseek
  • /fwrite
  • /fclose

/fopen

/fopen [-nox] <name> <filename>

/fopen opens the filename and use the specified name to reference it. The command fail by default if the file does not exists, the -n switch create the file if it does not exist, fails if it exists. The -o switch create a new file if it does not exist but overwrite the file if it exists.

After you opened a file with /fopen, you have a pointer of the content of the file, it starts at 0. This pointer is the starting position to read/write from.

/fseek

/fseek -lnwr <name> <position>

/fseek sets the read/write pointer to the specified <position in the file, unless you use a switch:

  • -l - sets the pointer to the beginning of the Nth line, use <position> to specify the Nth line
  • -n - sets the pointer to the beginning of the next line (from the current position of the read/write pointer), this does not take a parameter
  • -w - sets the pointer to the beginning of the line matching the wildcard expression, use <position> to specify the wildcard expression
  • -r - sets the pointer to the beginning of the line matching the regular expression, use <position> to specify the regular expression