Script only Stacks

Got a LiveCode personal license? Are you a beginner, hobbyist or educator that's new to LiveCode? This forum is the place to go for help getting started. Welcome!

Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller

hrcap
Posts: 131
Joined: Mon Jan 14, 2019 5:20 pm

Script only Stacks

Post by hrcap » Thu Apr 04, 2019 5:00 pm

Good Afternoon All

I am currently trying to get to grips with Script Only Stacks and I have a couple of questions:

1) Is there a tutorial anywhere that will walk me through how to create the script only stacks through to including them in a standalone application?

2) how do I include the script only stacks in a standalone application?


Many Thanks

jmburnod
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 2718
Joined: Sat Dec 22, 2007 5:35 pm
Location: Genève
Contact:

Re: Script only Stacks

Post by jmburnod » Thu Apr 04, 2019 5:31 pm

Hi hrcap,
I never used script only stack but i found a doc about it.
https://livecode.com/script-only-stacks/
Best regards
Jean-Marc
https://alternatic.ch

hrcap
Posts: 131
Joined: Mon Jan 14, 2019 5:20 pm

Re: Script only Stacks

Post by hrcap » Thu Apr 04, 2019 5:41 pm

Hi Jean Marc

Thanks for the reply, I had already seen this one but unfortunately it doesn’t go into enough detail.

Thanks for taking the time to reply much appreciated

bogs
Posts: 5435
Joined: Sat Feb 25, 2017 10:45 pm

Re: Script only Stacks

Post by bogs » Thu Apr 04, 2019 8:48 pm

Heya hrcap,

Trevor posted this a while back, might be helpful to you. My take on it (much like Mark W. said in Jean-Marc's post) is that the main benefit to it is version control, since it is just a plain text file.

It looks like replacing libraries or objects with behaviors would be the next best use for them. As far as deploying them goes, I'd just copy the files into the standalone builder, and save them out when your stack runs *if* your stack doesn't find them already there (alternately, you could just save them out every time and delete them when done).
Image

hrcap
Posts: 131
Joined: Mon Jan 14, 2019 5:20 pm

Re: Script only Stacks

Post by hrcap » Sat Apr 06, 2019 6:14 pm

Hi All

Thanks for the reply so far.

I have two elements to my test scenario:

a) a stack with a button on with the following script:

on mouseup
open stack (specialFolderPath ("resources") & "/test.livecodescript")
end mouseup



b) a 'script only stack' titled: 'test.livecodescript' containing the script

script "hello world"


on openstack
answer "hello world"
Close me
end openstack




When creating the standalone for an iOS device I have two questions:

1) do I include the script only stack within the 'Copy Files' tab of the standalone application settings?


2) if so what adjustments do I need to make to the button scrip mentioned in a) above in order to use that script only stack

open stack (specialFolderPath ("resources") & "/test.livecodescript")



Many thanks

Hadleigh

bogs
Posts: 5435
Joined: Sat Feb 25, 2017 10:45 pm

Re: Script only Stacks

Post by bogs » Mon Apr 08, 2019 8:52 pm

Hm, maybe no one knows (but I'm sure that isn't true, so *bump*) :D
Image

jacque
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 7215
Joined: Sat Apr 08, 2006 8:31 pm
Location: Minneapolis MN
Contact:

Re: Script only Stacks

Post by jacque » Tue Apr 09, 2019 5:45 pm

1} Yes, script only stacks go into the Copy Files pane.

2) Script only stacks are no different from regular stacks with the exception that they only contain a stack script. Treat them exactly like a library stack. When your app launches, start using the stack. That will insert its script into the message hierarchy similar to a backscript.

Since your script only stack triggers on openstack, you'll want to start using it before that, or change the trigger to something later in the message hierarchy. Or use a "send in time" command to trigger it after startup is fully complete.
Jacqueline Landman Gay | jacque at hyperactivesw dot com
HyperActive Software | http://www.hyperactivesw.com

MaxV
Posts: 1579
Joined: Tue May 28, 2013 2:20 pm
Location: Italy
Contact:

Re: Script only Stacks

Post by MaxV » Mon Apr 22, 2019 10:55 pm

Livecode Wiki: http://livecode.wikia.com
My blog: https://livecode-blogger.blogspot.com
To post code use this: http://tinyurl.com/ogp6d5w

