Page 1 of 1
saving substack
Posted: Wed Feb 16, 2011 3:31 pm
by reelstuff
I was looking for some information on a method of saving a substack,
If I load a substack
Code: Select all
on openCard
open Rewriter
end openCard
Then make some changes to the substack, I was looking at the dictionary and found this,
Code: Select all
on mouseUp
save stack "Rewriter"
end mouseUp
In a standalone should this work to save the text contents of a substack,
When I try it, then close the app and open it again the changes were not saved.
Just curious about the process of saving a substack there appears to be no information on this in the dictionary,
Re: saving substack
Posted: Wed Feb 16, 2011 3:46 pm
by Klaus
Hi reelstuff,
standalones cannot save themselves, I was sure this was even known in the USA today
ther are a couple of options that you have, I can hint you to my latest newsletter articls about this topic:
Part 1:
http://runrev.com/newsletter/october/is ... etter3.php
Part 2:
http://runrev.com/newsletter/december/i ... etter4.php
Best
Klaus
Re: saving substack
Posted: Wed Feb 16, 2011 3:54 pm
by reelstuff
Thanks Klaus yes, I knew it, I was just curious why this is, by the way thank you for the links.
This is one of the things I wish just worked about livecode
Sadly, it is like jumping through hoops to do something that in other IDE is as simple as a line or two, It is a little frustrating to have to constantly run around the old oak tree to do something that really should be simple.
Still your links are greatly appreciated, I will prepare to jump through some hoops
Re: saving substack
Posted: Wed Feb 16, 2011 8:12 pm
by FourthWorld
reelstuff wrote:Thanks Klaus yes, I knew it, I was just curious why this is, by the way thank you for the links.
This is one of the things I wish just worked about livecode
That an app is prevented from altering itself at runtime is an OS thing, not a LiveCode thing.
Re: saving substack
Posted: Wed Feb 16, 2011 10:30 pm
by reelstuff
Sorry If I misunderstood, but I was under the impression that live code is an engine that is compiled and then distributed, which would mean that you cannot compile at runtime, because of the engine and you cannot change the executable because of the OS, just curious about the differences, in say this layered, approach to the 4GL environment and say Borland, which is somewhat different in its approach.
I have sort of hit this wall in the past in trying to develop solutions, I do not know how some other RADs may approach this but this is my basic understanding of how live code works, Am I incorrect?
Re: saving substack
Posted: Thu Feb 17, 2011 12:06 am
by FourthWorld
I'm not sure I follow your post, reelstuff, but I'll see if I can clarify:
Modern OSes just don't allow an executable to be modified when it's running. I don't know much about Borland (other than that Delphi is said to be a great tool), but I would imagine the same applies to them as to any other toolmaker because AFAIK there's nothing any toolmaker can do to override that OS behavior.
As far as compilation, it's true that in general compilation requires the development engine. However, you can successfully set the script of an object at runtime as long as that script doesn't contain more than 10 executable lines. Few people ever need to do that anyway, since self-modifying code is widely regarded as a rat's nest of debugging nightmares.
But where LC differs from many other IDEs is that in addition to code stack files contain your user interface objects, and if your app supports saving data it can be desirable for some designs to use a stack file as the data file.
As with any other tool, and saved data must be separate from the executable file, but with LC that's dirt-simple to do: just use a separate stack file and use the "save" command on it. Depending on the particulars of your app there may be other considerations, like making sure any stack files are saved to folders with known write permissions, but the general principle of just using a stack file separate from your executable for data that needs to be saved is fairly straightforward.
In this regard LC is very much like any other RAD tool. Where LC offers and advantage, IMO, is that you can do that as easily with raw data as you can with any objects the engine supports, opening up very flexible options for what's in a data file and managing them easily.
For example, suppose you were making a custom drawing application. With most IDEs you'd have to store the definitions of the vector objects, and re-create them on the fly when a document is opened. But with LC, you can just use a stack file as your document, let the user draw into that, and in one line of code (the "save" command) you have everything in one file; the engine does all the work, and opening it again is just a matter of using the "open" command.
Re: saving substack
Posted: Thu Feb 17, 2011 12:23 am
by bn
Hi Reelstuff,
I give it a try to explain it.
If you make a standalone from your stack and stack means stack and its substacks, this will be included in the standalone as compiled. As such you can not modify that stack and its substacks since no Operating System allows to make changes to an executable. This stack (and its possible substacks) is what would be the splash stack in the splash approach.
What can be saved however is another stack that you include in the Standalone application settings -> Stacks -> add Stack file as a stack file. This stack and its substacks are in fact saveable and thus the data is persistent.
The confusion arises from the use of the word substacks. Any Mainstack can have substacks. But a substack is still part of the main stack. In case of the Standalone Splash Stack all substacks of the Splash Stack can not be saved.
However the substacks of your working stack aka a stack file are automatically saved if you save your working stack, even from a standalone. (you would have to issue a save this stack though)
In your Splash Stack, which would only show for a short time (since Splash) you would issue a go to my other stack command and then you do what you want and save it. Next time you open your application you will automatically start your Splash stack again and you would be automatically led to you working stack.
The location your working stack is included depends on the operating system. There are instructions for that. In your standalone Splash Stack you would have to indicate the path to the working stack accordingly to open it.
That is basically it.
I hope I got it right and made it clear.
Kind regards
Bernd
Re: saving substack
Posted: Thu Feb 17, 2011 12:31 am
by reelstuff
@Richard Gaskin Thanks yes, that is the best explanation I have ever heard concerning how LC works, I appreciate your reply.
So while you cannot save a substack you can save a separate "stack" in a folder, or other such locations, interesting again thank you for taking time to post.
Re: saving substack
Posted: Thu Feb 17, 2011 12:33 am
by reelstuff
@Bernd I see so a substack is subject to the same compilation engine requirements as the main stack, OK that explains a lot. thanks
Re: saving substack
Posted: Thu Feb 17, 2011 2:38 am
by FourthWorld
reelstuff wrote:So while you cannot save a substack you can save a separate "stack" in a folder, or other such locations, interesting again thank you for taking time to post.
Glad that was helpful.
Here's another tip that can be useful: the "clone" command.
With it you can clone any stack and the copy exists only in memory. You can then set that stack's fileName property to any valid path, issue a save command, and you have a new stack file with all the parts of your original.
This can be helpful for some kinds of documents, where you can just make the document as a substack in your app's mainstack, and whenever you need a new document you just clone it; on File-Save As you set the filename of that cloned stack to the path you get back from "ask file", save it, and you're done.
That may be more than you needed right now, but I love using stacks for data storage and thought that some time down the road that might be something you may consider.
Re: saving substack
Posted: Thu Feb 17, 2011 3:06 am
by reelstuff
Yes, actually, that is extremely helpful, thank you, I did not know that you could clone a stack, I can see a lot of uses for that.

Re: saving substack
Posted: Thu Feb 17, 2011 3:58 am
by jharris
I was wondering how that worked... Lots of helpful info for a new user like me.
JHarris