Why 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: Klaus, FourthWorld, heatherlaine, kevinmiller

Post Reply
richmond62
Livecode Opensource Backer
Livecode Opensource Backer
Posts: 4569
Joined: Fri Feb 19, 2010 10:17 am
Location: Bulgaria

Why Script-only stacks?

Post by richmond62 » Thu Apr 09, 2020 7:17 am

I have noticed, from time to time, something about script-only stacks popping up hereabout.

Could someone explain, in relatively simple language:

1. What is a script-only stack?

2. What might be an advantage in using a script-only stack?

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

Re: Why Script-only stacks?

Post by FourthWorld » Thu Apr 09, 2020 7:35 am

This is a good one for the "what", and some of the "why":
https://livecode.com/script-only-stacks/

In addition to working well with version control systems designed for other languages, I sometimes find them useful as server libraries, so I can edit them on the remote machine in Terminal.
Richard Gaskin
Community volunteer LiveCode Community Liaison

LiveCode development, training, and consulting services: Fourth World Systems: http://FourthWorld.com
LiveCode User Group on Facebook : http://FaceBook.com/groups/LiveCodeUsers/

Mikey
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 716
Joined: Fri Jun 27, 2008 9:00 pm

Re: Why Script-only stacks?

Post by Mikey » Thu Apr 09, 2020 4:26 pm

I can think of a lot of reasons:
1. "Version Control". It's so much more than that. It's clarity, and an audit trail, and tracking what everyone who is working on a project is doing, and not having to embed hundreds of lines of version-related comments into a file that mean less and less the further you are away from when the file was crafted, and being able to run experiments easier, and easily being able to revert to prior code if something breaks, and just generally a much less aggravating experience, and having the ability to impose a certain level of discipline on everyone who is not only involved on LC projects, but all projects across all environments on all platforms. Don't even get me started on some of the git-specific things like submoduling for libraries.
2. Agnostic code editing. If you don't like the script editor, don't use the script editor. Let's debate text editors. Why? Because we can use whatever text editor we choose to edit code in an SOS. Text editors are very specialized tools that have extensive resources thrown at them because the task is so specialized.
3. Even MORE platform-agnostic. Ever do editing on your phone while you're in the queue for the loo (That's some fine British lingo, right there, and I get that all the loos are closed because you're supposed to be buttoned up in your cottage by the sea, and even if they weren't, unless you have a bidet you wouldn't be able to clean up afterwards, because the zombies came and stole all the two-ply)? You can edit on your phone with SOS's, because you don't need to run the LC binary to work on an SOS. Got your eye on that brand-spanking new ipad pro - you know, the one with the new Magic Keyboard with the trackpad that won't be available until May? You can code on that, without using some remote access tool to get into your main development machine.
4. Ability to use file-system-level searching to search across all code for...something, because there are times when you are looking for some bit of code and for the life of you, where the hell is it? Example: In another tool we use, we have this very clever routine we wrote that is long and was very expensive to write. Then the project got compiled, and the original source was lost, somehow, and it was years before we realized the mistake, because no one needed to work on it, and by that time the backups and the original box the developer had been using had been recycled. If we had been searching for that code in another project, hoping to recover it, and our projects were saved the way LC stacks are saved, we would have had a very lengthy search, and it would have primarily been manual. Instead, we did a series of file-system searches (because if the code is compiled you can't be sure exactly what you're looking for), and found it relatively quickly.
5. Split the project into smaller files which means it's far easier to recover if something gets corrupted. If an LC stack gets corrupted you have a very difficult problem. If an SOS gets corrupted, not so much.

mrcoollion
Posts: 555
Joined: Thu Sep 11, 2014 1:49 pm
Location: The Netherlands

Re: Why Script-only stacks?

Post by mrcoollion » Fri Apr 10, 2020 8:19 am

Some questions.

- When I work with global / Local variables are those still usable within the script in a script only stack?
- Are there any restrictions one needs to take in account?
- Can script only stacks be protected from code theft (encrypted)?
- What editors work well with LC Scrip only stacks?

Regards,

Paul

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

Re: Why Script-only stacks?

Post by bogs » Fri Apr 10, 2020 12:12 pm

