How does build a stand alone actually work

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

Post Reply
standgale
Posts: 26
Joined: Fri May 07, 2021 4:12 am

How does build a stand alone actually work

Post by standgale » Fri Jan 28, 2022 3:55 am

Hi,
I am wondering how building a stand alone actually works. Is there any information on this?
I find that my application works completely differently after trying to build a stand alone.

e.g. I open up my live code project. Test it. It works perfectly. I try to build a stand alone. That fails because it just does 90% of the time for no apparent reason, either because it can't find a function it could find perfectly well 10 seconds ago or because it gets stuck in an infinite loop of dialog boxes. If I try to use the project again in livecode it now doesn't work, because it can't find its own cards, for instance - but its not the same thing that caused the stand alone build to fail.

What is actually HAPPENING when it builds? I feel if I had some more information I'd have at least a little bit of a chance of getting it to work.

Edit: I should say that all of these problems come from my having multiple stacks, so I feel like something is happening due to loading/unloading/linking... something...

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

Re: How does build a stand alone actually work

Post by dunbarx » Fri Jan 28, 2022 3:05 pm

I build successive versions of a group of stacks. This consists of a certain stack entered in the "Stacks" pane of the "Standalone Application Settings" pane which will become the executable. Then I add another stack file, the stack of which has a half dozen substacks.

The standalone comes out as a bundle for Mac. For Windows, an executable, that other stack and a couple of Windows library files.

But I have never, in over 500 updates ever had the standalone work differently than the IDE stack itself, which I develop on a Mac. There are some differences, though, but they are Windows vs. Mac differences, such as which choice in an "Answer" dialog is the default.

Craig

jacque
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 7210
Joined: Sat Apr 08, 2006 8:31 pm
Location: Minneapolis MN
Contact:

Re: How does build a stand alone actually work

Post by jacque » Fri Jan 28, 2022 10:10 pm

The infinite dialog loop was supposed to be fixed in LC 9.6.6 so you might want to try that version. I've never had it happen but others have reported it.

What happens behind the scenes is something of a mystery, but various dictionary entries say that LC closes the stack temporarily, reloads it from disk, and does whatever it does to do the build. After that, it re-opens your stack in the condition it was before. I think if you don't save the stack before building, your standalone will reflect the copy on disk rather than the one you've been working on in memory.

If LC can't find some of the things it needs -- in this case, those may be your script-only stacks -- then it will be unable to continue. See my post about including extra stacks here: viewtopic.php?f=7&t=36699&p=212463#p212463
Jacqueline Landman Gay | jacque at hyperactivesw dot com
HyperActive Software | http://www.hyperactivesw.com

stam
Posts: 2599
Joined: Sun Jun 04, 2006 9:39 pm
Location: London, UK

Re: How does build a stand alone actually work

Post by stam » Sun Jan 30, 2022 4:42 pm

standgale wrote:
Fri Jan 28, 2022 3:55 am
e.g. I open up my live code project. Test it. It works perfectly. I try to build a stand alone. That fails because it just does 90% of the time for no apparent reason, either because it can't find a function it could find perfectly well 10 seconds ago
A common cause of this is relying on inclusions being detected automatically. Very early on i realised this didn't work well and i *always* select inclusions manually. If you are not doing this, i'd suggest starting with this as the likely culprit...

If you're relying on other libraries make sure you can access them in your app (first of all they are copied into the bundle or app directory and second of all that you can actually load these) - you may want to for example pop a message box to confirm library loaded and working in the app.

Hope that helps,
Stam

standgale
Posts: 26
Joined: Fri May 07, 2021 4:12 am

Re: How does build a stand alone actually work

Post by standgale » Fri Feb 04, 2022 2:40 am

thanks for all the answers.

So its not the standalone that is working differently from in the IDE, but the build process. It seems that when it builds the standalone, it runs the code? But it seems to run each file or stack separately rather than connecting them up properly. Like, it runs the behaviour script on its own, instead of AS a behaviour.
For example, when I just added an the line "answer the long name of me" then the message box pops up when I try to build the standalone which seems weird in itself. But importantly the answer is different from what I get when I run the program in the IDE. The build doesn't work, it has an error, because "me" is not what it should be (its the behaviour stack instead of the stack which the script is a behaviour of).

standgale
Posts: 26
Joined: Fri May 07, 2021 4:12 am

Re: How does build a stand alone actually work

Post by standgale » Fri Feb 04, 2022 4:38 am

I thought I had solved something, but it turns out I haven't.

Firstly, I have the scripts in the Copy Files section of the Standalone Application settings.
copy files.PNG
And I have them listed in the stack files of the main stack, in the property inspector.
stack files.PNG
But they also show up in here, in the Stacks tab of the Standalone Application settings.
stacks.PNG
Maybe that's the problem, I thought. That's why its building all those stacks separately when I try to build the Standalone - because they're listed as stacks. So I removed them. And the whole thing built finally, with no errors! :D But when I run the standalone, it can't access any of the behaviours :(

Back in the IDE, I see that the files are no longer listed in the stack files of the main stack. So I add them back in, and they reappear in the Stacks tab of the standalone application settings. I delete them from one and they delete from the other. These seem to be different ways of getting to the same thing.

jacque
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 7210
Joined: Sat Apr 08, 2006 8:31 pm
Location: Minneapolis MN
Contact:

Re: How does build a stand alone actually work

Post by jacque » Fri Feb 04, 2022 8:49 am

The stackfiles are used during runtime so that the scripts can find them. The stacks pane in the standalone builder is required so that they will be included in the app. Apparently LC adds them to the standalone builder so you don't need to remember. The builder is a separate process from your app scripts.

I think your build errors may be due to a change in LC 9 where messages are not locked when the build happens. I think it's an unfortunate change because it means all your scripts will run if they contain any (pre)open* handlers. The mixed order you're seeing isn't important, it's just the order the standalone builder is accessing the stacks. But it does explain why you're getting unusual errors.

To avoid this you need to put a check into every (pre)open* and close* handler (preopencard, opencard, openstack, preOpenStack, closeStack, closeCard, etc.) and exit the handler if the builder is running.

Here's the explanation and example code:
https://www.mail-archive.com/use-liveco ... 98034.html

Some people just lock the messages from LC's toolbar before building, but they don't recommend that.
Jacqueline Landman Gay | jacque at hyperactivesw dot com
HyperActive Software | http://www.hyperactivesw.com

stam
Posts: 2599
Joined: Sun Jun 04, 2006 9:39 pm
Location: London, UK

Re: How does build a stand alone actually work

Post by stam » Fri Feb 04, 2022 8:53 am

I always build with messages suppressed to avoid issues with preOpen*
Might that help?
Stam

Post Reply

Return to “Getting Started with LiveCode - Complete Beginners”