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