mIRC Home    About    Download    Register    News    Help

Print Thread
Possible /fopen bug #46934 03/09/03 06:49 PM
Joined: Dec 2002
Posts: 37
O
oracel Offline OP
Ameglian cow
OP Offline
Ameglian cow
O
Joined: Dec 2002
Posts: 37
As seen in this post the /fopen command is not working properly. In addition to the problem described in the mentioned post, there is another problem with /fopen.

Following is a piece of code reproducing the error:
Code:
alias writetxt {
  fopen -n bloop somefile.txt
  fseek -l bloop $calc($lines(somefile.txt) + 1) 
  fwrite -n bloop blablablablabla
  fclose bloop
}


Let's step through this code according to the help file. First, a file stream using the handle "bloop" is created, and also creating the file "somefile.txt" if it doesn't already exist. Then the file pointer is set to the last line of the file, and the text "blablablablabla" is written to the file, terminated by a $crlf, and followed by closing the file stream.

What really happens: A file stream is created using the handle bloop, also creating the file if it doesn't exist, as well as deleting everything that might happen to be in the file. Otherwise, the script works as foreseen.

In short: /fopen -n DELETES contents of the given file. /fopen without the -n switch creates the file, even if it's not supposed to do so.

The above code will reproduce the bug (using the -n switch) as described here.

Feedback/workarounds on this matter will be appreciated.




Bloop
Re: Possible /fopen bug #46935 03/09/03 06:57 PM
Joined: Jul 2003
Posts: 19
K
kamelion Offline
Pikka bird
Offline
Pikka bird
K
Joined: Jul 2003
Posts: 19
Yep, the file contents gets overwritten every time... This must be a bug... Tnx for posting smile