|
|
Joined: May 2003
Posts: 730
Hoopy frood
|
OP
Hoopy frood
Joined: May 2003
Posts: 730 |
can anyone explain me what this file handling for?
|
|
|
|
Joined: Dec 2002
Posts: 2,962
Hoopy frood
|
Hoopy frood
Joined: Dec 2002
Posts: 2,962 |
The file handling commands are much more efficient than the traditional mIRC $read and /write commands. With $read() and /write the the file is opened, read or written to, then closed for every single call to those functions, making complex file tasks very inefficent and slow. Using the new commands a file only has to be opened and closed once, no matter how many tasks are performed in between.
Spelling mistakes, grammatical errors, and stupid comments are intentional.
|
|
|
|
Joined: May 2003
Posts: 730
Hoopy frood
|
OP
Hoopy frood
Joined: May 2003
Posts: 730 |
|
|
|
|
Joined: May 2003
Posts: 730
Hoopy frood
|
OP
Hoopy frood
Joined: May 2003
Posts: 730 |
the helpfile says that i need to /fclose the file before using it again, but when i do //fopen a file.txt | fopen b file.txt it works, why? and when one file is opened with /fopen and then i /run the same file it works too, why?
|
|
|
|
Joined: Mar 2003
Posts: 1,271
Hoopy frood
|
Hoopy frood
Joined: Mar 2003
Posts: 1,271 |
/fopen [-n] <name> <filename>
Opens the specified file and assigns a name to it for later reference. The -n switch creates the file if it doesn't already exist.
see the part where it says "assigns a name to it"? I open the file and call it a. Then I open the file again, and this time I call it b. I can do this endlessly as long as I specify a different name each time and my RAM doesn't run out. Same as the dialogs, where you can create many many dialogs with only one table definition. For the same reason /fopen and /run work at the same time.
Not a programming expert, but far as I understand, /fopen loads the file in memory and /fclose writes it back to your HDD. So if another application uses the file before you did /fclose, any changes you may have made to the file won't be seen by that other application.
DALnet #Helpdesk I hear and I forget. I see and I remember. I do and I understand. -Confucius
|
|
|
|
Joined: May 2003
Posts: 730
Hoopy frood
|
OP
Hoopy frood
Joined: May 2003
Posts: 730 |
//fopen a file.txt | fopen b file.txt | fwrite a test | echo -a $fread(a) - $fread(b) hmm, it writes the "test" to a but i see it in b, why?
|
|
|
|
Joined: Mar 2003
Posts: 1,271
Hoopy frood
|
Hoopy frood
Joined: Mar 2003
Posts: 1,271 |
Beats me. It does say
* fopen opened 'a' (C:\Program Files\mIRC\DALnet\file.txt) - * fopen opened 'b' (C:\Program Files\mIRC\DALnet\file.txt) - * fwrite wrote 4 bytes to 'a'
DALnet #Helpdesk I hear and I forget. I see and I remember. I do and I understand. -Confucius
|
|
|
|
Joined: Dec 2002
Posts: 2,809
Hoopy frood
|
Hoopy frood
Joined: Dec 2002
Posts: 2,809 |
Not a programming expert, but far as I understand, /fopen loads the file in memory and /fclose writes it back to your HDD. So if another application uses the file before you did /fclose, any changes you may have made to the file won't be seen by that other application. Thats generally the way it would work, however someone said it doesn't buffer it, which means as soon as you /fwrite it writes it to the disk, not when you /fclose. Hopefully an option to buffer it will be in 6.11.
|
|
|
|
|
|