mrcoollion wrote:
Fri Apr 10, 2020 8:19 am
1. - Can script only stacks be protected from code theft (encrypted)?
2. - What editors work well with LC Scrip only stacks?
I believe the answer to 1. was 'no' from another thread recently here on the forum, and while this isn't the one I'm thinking of, it would seem to say the same under 'normal' circumstances. Apparently the Levure frame work can do it, but I don't know much about it.

#2 would be one of the beauties of S.O.Stacks, since they are only text files, you can use any text editor to work on one. Of course, finding a text editor with the Lc lex available is another question, I know that a few were produced for editors like Sublime, BBEdit, and the like.
Image

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

Re: Why Script-only stacks?

Post by kaveh1000 » Fri Apr 10, 2020 2:17 pm

Regarding encryption, according to a great idea by Jacque, it should be possible to encrypt automatically at the point of making a standalone. But when I tried it it did not work. Please thread here:

https://forums.livecode.com/viewtopic.p ... 35#p189835

Any ideas on that thread welcome.

Kaveh
Kaveh

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

Re: Why Script-only stacks?

Post by bogs » Fri Apr 10, 2020 2:28 pm

Thank you Kaveh, that was indeed the thread I was thinking of :D
Image

richmond62
Livecode Opensource Backer
Livecode Opensource Backer
Posts: 4569
Joined: Fri Feb 19, 2010 10:17 am
Location: Bulgaria

Re: Why Script-only stacks?

Post by richmond62 » Fri Apr 10, 2020 2:37 pm

What editors work well with LC Scrip only stacks?
Well; any old text editor should work with an LC script-only stack.

HOWEVER, depending on what one exactly means by "work well" . . .

If I had an urge to work on an LC script outwith the IDE's script editor (which I find is just fine for my purposes)
I would try to find a text editor that "did the colours" the way the IDE script editor does . . .

A few years ago I worked on some of my monster my scripts in Devawriter Pro (some stretch to more than 6,000 lines)
using AppleWorks on a PPC Macintosh. AppleWorks did not colourise stuff; but I found the search-&-replace tools
more to my taste than those in the IDE script editor.

What is also useful is to be able to 'see' parts of a long script in 2 or 3 windows: say, lines 1 to 100 in windows 1, lines 1500 to 1600 in window 2,
and lines 1780 to 1900 in window 3. This means one does not have to scroll back and forth like someone possessed.

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

Re: Why Script-only stacks?

Post by kaveh1000 » Fri Apr 10, 2020 2:40 pm

Hi Richmond

The big drawback for me with working in 3rd party editors is that I cannot immediately save and run the code as I can when I am in the LiveCode IDE. It is rare that I write more then a couple of lines before rerunning. How do you deal with that?

Kaveh
Kaveh

richmond62
Livecode Opensource Backer
Livecode Opensource Backer
Posts: 4569
Joined: Fri Feb 19, 2010 10:17 am
Location: Bulgaria

Re: Why Script-only stacks?

Post by richmond62 » Fri Apr 10, 2020 2:49 pm

I don't deal with it as I gave up using an external editor when I became more comfortable
with the IDE's search and replace tools about 7 years ago.

The only possible advantage I can see about using an external editor is if one has a team of developers but owns only one commercial licence.

Mikey
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 716
Joined: Fri Jun 27, 2008 9:00 pm

Re: Why Script-only stacks?

Post by Mikey » Fri Apr 10, 2020 6:51 pm

I think that all of these concerns are addressed (theming, encrypting stacks, and live-updating LC). I will discuss them all below.

Several of the issues can be handled if you use the Levure framework for LC. It's not necessary to make SOS's work, but it does make some of these issues more automatic. Trevor has videos on his channel that demonstrate some of these topics. I do not believe that he shows how to theme. I can't stand the theme he uses, so I use a different one. I think I probably wrote instructions on how to do that on the email list at one time. The hardest part was choosing one, because there are many to choose from.

One other question that will come up is "how do i get my scripts into SOS's? There are a number of ways to do that. Navigator has a mechanism, there is one buried in the tools folder in the LC package called "Scriptifier", and there are others, as well. You can also do it manually only for the scripts that you want to export by right-clicking on the object. In his videos, Trevor only tends to export longer (>5 lines) scripts. I do everything.

