In my app, the results of a series of calculations are placed into the appropriate line of a scrolling field.
When working in LiveCard everything is fine, but when saved as a standalone, the new text appears on the card only as long as the card is open.
Go to a different card, and return and the new text is gone.
Close and reopen the standalone and the new text is gone.
I have a "save this stack" line in the "On CloseCard" of the card script and in the "On Close Stack" of the stack script, but I see from the dictionary that "You cannot save to a standalone application's file; standalones are read-only".
Is there no workaround for this?
Newly generated text not saving in a standalone
Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller
Re: Newly generated text not saving in a standalone
Hi Maxiogee,
yep, standalones cannot save themselves, never, on no platform!!!!!
You need to write the text to a file and read it back when the app starts next time.
I created some newsletter articles for RunRev about this topic last year:
http://runrev.com/newsletter/october/is ... etter3.php
This will get you started!
Best
Klaus
P.S.
Almost overlooked this one:
yep, standalones cannot save themselves, never, on no platform!!!!!
You need to write the text to a file and read it back when the app starts next time.
I created some newsletter articles for RunRev about this topic last year:
http://runrev.com/newsletter/october/is ... etter3.php
This will get you started!
Best
Klaus
P.S.
Almost overlooked this one:
This should NOT happen, unless you have some "(pre)opencard" (or any other) handler that resets the text every time!Go to a different card, and return and the new text is gone.
Re: Newly generated text not saving in a standalone
So why does this not put anything into the text file.Klaus wrote: You need to write the text to a file and read it back when the app starts next time.
I created some newsletter articles for RunRev about this topic last year:
http://runrev.com/newsletter/october/is ... etter3.php
This will get you started!
===
else if tot < 101 then
if line tot of field "Solutions" is empty then
put strin into line tot of field "Solutions"
select line tot of field "Solutions"
select empty
beep 2
put strin & return into strin
open file "Macintosh HD/Applications/Solution.Txt" for write
write strin to file "Macintosh HD/Applications/Solution.Txt"" at end
close file "Macintosh HD/Applications/Solution.Txt""
else put
===
It creates the file, but it is blank after the process, despite the content of the strin variable being put into the right line of the field.
No. The only handler there is one which ensures that the length of the field is 101 linesKlaus wrote: Almost overlooked this one:This should NOT happen, unless you have some "(pre)opencard" (or any other) handler that resets the text every time!Go to a different card, and return and the new text is gone.
===
on opencard
if number of lines in field "Solutions" <> 101 then put " " into line 101 of field "Solutions"
===
Thanks for your help.
-
- Posts: 101
- Joined: Wed Dec 22, 2010 8:17 pm
Re: Newly generated text not saving in a standalone
Hi Maxiogee, actually there is another workaround, so to speak, really it's just using stack(s) in place of the text file Klause suggested. You can use what's commonly called a splashscreen as your standalone i.e. the standalone application file is a very small stack (usually just a small logo picture) with a script along the lines of (well, this is pretty much what I use):
And that's all the standalone file is--it then runs in the background. The main idea is to keep the standalone which you can't change separate from your own stuff. Now you can do whatever you like to your own stacks, have your users customise them, or later you can have patches to update them etc, all without having to rebuild. And you can still have your stacks encrypted (and password protected) if you so choose.
Steve
Code: Select all
on openStack
global gSplashScreen, gHomeStak -- set here (so you can navigate around and make sure the standalone is closed at the finish)
get the long name of this stack --file path on hard drive
delete the first word of it --stack
delete the first char of it -- "
delete the last char of it -- "
put it into gSplashScreen-- exe file
put it into thisStackPath
set itemDel to "/"
delete the last item of thisStackPath --the name of the current stack, leaving the file path to the current folder
put thisStackPath & "/my_mainStack.livecode" into gHomeStak
wait 1 sec
if there is not a stack gHomeStak then
answer error "Can't find the required file " & gHomeStak
close this stack
end if
set the passkey of stack gHomeStak to your_password -- so you can open it (if it's encrypted)
set the loc of stack gHomeStak to the screenLoc
set the visible of stack gSplashScreen to false
set the visible of stack gHomeStak to true
end openStack
Steve
Re: Newly generated text not saving in a standalone
Hi guys,
don't forget that only users with ADMIN right are allowed to write (save) in the APPLICATION folder!!!!
@Maxiogee
the correct path to that file, in case you are allowed to write in the APPLICATION folder, should be:
/Applications/your_file.txt
Without the name of the harddisk!
Nevertheless I highly recommend to use the prefs folder -> specialfolderpath("preferences") on the Mac, to store any info from a standalone!
Everything else means asking for trouble
Best
Klaus
don't forget that only users with ADMIN right are allowed to write (save) in the APPLICATION folder!!!!
@Maxiogee
the correct path to that file, in case you are allowed to write in the APPLICATION folder, should be:
/Applications/your_file.txt
Without the name of the harddisk!
Nevertheless I highly recommend to use the prefs folder -> specialfolderpath("preferences") on the Mac, to store any info from a standalone!
Everything else means asking for trouble

Best
Klaus