From WikiChip
Editing mirc/file handling
Warning: You are not logged in. Your IP address will be publicly visible if you make any edits. If you log in or create an account, your edits will be attributed to your username, along with other benefits.
The edit can be undone.
Please check the comparison below to verify that this is what you want to do, and then save the changes below to finish undoing the edit.
This page supports semantic in-text annotations (e.g. "[[Is specified as::World Heritage Site]]") to build structured and queryable content provided by Semantic MediaWiki. For a comprehensive description on how to use annotations or the #ask parser function, please have a look at the getting started, in-text annotation, or inline queries help pages.
Latest revision | Your text | ||
Line 1: | Line 1: | ||
− | + | '''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 | + | 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 | + | * /fopen |
+ | * /fseek | ||
+ | * /fwrite | ||
+ | * /fclose | ||
− | + | == /fopen == | |
− | + | /fopen [-nox] <name> <filename> | |
− | + | {{mIRC|/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. | 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 -lnwr <name> <position> | ||
− | {{mIRC|/fseek}} sets the read/write pointer to the specified <position | + | {{mIRC|/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 | * -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 | * -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 | + | * -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 | * -r - sets the pointer to the beginning of the line matching the regular expression, use <position> to specify the regular expression | ||
− | If /fseek fails, it sets the pointer to the end of the file | + | If /fseek fails, it sets the pointer to the end of the file. |
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− |