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

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

Re: Script only Stacks

Post by Klaus » Wed Apr 24, 2019 9:06 pm

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 pm
i.e could the user potentially access the resources folder and modify a script only stack?
Yes.

RobertC
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 46
Joined: Sun Feb 04, 2007 3:43 pm

Re: Script only Stacks

Post by RobertC » Thu Mar 19, 2020 10:10 pm

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?
The Old Rant Robert.

FourthWorld
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 9845
Joined: Sat Apr 08, 2006 7:05 am
Location: Los Angeles
Contact:

Re: Script only Stacks

Post by FourthWorld » Thu Mar 19, 2020 10:15 pm

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)?
Richard Gaskin
LiveCode development, training, and consulting services: Fourth World Systems
LiveCode Group on Facebook
LiveCode Group on LinkedIn

kaveh1000
Livecode Opensource Backer
Livecode Opensource Backer
Posts: 508
Joined: Sun Dec 18, 2011 7:23 pm
Location: London
Contact:

Re: Script only Stacks

Post by kaveh1000 » Fri Mar 20, 2020 12:08 pm

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. ;-)
Kaveh

RobertC
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 46
Joined: Sun Feb 04, 2007 3:43 pm

Re: Script only Stacks

Post by RobertC » Fri Mar 20, 2020 4:58 pm

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 166 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…
:(
The Old Rant Robert.

Thierry
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 875
Joined: Wed Nov 22, 2006 3:42 pm

Re: Script only Stacks

Post by Thierry » Fri Mar 20, 2020 5:47 pm

Code: Select all

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

Code: Select all

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

Take care,

Thierry
!
SUNNY-TDZ.COM doesn't belong to me since 2021.
To contact me, use the Private messages. Merci.
!

RobertC
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 46
Joined: Sun Feb 04, 2007 3:43 pm

Re: Script only Stacks

Post by RobertC » Sat Mar 21, 2020 3:47 pm

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).
The Old Rant Robert.

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

Re: Script only Stacks

Post by bogs » Sat Mar 21, 2020 7:19 pm

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
Image

Post Reply

Return to “Getting Started with LiveCode - Complete Beginners”