I’ve been trying to write to a file the results of an xmlhttp GET request. I have tried the code below:
set the_file to "/Users/xxxx/Documents/outputvals.txt" as file specification
set the_data to costItems
try
open for access the_file with write permission
set eof of the_file to 0
write (the_data) to the_file starting at eof as list
close access the_file
end try
However it doesn’t seem to write anything to the file. Ideally I want to write the xml ‘costItems’ to the end of a text file.
Generally, if you want to do anything with a file or folder, it must be a complete
aliasreference. Just changeas file specificationtoas POSIX file as aliasand that part will work!Also, remove the
as listand delete the lineset eof of the_file to 0. Assuming the file already contains information, you’re basically telling the script that the end of the file is the beginning of the file.I hope this helps!
EDIT: I don’t know why your code isn’t working properly (it does for me). Well, I guess you could try the following (kind of hacky, though, but oh well 😛 )