Files vs. 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

DavidF.
Posts: 23
Joined: Sat Sep 10, 2016 3:00 pm

Files vs. Stacks

Post by DavidF. » Fri Dec 22, 2017 3:20 pm

hi,

Is there anywhere that gives a good, succinct overview of the relationship in LiveCode between files and stacks? Lately I’ve been getting those cryptic Purge/Save/Cancel messages and though I’m not sure what exactly is going on I do know I’ve been losing quite a bit of work. The impression I’m getting is that there is a kind of primacy of the stack in LiveCode and that the file is just a kind of fortuitous convenient container for stacks. I think my problems have come about because I’ve been working on a simple practice stack and creating backup versions as I go. Close one version, open the other, of course the name of the stack is the same as in the old one and this is what seems to matter to LiveCode. In the midst of all this and my complete unfamiliarity with this way of doing things the old stack overwrites the new. I think.

It’s as though LiveCode operates entirely in its own space, which LiveCode files as such are only contributors to.

I see from a forum search that this has come up before, in Current IDE Oddities and Obstacles viewtopic.php?f=67&t=23717 as one of the obstacles to new users. This business of files and stacks is a fairly basic aspect which you can nonetheless ignore as you make progress – ignore that is until you start losing work. It’s such a fundamental difference from normal computer usage, where the file is an island, complete unto itself, that I think it would merit some up-front mention. I also assume this way of doing things has some functional benefits and these would be worth mentioning too.

The other typical case where this comes up: create a new stack, then create another new stack, no you can’t do that because then you would have two stacks both called “Untitled”. This is surprising if you’re a new user and expect this to be like creating a couple of new documents in Word.

So what would be the best way to work through a series of versions? When I do a Save As to create a separate newer version should I also make sure I rename the stack to avoid the possibility of confusion and loss of work?

-- DavidF.

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

Re: Files vs. Stacks

Post by FourthWorld » Fri Dec 22, 2017 5:39 pm

When I create a new stack here, the first one is titled "Untitled 1". If I close it and make another, the second is titled "Untitled 2".

Can you give us a recipe to reproduce what you're seeing?
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/

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

Re: Files vs. Stacks

Post by dunbarx » Fri Dec 22, 2017 6:15 pm

Unlike HC, where a stack and its enclosing file were one and the same, LC maintains these as separate entities.

I have to deal with this constantly, since I am creating new versions of a stack in a project I am working on, and in order to create manageable standalones for each new version, I have to make sure that I update the file name, the stack name and the standalone name.

My point is that it is possible to mix any of these along the path of creating successive versions, and you will not get an error anywhere, though you may lose track of the sequence.

So say I had "workingStack25" in file "stack25" and created a standalone "app25". I could update my stack to "workingStack26" but maintain it in the file "stack25". When creating a standalone, I could leave the standalone name as "app25" if I wanted to. I never do, but that does not mean that I never do.

There are tricks to learn. The OS will oftentimes create a copy of the file if the order of updating is not performed in a certain sequence. This does no harm, but can be confusing, at least to me. I have pa procedure to prevent this, assuming I remember to do it.

Ultimately, the LC scheme gives maximum flexibility. For example, one can add one or more stack files to a standalone, and they are included in the final bundle, just as if they were stacks in the IDE.

Craig Newman

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

Re: Files vs. Stacks

Post by FourthWorld » Fri Dec 22, 2017 6:38 pm

While it would be nice if the IDE were updated to allow multiple stacks with the same name, in the meantime multiple instances of LiveCode allow copy and paste it even LiveCode objects between them.

In some ways this is almost better, since you also don't need to worry about global variables, behavior objects, or anything else that might be affected by two apps manipulating the same things in the same namespace.
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/

DavidF.
Posts: 23
Joined: Sat Sep 10, 2016 3:00 pm

Re: Files vs. Stacks

Post by DavidF. » Fri Dec 22, 2017 7:05 pm

FourthWorld wrote:
Fri Dec 22, 2017 5:39 pm
When I create a new stack here, the first one is titled "Untitled 1". If I close it and make another, the second is titled "Untitled 2".

