Steve,

Here's what I've done and though not the prettiest code in the world, it has worked solidly for me for the last couple years on Mac, Win and Lin. I haven't tried the OSX portion...so caution:

global allStatusLo

on openStack
put whichMachine(platform()) into thisMachine
put thisMachine&"V2.0.002" into fld "Version" of card "Main"
do "setUp"&thisMachine
put thisMachine into line 16 of allStatusLo
set the maxHeight of this stack to "475"
set the maxWidth of this stack to "640"
set the resizable of this stack to true
end openStack

function whichMachine thisPlatform
if thisPlatform="MacOS" then
  set the itemDelimiter to "." -- OS versions are of the form "x.y.z"
  if item 1 of the systemVersion >= 10 then
    put "OSX" into thisMachine
  else
    put "Mac" into thisMachine
  end if
else if thisPlatform="Linux" then put "Lin" into thisMachine
else if thisPlatform="Win32" then put "Win" into thisMachine
else put "???" into thisMachine
return thisMachine
end whichMachine

on setUpMac
set the itemDelimiter to "/"
put (item 1 to -2 of the effective filename of this stack)&"/" into appFolderPath
get url ("file:"&appFolderPath&"ieCfg.txt")
if it is empty then
get restoreConfig(appFolderPath&"ieCfg.txt")
else
put it into allStatusLo
end if
put appFolderPath into line 26 of allStatusLo
put "Quit/Q" into line 2 of btn "File" of card "Main"
put "Help/?" into line 1 of btn "Help" of card "Main"
set the decorations of this stack to default
end setUpMac


on setUpOSX
set the itemDelimiter to "/"
put (item 1 to -2 of the effective filename of this stack)&"/" into appFolderPath
get url ("file:"&appFolderPath&"ieCfg.txt")
if it is empty then
get restoreConfig(appFolderPath&"ieCfg.txt")
else
put it into allStatusLo
end if
put appFolderPath into line 26 of allStatusLo
put "Quit/Q" into line 2 of btn "File" of card "Main"
put "Help/?" into line 1 of btn "Help" of card "Main"
set the decorations of this stack to default
end setUpOSX


on setUpWin
set the itemDelimiter to "/"
put (item 1 to -2 of the effective filename of this stack)&"/" into appFolderPath
get url ("file:"&appFolderPath&"ieCfg.txt")
if it is empty then
get restoreConfig(appFolderPath&"ieCfg.txt")
else
put it into allStatusLo
end if
put appFolderPath into line 26 of allStatusLo
put "Exit/E" into line 2 of btn "File" of card "Main"
put "Help/H" into line 1 of btn "Help" of card "Main"
set the decorations of this stack to "minimize, maximize, menu"
end setUpWin


on setUpLin --Set up for Linux and other *nix boxes.
put fld "AppName" of card "Main"&fld "Version" of card "Main" into appNameVers
replace "." with "" in appNameVers
get shell("env") --Get details about the *nix environment.
get line (lineOffset("PWD=",it)) of it
if the last char of it<>"/" then get it&"/"
if appNameVers is not in it then
put char 5 to -1 of it&appNameVers into appFolderPath
else
put char 5 to -1 of it into appFolderPath
end if
if the last char of appFolderPath<>"/" then put "/" after appFolderPath
set the defaultFolder to appFolderPath --set the global rev property "defaultFolder" to the path from the preceeding line.
get the detailed files --get the detailed list of files in the "defaultFolder".
put line (lineOffset("ieCfg.txt",it)) of it into heresCfg --find the "ieCfg" file details in the list and put that info into a variable.
if heresCfg is empty then
get restoreConfig(appFolderPath&"ieCfg.txt")
else
get shell("chmod 755"&&(appFolderPath&"ieCfg.txt")) -- Set permissions to read/write/exe, read/exe, read/exe...User, Group, Other
get url ("file:"&appFolderPath&"ieCfg.txt")
if it is empty then
get restoreConfig(appFolderPath&"ieCfg.txt")
get shell("chmod 755"&&(appFolderPath&"ieCfg.txt")) -- Set permissions to read/write/exe, read/exe, read/exe...User, Group, Other
else
put it into allStatusLo
end if
end if
put appFolderPath into line 26 of allStatusLo
put "Exit/E" into line 2 of btn "File" of card "Main"
put "Help/H" into line 1 of btn "Help" of card "Main"
set the decorations of this stack to "minimize, maximize, menu"
end setUpLin


function restoreConfig appCfgPath
answer warning "Sorry, but your Config File is missing or corrupt."&cr&"It will be restored to the default condition."&cr&"id0000"
-- I've truncated the following line so as not to bore the reader too much. In reality, I end up with around 45 lines of cfg stuff.
put "0"&cr&"0"&cr&"0"&cr&cr&"192.168.0.210"&cr&"2000"&cr&&cr&"File"&cr&cr&"000000000000" into allStatusLo
put allStatusLo into url ("file:"&appCfgPath)
end restoreConfig




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

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@lists.runrev.com
http://lists.runrev.com/mailman/listinfo/use-revolution





_______________________________________________
use-revolution mailing list
use-revolution@lists.runrev.com
http://lists.runrev.com/mailman/listinfo/use-revolution

Reply via email to