Page 2 of 2

Re: Script only Stacks

Posted: Wed Apr 24, 2019 9:06 pm
by Klaus
hrcap wrote: Wed Apr 24, 2019 8:59 pm When the stack is built into a standalone application, is the resources folder protected?
No.
hrcap wrote: Wed Apr 24, 2019 8:59 pmi.e could the user potentially access the resources folder and modify a script only stack?
Yes.

Re: Script only Stacks

Posted: Thu Mar 19, 2020 10:10 pm
by RobertC
This is probably my ignorance, but when I try to use a script-only stack by

Code: Select all

start using stack "<path to file S>"

I get

Code: Select all

execution error at line … (Chunk: cant find stack), char 1
Is opening a stack from a file a feature that is not in the community or Indy edition?
I have Indy 9.5.1

Any thoughts?

Re: Script only Stacks

Posted: Thu Mar 19, 2020 10:15 pm
by FourthWorld
Stack files are fundamental to LiveCode; using them is well supported in all editions.

Are you certain the path is correct?

Is the script-only stack in a valid format (with the stack declaration on the first line)?

Re: Script only Stacks

Posted: Fri Mar 20, 2020 12:08 pm
by kaveh1000
I am successfully using multiple script only stacks read in by a main stack. My problem at the moment is encrypting the SOS's in standalone. This is something I still have to work out. If this is of interest to you, then please see this thread:

viewtopic.php?f=9&t=33678&e=1&view=unread#unread

where I have uploaded a minimal stack. I am trying to encrypt on the fly as I make the standalone.

If you don't need this then ignore. ;-)

Re: Script only Stacks

Posted: Fri Mar 20, 2020 4:58 pm
by RobertC
Richard asks if the path is correct and the content.
I'm not sure, but here is an archive (macOS) with the main stack and two files
Archive.zip
(2.1 KiB) Downloaded 775 times
The main stack's button has this script:

Code: Select all

on mouseup
   if the optionkey is down then
      FromPath
   else
      ExplicitFromFile
   end if
   putmilliseconds
end mouseup

on FromPath
   start using stack "/Users/robertcailliau/Desktop/pms.livecodescript"
end FromPath

on ExplicitFromFile
   create script only stack "pms"
   open file "/Users/robertcailliau/Desktop/pms.livecodescript" for "utf-8" text read
   read from file "/Users/robertcailliau/Desktop/pms.livecodescript" until EOF
   set the script of stack "pms" to it
   start using stack "pms"
end ExplicitFromFile
The ExplicitFromFile handler works fine, but the FromPath one gives the error.

Both text files contain the same thing:

Code: Select all

stack "pms"

on putmilliseconds
   put the milliseconds into field 1
end putmilliseconds
There must be something I'm not getting…
:(

Re: Script only Stacks

Posted: Fri Mar 20, 2020 5:47 pm
by Thierry

Code: Select all

stack "pms"
First line of your text file, do:

Code: Select all

script "pms"
That should work better....

Take care,

Thierry

Re: Script only Stacks

Posted: Sat Mar 21, 2020 3:47 pm
by RobertC
Yes Thierry, that does it… Thanks very much for spotting that.
Sorry for not having seen it! (I knew I'd done something terribly stupid).

Strangely though:
when reading it directly:

Code: Select all

   start using stack "/Users/robertcailliau/Desktop/pms.txt"
the first line (script "pms") is removed from the loaded stack script, but when it's read explicity that line is not removed (in fact that's as expected) but it also does not give an error either.

Thanks everyone, have a nice locked-down day if you're in a locked-down situation (I am).

Re: Script only Stacks

Posted: Sat Mar 21, 2020 7:19 pm
by bogs
Just wondering, Robert, whether or not you had come across this article, it seems to answer your observation:
https://livecode.com/script-only-stacks/ wrote: In a nutshell, a script only stack is a text file, structured in a specific way, which the engine can load and save as if it were a normal stackfile. When the engine loads a script only stack, it creates a stack with the name specified in text file and sets the stacks script property to the script specified in the text file. When the engine saves a script only stack it reverses this process, writing out a text file containing the stack name and stack script and absolutely nothing else.
A little further down, you will see what Thierry mentioned...
The fact that script only stack files really are just text files is really important! It means you can edit and create them in any text editor you choose, and use any text based processing tool on them (the key thing for git is that you can diff and patch them)! The only thing to remember is that the very first line in the text file has to be of the form:
script "<name>"
With every line after the first being taken as the stack script.
Reporting from Lockdown New England,
bogs :D

Re: Script only Stacks

Posted: Mon Jul 21, 2025 7:05 pm
by trevix
Hello.
I got my test version of the script only stack (see the attachment).
It works.
What I don't understand is why every time I try to save the "TestSOStack" stack or the "TestScript", be it in the project browser or directly in the stack, the Openstack of the TestScript starts running. It runs also when opening for the first time the inspector of the "TestScript" stack.
Is this a bug?

One more thing: I am not sure of how I arranged the opening order of things. I did my best, considering how little informations there is about it, but I may have done some confusion, in preopestack, openstack, in the card, in the stack, front, back, sideways...

Thanks for any help

Re: Script only Stacks

Posted: Tue Jul 22, 2025 6:16 pm
by jacque
When you save a stack, LC actually creates a new copy and deletes the old one. When the new one runs it's like you just opened it and all normal messages are sent. You can try locking messages before saving, or just type "save stack TestSOStack" in the message box.