So let's talk for a minute about Levure. Levure is just a LC framework that you can attach to your project. I'd suggest watching Trevor's videos and then start asking questions. There is also a Levure wiki on github, with lots and lots of information and help. There have been multiple videos during LiveCode Global, and discussions here and on the email list. You don't need to use Levure, it just makes going SOS simpler, helps you impose more organization, and has library and feature add-ons that you might like (and, if you start using git, updating those modules and that codebase is straightforward and pretty painless).

Encryption - Levure has a mechanism to handle that. Trevor explains how he does it, if you just want to do it yourself, instead.

Text editors - the two that seem the most popular with LC'ers are Atom and SublimeText.
There are indent, grammar, and parsing addons that work with both with LC. The most complete setup also includes installing a copy of LiveCode Server on your development machine. The reason is that the plugins will communicate with LCS to check your code for syntax issues, color it on-the-fly, do most of the indenting.
• Atom is generally a more polished-feeling/prettier experience, but it's slower, and I do not yet know of a way to get it to live-update your project that is open in LC, but maybe that's changed.
• SublimeText is faster than Atom at almost everything, and there is a plugin for it that is intended to be used with Levure projects that will tell LC to reload the script you are working on once you save it. Basically you install a small python script into the ST plugins, and then when you open your Levure project, it automatically launches a socket listener in LC. Then when you save the file in ST, the plugin sends the signal on the socket. Your Levure project is listening on the socket, and reloads the SOS.
Both editors work well. We use both of them for different things, here (mainly different languages because some of the grammar files for other languages are optimized for Atom, for example, whereas the LC experience is IMHO generally better in ST because of the script reload functionality).
Personally I only use the SE when I have to, like when I'm debugging. Dedicated text editors have so many additional features and add-ons that I cannot get in the SE, like code folding (especially with shortcuts and being able to fold/unfold different levels, and fold or unfold depending on the cursor position) and code blocks, which let me have these very long handlers that I don't have to break up to make them readable, because in a dedicated text editor, I can just fold them. Both of those are such incredible time-savers.

foosmaster
Posts: 30
Joined: Mon Apr 13, 2020 8:46 am

Stacks scripts only

Post by foosmaster » Mon Apr 13, 2020 8:54 am

Hi,

I have a REALLY simple app with 2 cards, but I want to separate functionality in different stacks - in particular I'd like to have 2 scripts only stacks.
it's easy to track changes via git this way, and also has a nice separation.
I can't figure out how to define the "project" or the dependency between the cards and stacks.
the only way I managed to get this working is this (which is bad - I know)
1. inspect a label in a card, go to behavior, create a new stack A - now that stack is included as part of the "project"
2. open a message box, type there
>> start using "A"

now I can use this - but this doesn't make sense - since I have to do step #2 every time I open my 'main' stack

clearly - I am missing something simple here
Thanks a lot.
the Fossball master :)

richmond62
Livecode Opensource Backer
Livecode Opensource Backer
Posts: 4569
Joined: Fri Feb 19, 2010 10:17 am
Location: Bulgaria

Re: Stacks scripts only

Post by richmond62 » Mon Apr 13, 2020 9:48 am

foosmaster wrote:
Mon Apr 13, 2020 8:54 am
now I can use this - but this doesn't make sense - since I have to do step #2 every time I open my 'main' stack
Well, personally, I'd stick that in an openStack statement in the 'main' stack.

foosmaster
Posts: 30
Joined: Mon Apr 13, 2020 8:46 am

Re: Stacks scripts only

Post by foosmaster » Mon Apr 13, 2020 10:21 am

thanks - that's nice as starting to use the stack - half way there :)

but whenever I open the main stack - all I see is the main stack - and not the 'library' one I created ..
is there a way to indicate these 2 work hand in hand ? (like a solution in Visual Studio)

richmond62
Livecode Opensource Backer
Livecode Opensource Backer
Posts: 4569
Joined: Fri Feb 19, 2010 10:17 am
Location: Bulgaria

Re: Stacks scripts only

Post by richmond62 » Mon Apr 13, 2020 10:30 am

Try something like this:

Code: Select all

on openStack
open stack "secondary stack"
end openStack

Post Reply

Return to “Getting Started with LiveCode - Complete Beginners”