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

Alex Tweedly alex at tweedly.net
Wed Mar 16 14:39:16 EST 2005


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



More information about the use-livecode mailing list