Can I write "empty" to a text file?

Steve Bonham sbonham at georgiasouthern.edu
Wed Mar 16 12:26:40 EST 2005


Sarah & Other helpful Revers,

I'm about to go crazy here. My stack works perfectly as long as it is 
not saved as a standalone.
But as a standalone while opening it gets hung/stuck- will not open!

I've isolated the code that is making the runtime version hang. If I 
make this section a comment it launches (as a standalone) BUT I need 
to be able to read from an external text file so I've got to get this 
function to work.

The following lines of Transcript are within the "on openstack" script.
This is what is supposed to happen:
a. as stack opens it imports preferences from "TJsettings.txt" IF the 
files exists (and rev is told to look in the same directory my stack 
is in) to a variable named theSettings

	OTHERWISE
b. a default "TJsettings.txt" file (that the stack will save prefs to 
on closestack) is created in the same folder my stack is in and that 
data is imported to a variable named theSettings

What's in here that is so hostile?

put the filename of this stack into MyPathWay
   repeat until the last char of myPathWay is "/"
     delete last char of MyPathWay
   end repeat

   put myPathWay & "TJsettings.txt" into MyPathWay

   ----------------
   if there is a file myPathWay then
     answer myPathway ----- just a debugging attempt--  DELETE LATER-----------
     put URL ("file:" & myPathWay) into TheSettings
   else
     put "1. CURRENT SETTINGS as of " & the long date &  " - " & the 
long time & return & fld "generic" into URL ("file:" & myPathWay)
     put URL ("file:" & myPathWay) into TheSettings
   end if



>>I've got my Rev stack writing data to an external file each time it is used.
>>
>>Some times the data is 20 lines long some times it is only 10.
>>
>>I've just realized that IF it had 20 lines previously and this time 
>>it only write 10-- lines 11 to 20 from the previous time are STILL 
>>in the file! This is a problem.
>>
>>What's the solution?
>>Delete the file prior to opening (recreating) it again?
>>Is there an option to put or write empty into a file?
>>
>Are you using the URL form of file writing or are you opening the 
>file, writing to it and closing it again?
>I THINK, that if you use the URL command, it will overwrite the 
>current contents of the file with whatever you specify, which can be 
>anything, including empty
>e.g. put empty into URL ("file:" & myFileName)
>
>Cheers,
>Sarah
>
>_______________________________________________
>use-revolution mailing list
>use-revolution at lists.runrev.com
>http://lists.runrev.com/mailman/listinfo/use-revolution


-- 


--------------------------------------------------------------------------------------------------
Steve Bonham
Director, Faculty Technology Development Laboratory
Center for Excellence in Teaching - Georgia Southern University
Statesboro, GA 30460-8143
--------------------------------------------------------------------------------------------------


More information about the use-livecode mailing list