Need help with writing to a file
Fernando Raineri
raineri at mail.chem.sunysb.edu
Sun Jun 1 08:32:01 EDT 2003
Hello
I am using RR 2.0r2 on an iBook 600 MHz with 640 MB of memory
and Mac OS X 10.2.6.
I have been working on a script that reads a line from a
card field "theVsites", processes this information with the result
stored in a variable theText, and then writes this information
in another card field "theVoutput".
The above goal is working. But I would also like to write
the information contained in the variable theText into a file,
say "try.txt" in the Desktop.
This I can't find the way to do it. I have tried the line
put theText into URL "file:/fallRains/Users/fernando/Desktop/try.txt".
I have also tried the "open file to write; write to file; close file"
approach, but also can't make it to work.
Perhaps there is some setting that I'm missing, or there is something
very fundamental that I'm not doing correctly (like the filePath style,
perhaps?).
The button script is below (with the open/write/close alternative
commented).
A typical content in the card field "theVsites" is "O H1 H2".
I would appreciate it very much if somebody could help me.
Thank you, Fernando
on mouseUp
put card field "theVsites" into theVsites
put (number of words in theVsites) into theSitesNo
put "" into card field "theVoutput"
put "" into theText
put 0 into m
repeat with j=1 to theSitesNo
put (m+1) into m
put word j of theVsites into theSite1
put m & " " & j & " " & j & " " & theSite1 & " " & theSite1 &
return after theText
repeat with l=(j+1) to theSitesNo
put (m+1) into m
put word l of theVsites into theSite2
put m & " " & j & " " & l & " " & theSite1 & " " & theSite2 &
return after theText
end repeat
end repeat
put theText into card field "theVoutput"
put theText into URL "file:/fallRains/Users/fernando/Desktop/try.txt"
--put "/fallRains/Users/fernando/Desktop/try.txt" into theFile
--open file theFile for write
--write theText to file theFile
--close file theFile
end mouseUp
More information about the use-livecode
mailing list