PROBLEMS WITH WRITE TO FILE

Jeanne A. E. DeVoto jeanne at runrev.com
Mon May 19 23:15:02 EDT 2003


At 1:12PM -0700 5/19/03, Stephen Barncard wrote:
>I don't know if it's OSX or a bug in REV, but I'm having a hell of a
>time with the simple WRITE TO FILE command.
>
>Instead of overwriting the old file, it always appends at leaves
>garbage of the old data at the end of the file, yet I am clearly
>using the command as I always did in Hypercard...this garbage is
>deadly to a html file....


If the file was opened in write mode, the write to file command completely
replaces the file contents from the start. For example, if the file
originally contains "ABC", and you write "1" to it, after the write to file
command is executed the file contains "1".

If the file was opened in update mode, if you write less data to the file
than it already contains, the write to file command does not remove
characters from it. For example, if the file originally contains "ABC", and
you write "1" to it, after the write to file command is executed the file
contains "1BC".

My guess is that you opened the file in update mode (which is the default,
if you just say "open file filename"), and this is why you're getting
garbage at the end. Opening the file with "open file filename for write"
ought to fix it..

--
Jeanne A. E. DeVoto ~ jeanne at runrev.com
Runtime Revolution Limited - Software at the Speed of Thought
http://www.runrev.com/





More information about the use-livecode mailing list