Getting a *standalone* to read & write to/from text file?

Steve Bonham sbonham at georgiasouthern.edu
Wed Mar 16 15:22:07 EST 2005


That worked on my Mac running OSX. That's a good sign!
I'll test the other platforms.

THANK YOU ALEX!!!

Steve


So-- when I'm asking for the filename of this stack to be put into 
MyPathWay I can'd depend upon an absolute pathway- because of OS 
differences? Would using a relative pathway instead be wiser? If so 
how would I write that?

would this do the job?

  if there is a file "TJsettings,txt" then
	put URL ("file:TJsettings.txt") into TheSettings
   else
     put "1. CURRENT SETTINGS as of " & the long date &  " - " & the 
long time & return & fld "generic" into URL ("file:TJsettings.txt")
     put URL ("file:TJsettings.txt") into TheSettings
   end if

I'm going to try this now.

S


>Steve Bonham wrote:
>
>>My stack works perfectly UNTIL it is saved as a standalone.
>>Then while opening the standalone 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 (there is NOT a TJsettings.txt file)
>>
>>b. a default "TJsettings.txt" file (that the stack will save prefs 
>>to "on closestack") is created in the same folder my 
>>standalone/stack is in and that data is imported to a variable 
>>named theSettings
>
>I don't really think this is the answer - but it's worth checking ....
>
>>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
>
>That repeat loop bothers me - if for some reason MyPathWay had no 
>"/" characters, you'd be in an infinite loop ....
>maybe add a safety check around it, or put its current value into a 
>field to check ....
>  if "/" is in MyPathWay then
>    repeat until the last char of myPathWay is "/"
>      delete last char of MyPathWay
>    end repeat
>end if
>
>or (what I'd do) ...
>  set the itemDel to "/"
>  delete the last item of MyPathWay
>  -- and remember to set the itemDel back again, if necessary
>  -- and remember that this strips the "" as well, so you'd then want to do
>    put myPathWay & "/TJsettings.txt" into MyPathWay
>
>>   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
>
>
>
>--
>Alex Tweedly       http://www.tweedly.net
>
>
>
>
>--
>No virus found in this outgoing message.
>Checked by AVG Anti-Virus.
>Version: 7.0.308 / Virus Database: 266.7.3 - Release Date: 15/03/2005
>
>_______________________________________________
>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