Can you give us a recipe to reproduce what you're seeing?
Ermm... You're quite right of course, the behaviour is as you describe. Now I've checked my notes I see that the actual problem was when I had created a stack, unnamed and therefore called "Untitled (1)". Then for comparison, I opened an LC file created by someone else; the author had not actually named the stack, so it too was called "Untitled (1)", and this was what LC wouldn't allow. I have evidently exaggerated the problem in retrospect... It was a puzzle to me at the time, though, and it illustrates the conceptual difficulty I'm talking about: to me these were two separate files and therefore completely distinct; whereas to LC what mattered were the stacks.

-- DavidF.

DavidF.
Posts: 23
Joined: Sat Sep 10, 2016 3:00 pm

Re: Files vs. Stacks

Post by DavidF. » Fri Dec 22, 2017 7:21 pm

The other "conceptual difficulty" that intersects with this namespace one is the question of what actually is opened or closed. Ie the notion of "closed but remaining in memory", which is also one that I will have to become more familiar with. It's this intersection that I think has resulted in things that in my mind are distinct actually overwriting each other and losing my changes.

Maybe none of this is intrinsically complex but it is very different from anything I'm familiar with.

I guess in the meantime I will start renaming the stacks as well as the files of previous versions, as per your example Craig, to be on the safe side.

-- DavidF.

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

Re: Files vs. Stacks

Post by FourthWorld » Fri Dec 22, 2017 7:44 pm

In the older IDE new stacks were named "Stack <milliseconds>", so the odds of having two stacks with the same name were closer to zero.

In production it's rare to have stacks with default names; we give them meaningful names per their role so we know what they are. ;)

But long before one gets into production we have a learning phase, where it's quite reasonable for a newcomer to leave the default name in place.

My own IDE extension (devolution) has a New Stack feature that prompts the user for a name before creating the stack. Given that nearly all stacks made with LC serve some purpose, having a user-defined name benefits from being able to know what it's for, and avoids the downsides of trying to use the consumer-app convention of "Untitled <n>" in a dev tool like LC. Frankly I'm surprised the LC IDE doesn't similarly encourage stack naming at creation.

If I get time later I may submit a request for something like that.
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/

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

Re: Files vs. Stacks

Post by bogs » Fri Dec 22, 2017 7:46 pm

DavidF. wrote:
Fri Dec 22, 2017 7:21 pm
The other "conceptual difficulty" that intersects with this namespace one is the question of what actually is opened or closed. Ie the notion of "closed but remaining in memory"
Yah, I had the same experience when coming to this language from other languages, mainly because I skipped out of the whole .net/java/similar frameworks thing in my case (most of which also load the program into memory and in certain cases keeps it there).

There are options to this behavior though, you can either a.) keep in mind that by default, the erm...program lets say, is left in memory, or b.) set it to destroy itself, which removes it from memory on close.

