writing to external file from Windows standalone: empty files

Curtis Ford cford at gwm.sc.edu
Tue Feb 27 23:15:24 EST 2007


My project needs to allow the user to enter data which is then saved to
an external text file. It has worked fine on OS X in the IDE and
standalone. When I tried from a Windows standalone, the external file is
written but is empty (0 kb). Here's the code:

on saveNewFile
  global gMyFileName,gEntireList,gMyLoop,gCurrentSet
  ask file "Save list as" with "MyList.txt"
  put it into gMyFileName
  --separate handler saves current set of data to gCurrentSet
  saveCurrentSet
--is the current set already in gEntireList?
  put lineOffset("<itemIDnum=" & gMyLoop, gEntireList) into tSetStart
  if tSetStart = 0 then
    --it wasn't there, so append the set just entered to the end of
gEntireList
    put gCurrentSet after gEntireList
  end if
  open file gMyFileName for update
  answer "now doing saveNewFile: gEntireList is" && gEntireList
  put gEntireList into URL ("file:" & gMyFileName)
end saveNewFile

I put the 'answer' command right before the final 'put gEntireList..'
command to make sure the variable had the expected contents, and it did;
but the resulting text file is always empty on XP. 

I'm developing on OS X 10.4.8, testing on Windows XP; using Rev 2.8, but
I checked earlier versions of the project and the problem is there in
2.6 as well.

I don't know a lot about Windows or where to go on with troubleshooting.
Help! Thanks in advance!

Curt

Dr. Curtis Ford
Instructor of Russian and Linguistics
Dept of Languages, Literatures and Cultures
University of South Carolina
(803) 777-9615
cford at sc.edu



More information about the use-livecode mailing list