hrcap
Posts: 131
Joined: Mon Jan 14, 2019 5:20 pm

Re: Script only Stacks

Post by hrcap » Wed Apr 24, 2019 6:48 pm

Ok All

Thank you so much for the input so far, I am starting to get there, one problem that I have is...:

- When I first open the main stack I have the following code to start using the script only stack

Code: Select all

start using stack(specialFolderPath ( desktop ) & "/test.livecodescript") //this is a remote script
  

- The code on the script only stack is as follows:

Code: Select all


script "test"

On openstack
   
   Answer "helloworld"
   
End openstack


- When the first stack is opened it immediately displays "helloworld"


can I change the 'on Openstack' part within the script only stack to something else to stop this from happening when the main stack is first opened?

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

Re: Script only Stacks

Post by Klaus » Wed Apr 24, 2019 7:04 pm

hrcap wrote:
Wed Apr 24, 2019 6:48 pm

Code: Select all

start using stack(specialFolderPath ( desktop ) & "/test.livecodescript") //this is a remote script  
Do yourself a favour and get used to use QUOTES around ANY string:

Code: Select all

start using stack(specialFolderPath("desktop") & "/test.livecodescript")
hrcap wrote:
Wed Apr 24, 2019 6:48 pm

Code: Select all

script "test"
On openstack 
   Answer "helloworld"  
End openstack
- When the first stack is opened it immediately displays "helloworld"
Yes, and that is correct behavior,right! :D
hrcap wrote:
Wed Apr 24, 2019 6:48 pm
can I change the 'on Openstack' part within the script only stack to something else to stop this from happening when the main stack is first opened?
Why don't you just try?
If you are too scared, yes this is of course possible. 8)

Hint:
If you put that script-only stack into the same folder as your stack, the you can use this in the IDE AND in your standalone::

Code: Select all

start using stack(specialFolderPath ("resources") & "/test.livecodescript")

hrcap
Posts: 131
Joined: Mon Jan 14, 2019 5:20 pm

Re: Script only Stacks

Post by hrcap » Wed Apr 24, 2019 7:19 pm

Hi Klaus

Thank you very much.

I will be sure to start using "" around all strings.

The problem that I was having was that "hello world" was displaying straight away and I didn't want it to display until I clicked a button.

On further investigation this was because on prestackopen of the main stack I was using the wording

Code: Select all

start using stack (and then the path of the script only stack)
I changed this to

Code: Select all

start using (and then the path of the script only stack)

This has stopped the "hello world" message displaying at the initial stack open and it now only displays when a button is used to call the script only stack (the desired behaviour).



I have added this script only stack example incase it of use to anyone.


Many Thanks for everyones help.
Attachments
Script only stack example.zip
(2.7 KiB) Downloaded 206 times

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

Re: Script only Stacks

Post by Klaus » Wed Apr 24, 2019 7:25 pm

Problem is you scripted "on openstack" (start using is like GO stack!), but leaving out "stack" while "start using" that file is really puzzling me and I consider this a bug!

However you should have named your script like "on helloworld" which makes more sense:

Code: Select all

script "test"
On helloworld 
   Answer "helloworld"  
End helloworld
Know what I mean?

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

Re: Script only Stacks

Post by Klaus » Wed Apr 24, 2019 7:29 pm

Your example stack will work right "out of the box" if you use my proposed specialfolderpath() code!

Code: Select all

on preopenstack   
   start using (specialFolderPath("resources") & "/test_script_only_stack.livecodescript") 
end preopenstack
No need to move the script only stack anywhere else!

hrcap
Posts: 131
Joined: Mon Jan 14, 2019 5:20 pm

Re: Script only Stacks

Post by hrcap » Wed Apr 24, 2019 7:34 pm

excellent thank you, I have modified the script only stack here:
Attachments
Script only stack example.zip
(3.85 KiB) Downloaded 215 times

hrcap
Posts: 131
Joined: Mon Jan 14, 2019 5:20 pm

Re: Script only Stacks

Post by hrcap » Wed Apr 24, 2019 8:59 pm

When the stack is built into a standalone application, is the resources folder protected? i.e could the user potentially access the resources folder and modify a script only stack?

Post Reply

Return to “Getting Started with LiveCode - Complete Beginners”