Both have relative merits / downsides, the default behavior leads to speedier reloads of the program, but takes up memory until the system shuts down. Setting it to destroy frees the memory, but if your working on a very large program, that takes a long time to load, could be a performance penalty (although in recent years I have not written a program so large that modern hardware couldn't launch it handily enough).

I set all stacks I make now to close out completely, unless they are system utilities or are monitoring system utilities.

About working on files that have the same stack name (where it pertains to your own work, this wouldn't be of help in the other example you gave), you can always clone a stack, which creates a copy of that stack. In the case of your friend sending you an untitled mainstack, and you had one open, all I can add there is that I name stacks immediately, but I did that previous to coming to Lc and more to keep my own sanity.

I see Richard posted ahead of me while I was composing this work, if there is any overlay in commentary it was purely coincidental :P
FourthWorld wrote:
Fri Dec 22, 2017 7:44 pm
My own IDE extension (devolution) has a New Stack feature that prompts the user for a name before creating the stack.
One of my favorite things when using your extension, if you do submit a request, I really hope they implement it.
Image

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

Re: Files vs. Stacks

Post by richmond62 » Fri Dec 22, 2017 9:24 pm

In the older IDE new stacks were named "Stack <milliseconds>"
Presumably that refers to MetaCard, which by this stage is ancient history, as is HyperCard.

"the older IDE" is not at all clear and does not really help.

Just cracked open Revolution 4.5 and it opened a new stack in exactly the way LiveCode 8.1.8 does.

DavidF.
Posts: 23
Joined: Sat Sep 10, 2016 3:00 pm

Re: Files vs. Stacks

Post by DavidF. » Fri Dec 22, 2017 9:53 pm

bogs wrote:
Fri Dec 22, 2017 7:46 pm
DavidF. wrote:
Fri Dec 22, 2017 7:21 pm
The other "conceptual difficulty" that intersects with this namespace one is the question of what actually is opened or closed. Ie the notion of "closed but remaining in memory"
I set all stacks I make now to close out completely, unless they are system utilities or are monitoring system utilities.

About working on files that have the same stack name (where it pertains to your own work, this wouldn't be of help in the other example you gave), you can always clone a stack, which creates a copy of that stack
Thanks for this, those are two useful-sounding features I'll be exploring - cloning a stack as part of the backup/version-making process (as it's the stack that matters, at least as much as the file), and turning off the "hold in memory" feature on a per-stack basis.

-- DavidF.

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

Re: Files vs. Stacks

Post by bogs » Fri Dec 22, 2017 10:25 pm

Just keep in mind there are some caveats with cloning stacks as well, for instance, when your projects get more complicated, you might have substacks of your mainstack. Those would not be cloned with the mainstack, as you see here -
Image.
Now, you can always clone those as well, just make sure the clones mainstack is set to your projects mainstack.

This is no issue for me personally, as I generally speaking work on one stack at a time (not always, but mostly), then combine them at the end.
Image

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

Re: Files vs. Stacks

Post by bogs » Fri Dec 22, 2017 10:43 pm

richmond62 wrote:
Fri Dec 22, 2017 9:24 pm
Presumably that refers to MetaCard, which by this stage is ancient history, as is HyperCard.
<sic>
Just cracked open Revolution 4.5 and it opened a new stack in exactly the way LiveCode 8.1.8 does.
Sure, you and yer fancy new fangled Rev 4.5 (typing this as I merrily am still plugging away on Mc3.x :P )
Image

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

Re: Files vs. Stacks

Post by FourthWorld » Fri Dec 22, 2017 11:01 pm

richmond62 wrote:
Fri Dec 22, 2017 9:24 pm
In the older IDE new stacks were named "Stack <milliseconds>"
Presumably that refers to MetaCard, which by this stage is ancient history, as is HyperCard.

"the older IDE" is not at all clear and does not really help.
It was exactly as helpful as it needed to be: by noting that there was once an IDE that used unique stack names by default, it validates the OP's concern about duplicate names.

There's no more point to what I wrote beyond that. Explaining the 25-year history of the code base would not seem relevant to his immediate concern.
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/

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

Re: Files vs. Stacks

Post by bogs » Fri Dec 22, 2017 11:36 pm

FourthWorld wrote:
Fri Dec 22, 2017 11:01 pm
Explaining the 25-year history of the code base would not seem relevant to his immediate concern.
Um, you can send that discussion my way if you want :D (getting the popcorn).
Image

DavidF.
Posts: 23
Joined: Sat Sep 10, 2016 3:00 pm

Re: Files vs. Stacks

Post by DavidF. » Fri Dec 22, 2017 11:37 pm

bogs wrote:
Fri Dec 22, 2017 10:25 pm
Just keep in mind there are some caveats with cloning stacks as well, for instance, when your projects get more complicated, you might have substacks of your mainstack. Those would not be cloned with the mainstack
Thanks - I am strictly at the "single stack" stage of learning at the moment but I will bear this in mind.

A lot here to digest and try out. I learned via this thread (Crazy Stack File Saving System?) viewtopic.php?f=7&t=20173 about the filename property of stacks, which looks like a useful check on what belongs where.

I tried cloning my solitary stack, then did a Save As, creating a new file. Original Stack stayed in the original file, Copy of Original Stack ended up in the new one, on what basis I'm not sure.

Then I did

Code: Select all

set the filename of the stack "Copy of Original"  to original.livecode 
Opened the original file and there was Copy of Original Stack... With this plus the Save stack command you could surely do something programmatic, as part of some kind of backup system... Use Save to make a new LiveCode file, clone the stack, name it incrementally by some convention, set its filename to the new file...

LiveCode really is almost ridiculously flexible... As soon as you start thinking about something, you start to see how you could do it.

-- DavidF.

Post Reply

Return to “Getting Started with LiveCode - Complete Beginners”