PROBLEMS WITH WRITE TO FILE
    Klaus Major 
    klaus at major-k.de
       
    Mon May 19 11:46:03 EDT 2003
    
    
  
Hi Stephen,
> 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....
>
> Must I delete the file entirely before 'overwriting'? This seems 
> strange and unneeded. Is there a better syntax? This is not explained 
> well in the Transcript guide, especially the "start at" parameter. Is 
> it "at" or "start at" ?.
>
>
> function writeToFile theBlock
>   global targetFile
>   set the fileType to "MSIETEXT"
>   open file targetFile
>   write theBlock to file targetFile at 0
>   close file targetFile
> end writeToFile
try this:
function writeToFile theBlock
   global targetFile
   set the fileType to "MSIETEXT"
   put theBlock into url("file:" & targetfile)
end writeToFile
With the "url"-syntax you also can:
...
put CR & theBlock after url...
...
or
...
put CR & the block before url...
...
and even:
...
put CR & theBlock after line 3 of url...
...
etc...
Great, isn't it? :-D
Regards
Klaus Major
klaus at major-k.de
    
    
More information about the use-livecode
mailing list