mIRC Home    About    Download    Register    News    Help

Print Thread
file handling #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?

Re: file handling #44961 30/08/03 01:45 AM
Joined: Dec 2002
Posts: 2,962
S
starbucks_mafia Offline
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.
Re: file handling #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

Re: file handling #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?

Re: file handling #44964 30/08/03 07:07 AM
Joined: Mar 2003
Posts: 1,271
L
LocutusofBorg Offline
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
Re: file handling #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?

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