mIRC Home    About    Download    Register    News    Help

Print Thread
#44960 30/08/03 01:24 AM
Joined: May 2003
Posts: 730
S
ScatMan Offline OP
Hoopy frood
OP Offline
Hoopy frood
S
Joined: May 2003
Posts: 730
can anyone explain me what this file handling for?

#44961 30/08/03 01:45 AM
Joined: Dec 2002
Posts: 2,962
S
Hoopy frood
Offline
Hoopy frood
S
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.
#44962 30/08/03 01:50 AM
Joined: May 2003
Posts: 730
S
ScatMan Offline OP
Hoopy frood
OP Offline
Hoopy frood
S
Joined: May 2003
Posts: 730
uh.. thanks

#44963 30/08/03 02:00 AM
Joined: May 2003
Posts: 730
S
ScatMan Offline OP
Hoopy frood
OP Offline
Hoopy frood
S
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?

#44964 30/08/03 07:07 AM
Joined: Mar 2003
Posts: 1,271
L
Hoopy frood
Offline
Hoopy frood
L
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
#44965 30/08/03 11:36 AM
Joined: May 2003
Posts: 730
S
ScatMan Offline OP
Hoopy frood
OP Offline
Hoopy frood
S
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?

#44966 30/08/03 12:00 PM
Joined: Mar 2003
Posts: 1,271
L
Hoopy frood
Offline
Hoopy frood
L
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
#44967 30/08/03 04:22 PM
Joined: Dec 2002
Posts: 2,809
C
Hoopy frood
Offline
Hoopy frood
C
Joined: Dec 2002
Posts: 2,809
Quote:
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.


Link Copied to Clipboard