Limitations of Dynamically Executing Script in LC

Anything beyond the basics in using the LiveCode language. Share your handlers, functions and magic here.

Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller, robinmiller

dunbarx
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 9567
Joined: Wed May 06, 2009 2:28 pm
Location: New York, NY

Re: Limitations of Dynamically Executing Script in LC

Post by dunbarx » Tue May 04, 2021 11:29 pm

Hi
Are there any examples around of a 'splash stack' ?
Everyone has some. It is a common way of making standalones, where the splash stack is the executable and everything else, like other stacks "attached" to it, or external files that are accessed by it. The executable cannot be saved, which is why other stack files are attached to it. These can be saved. And of course external files can be read and written to.

Try this. Make a new stack, name it "XXX" and save it. In the card script of "XXX""

Code: Select all

on openCard
  go stack "YYY"
end openCard
Now make another stack, name it "YYY" and save it as well. In that stack make a single button and field, and in the button script:

Code: Select all

on mouseUp
  put random(99999) into fld 1
end mouseUp
and in the stack script:

Code: Select all

on closeStackRequest
     save  this stack
end closeStackRequest
You can get random numbers in the field all day.

Now go to menu "File/Standalone Application Settings". In the General pane, name your standalone, say "ZZZ". Now in the "Stacks" pane, click "Add Stack File" and navigate to stack "YYY".

Now go to "File/Save as Standalone Application..."

When all this is done, your first stack ("XXX") is the "splash" stack. which does nothing but open "YYY". But you can now click in "YYY" and each new number will be saved. Nothing in "XXX" can be. "XXX" might, however, read and write to external files.

I am not testing this as I write it, but I think it should work. If not, some little tweak will fix it if I messed up. But that is the general idea.

Craig
Last edited by dunbarx on Wed May 05, 2021 3:56 am, edited 2 times in total.

SteveP495
Posts: 17
Joined: Sun May 02, 2021 1:59 am

Re: Limitations of Dynamically Executing Script in LC

Post by SteveP495 » Wed May 05, 2021 2:18 am

Great thanks very much.

I also found examples for downloading a stack from a server and also from the local file system in Lessons so will have a play later tonight after work (I'm based in Oz).

Out of interest, does a stack have to have the .livecode extension or would

Code: Select all

go stack "/.../myfile.blah"
work ?

TIA
Steve

SparkOut
Posts: 2834
Joined: Sun Sep 23, 2007 4:58 pm

Re: Limitations of Dynamically Executing Script in LC

Post by SparkOut » Wed May 05, 2021 7:37 am

I never tried this with a stack hosted on the Internet, but I frequently change the filename extension for desktop stacks, for example .pref or .dat and it always works fine, so I believe the answer is yes for you too.

SteveP495
Posts: 17
Joined: Sun May 02, 2021 1:59 am

Re: Limitations of Dynamically Executing Script in LC

Post by SteveP495 » Wed May 05, 2021 8:55 am

SparkOut wrote:
Wed May 05, 2021 7:37 am
I never tried this with a stack hosted on the Internet, but I frequently change the filename extension for desktop stacks, for example .pref or .dat and it always works fine, so I believe the answer is yes for you too.
Cool thanks :D

capellan
Posts: 654
Joined: Wed Aug 15, 2007 11:09 pm

Re: Limitations of Dynamically Executing Script in LC

Post by capellan » Thu May 06, 2021 5:47 pm

You could download and open stacks from Google drive too.
There is a thread on this forum explaining how to do this.

Klaus
Posts: 13793
Joined: Sat Apr 08, 2006 8:41 am
Location: Germany
Contact:

Re: Limitations of Dynamically Executing Script in LC

Post by Klaus » Thu May 06, 2021 7:02 pm

Hi all,

regarding the "Splash stack approach", this:

Code: Select all

on closeStackRequest
     save  this stack
end closeStackRequest
will NOT work if the standalone is installed in the dedicated "Application" folder
Mac -> Applications
Win -> Programm files (x86) (not sure, but something like that)

Simply because an "average" (read non admin) user has no write permissions there!
In that case, copy the stack to the users DOCUMENTS folder and open (and save) it from there!


Best

Klaus

Post Reply

Return to “Talking LiveCode”