How to create stand alone application/use own script library
Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller
How to create stand alone application/use own script library
Kia ora,
Using livecode Indy 9.6 (rc 1) on Windows
I'm trying to create an application using some script-only stacks and a library, but I'm having various problems.
1. It often tells me I have a stack already open and is not happy with my choice of any of the 3 options in the dialog
2. I can't make a stand-alone application - I get an error but it doesn't actually seem to say what the error is.
I couldn't find very much information on how to actually implement script-only stacks and libraries so that part is probably a bit mucked up.
The library:
a file called loggingLib.livecode
in its own stack called loggingLib
I'm not sure how to actually load it as I saw lots of conflicting information about this, so I went with putting the following in preOpenStack in one of the cards in one of the script-only stacks
start using stack (specialFolderPath("resources") & "\libraries\loggingLib.livecode")
The script-only stacks:
one for the stack, and one for each of the two cards.
These are .livecodescript files.
Each of the stacks have empty cards in them when I look in the project browser which don't go away even if I delete them
The script-only stacks are linked to the application via behaviours which I set up using the Property Inspector
All of this works, except for when it decides to complain that a stack is already open, which it seems to do at random e.g. sometimes when I try to view the stack script or run the application it will complain the stack is already open and other times it will not.
In terms of trying to make a stand alone application - it did not add my library script automatically, and then when I tried to add it it complained it was already open. However it still added it to the list of stack files.
When I choose to make the standalone, it first asks if I want to save all my changes before closing - don't know why it needs to ask that.
Then it says "A stack with the same name as the one you are trying to load is already open" (library stack)
If I choose purge, it says the same thing.
If I choose save, it says it can't save it because it can't open it.
It then says the same thing again. I choose purge again for fun.
Then it says there was an error while saving the standalone application. It doesn't really say what the error is. I cannot select the text to copy it, but it starts like this:
219,3,8,getDataFilePath
465,3,8
241,3,1,preOpenCard
353,0,0,stack
and continues on.
Any ideas, or specific instructions on how to actually add and use the library file as that seems to be the main problem and might fix it.
Using livecode Indy 9.6 (rc 1) on Windows
I'm trying to create an application using some script-only stacks and a library, but I'm having various problems.
1. It often tells me I have a stack already open and is not happy with my choice of any of the 3 options in the dialog
2. I can't make a stand-alone application - I get an error but it doesn't actually seem to say what the error is.
I couldn't find very much information on how to actually implement script-only stacks and libraries so that part is probably a bit mucked up.
The library:
a file called loggingLib.livecode
in its own stack called loggingLib
I'm not sure how to actually load it as I saw lots of conflicting information about this, so I went with putting the following in preOpenStack in one of the cards in one of the script-only stacks
start using stack (specialFolderPath("resources") & "\libraries\loggingLib.livecode")
The script-only stacks:
one for the stack, and one for each of the two cards.
These are .livecodescript files.
Each of the stacks have empty cards in them when I look in the project browser which don't go away even if I delete them
The script-only stacks are linked to the application via behaviours which I set up using the Property Inspector
All of this works, except for when it decides to complain that a stack is already open, which it seems to do at random e.g. sometimes when I try to view the stack script or run the application it will complain the stack is already open and other times it will not.
In terms of trying to make a stand alone application - it did not add my library script automatically, and then when I tried to add it it complained it was already open. However it still added it to the list of stack files.
When I choose to make the standalone, it first asks if I want to save all my changes before closing - don't know why it needs to ask that.
Then it says "A stack with the same name as the one you are trying to load is already open" (library stack)
If I choose purge, it says the same thing.
If I choose save, it says it can't save it because it can't open it.
It then says the same thing again. I choose purge again for fun.
Then it says there was an error while saving the standalone application. It doesn't really say what the error is. I cannot select the text to copy it, but it starts like this:
219,3,8,getDataFilePath
465,3,8
241,3,1,preOpenCard
353,0,0,stack
and continues on.
Any ideas, or specific instructions on how to actually add and use the library file as that seems to be the main problem and might fix it.
Re: How to create stand alone application/use own script library
Apparently its not the library that is the problem because I copied all that code into the stack behaviour script and it didn't help.
Going through and gradually commenting out all the stuff it mentions in the error message, it seems to be the stuff where the stack-only scripts refer to handlers in each other. Even though they all work when running the application in the IDE, they can't seem to connect up when it creates the stand alone application.
Going through and gradually commenting out all the stuff it mentions in the error message, it seems to be the stuff where the stack-only scripts refer to handlers in each other. Even though they all work when running the application in the IDE, they can't seem to connect up when it creates the stand alone application.
Re: How to create stand alone application/use own script library
Code: Select all
start using stack (specialFolderPath("resources") & "\libraries\loggingLib.livecode")
Code: Select all
open stack (specialFolderPath("resources") & "\libraries\loggingLib.livecode")
start using stack (specialFolderPath("resources") & "\libraries\loggingLib.livecode")
Do you have globals for variables at the top of your script?
Re: How to create stand alone application/use own script library
I just used "start using ..." based on what I found on this page https://livecode.byu.edu/messages/libraries.phpxAction wrote: ↑Thu Oct 21, 2021 9:46 amDid you try that?Code: Select all
start using stack (specialFolderPath("resources") & "\libraries\loggingLib.livecode")
Code: Select all
open stack (specialFolderPath("resources") & "\libraries\loggingLib.livecode") start using stack (specialFolderPath("resources") & "\libraries\loggingLib.livecode")
Everything is in the stack-only scripts (or the library), so yes.The main scripts, the handlers its screaming about are in the stack scripts?
No globals.Do you have globals for variables at the top of your script?
Re: How to create stand alone application/use own script library
So, if I put the script-only stacks that are used as behaviours in the Files rather than in Stacks in the Standalone Application settings then it builds.
However, when I run the exe it can't find any of the handlers that are in the behaviours.
Since it is a behaviour, I didn't think you would need to "start using" (also I don't need to do that when running in the IDE, it just sorts it out).
I tried using the following in preOpenStack of my main stack - i.e. loading the behaviour script in code rather than in the property inspector.
If I use the same type of code to manually add behaviours for the cards as well, then it does a bunch of weird stuff - popping up windows and producing errors. Also, I don't know why the behaviours aren't being found and used when added through the user interface via the property inspector.
So basically the problem seems to be: it is not loading/using the script files that are added as behaviours via the property inspector.
However, when I run the exe it can't find any of the handlers that are in the behaviours.
Since it is a behaviour, I didn't think you would need to "start using" (also I don't need to do that when running in the IDE, it just sorts it out).
I tried using the following in preOpenStack of my main stack - i.e. loading the behaviour script in code rather than in the property inspector.
This sort of worked - it mean I could build and start the standalone, but the program wasn't working properly - I think it wasn't loading the behaviors of the cards. Before, when I just set the behaviour of the stack & cards using the property inspector, it loaded all the extra stacks into the livecode IDE. Now, by setting this behaviour by code, it loads only that behaviour stack and not the ones for the cards.local tB
put specialFolderPath("resources") & "/behaviours/DEMS-Strider Stack Behavior.livecodescript" into tB
set the behaviour of me to the long ID of stack tB
start using stack tB
If I use the same type of code to manually add behaviours for the cards as well, then it does a bunch of weird stuff - popping up windows and producing errors. Also, I don't know why the behaviours aren't being found and used when added through the user interface via the property inspector.
So basically the problem seems to be: it is not loading/using the script files that are added as behaviours via the property inspector.
-
- VIP Livecode Opensource Backer
- Posts: 7228
- Joined: Sat Apr 08, 2006 8:31 pm
- Location: Minneapolis MN
- Contact:
Re: How to create stand alone application/use own script library
Set up the behaviors in the property inspectors as usual. Then add all the script stacks to the stackfiles, and include them in the Copy Files pane of the standalone settings. That should be all you need to do. LC looks at the stackfiles when it sees a stack reference.
Jacqueline Landman Gay | jacque at hyperactivesw dot com
HyperActive Software | http://www.hyperactivesw.com
HyperActive Software | http://www.hyperactivesw.com
Re: How to create stand alone application/use own script library
What do you mean by "add all the script stacks to the stackfiles"? Do you mean in the Standalone Application Settings "Stacks" tab? I've tried that but still getting the same errors as I got at the start i.e. if the script stacks are added in the stack tabs then it will not build the Standalone Application.jacque wrote: ↑Thu Oct 28, 2021 5:48 pmSet up the behaviors in the property inspectors as usual. Then add all the script stacks to the stackfiles, and include them in the Copy Files pane of the standalone settings. That should be all you need to do. LC looks at the stackfiles when it sees a stack reference.
Based on the error messages, it looks like when it makes the standalone then the script can't find the objects on the card.
When its in the IDE I sometimes get errors now too, and it looks like the objects can't find the stack script.
-
- VIP Livecode Opensource Backer
- Posts: 7228
- Joined: Sat Apr 08, 2006 8:31 pm
- Location: Minneapolis MN
- Contact:
Re: How to create stand alone application/use own script library
The procedure is like this:
Naturally you'll substitute "MyStack" with the real names of the stacks. When LC looks for a stack with the name "myStack" it will search the stackfiles if it can't find it in the substacks. This ensures the stacks can be found, even if you only refer to them by their short names. In your scripts you will also need to start using each file, like this:
That should be all you need to do.
- Put all the script-only stacks into a folder, which I think you're naming "behaviours." Put the behaviours folder into the same folder with the mainstack.
- Open the Standalone Settings for the mainstack and go to the Copy Files pane. Add the behaviours folder there. (Don't add each file, just add the whole folder.)
- Open the property inspector for the mainstack and go to the stackfiles pane (second icon at the top.) Here you list each script-only file individually. The first column is the short name of the stack. The second column is the path to that stack, starting from the behaviours folder. Each line looks like this:
Code: Select all
myStack /behaviours/myStack.livecodescript
Code: Select all
start using stack "myStack"
Jacqueline Landman Gay | jacque at hyperactivesw dot com
HyperActive Software | http://www.hyperactivesw.com
HyperActive Software | http://www.hyperactivesw.com
Re: How to create stand alone application/use own script library
Yep exactly what Jacque says...
I have a number of libraries and stacks loading with one of my apps.
Early in the app startup process i check for the presence of the stack files and if exist then i start using the stack as Jacque shows above (location can be anywhere).
If you need the stacks to be editable you probably want to put these into a writeable location as often the 'apps' folder isn't (i have mine in the user's Documents folder usually) - if the files don't exist, i copy across a copy from a copy in the app folder/bundle (keep in mind however that commands such as revCopyFile will fail if called too early as they rely on the 'common library' which gets loaded fairly late in the app startup process.
S.
I have a number of libraries and stacks loading with one of my apps.
Early in the app startup process i check for the presence of the stack files and if exist then i start using the stack as Jacque shows above (location can be anywhere).
If you need the stacks to be editable you probably want to put these into a writeable location as often the 'apps' folder isn't (i have mine in the user's Documents folder usually) - if the files don't exist, i copy across a copy from a copy in the app folder/bundle (keep in mind however that commands such as revCopyFile will fail if called too early as they rely on the 'common library' which gets loaded fairly late in the app startup process.
S.