Simple example of start using stack
Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller
Simple example of start using stack
New to live code and trying to create a library stack for use with Sqlite.
Have found some information by searching for:livecode library script stack example on the internet.
so if I have:
start using "myLib.livecode"
How do I find if the stack loaded?
What is the proper syntax to call a function in "myLib.livecode" from another stack?
Thanks in advance for your help.
Have found some information by searching for:livecode library script stack example on the internet.
so if I have:
start using "myLib.livecode"
How do I find if the stack loaded?
What is the proper syntax to call a function in "myLib.livecode" from another stack?
Thanks in advance for your help.
Re: Simple example of start using stack
You could look in the openStacks. Put a button on your main stack, and in mouseUp put -
Code: Select all
on mouseUp
answer the openStacks
end mouseUp
http://livecode.byu.edu/messages/libraries.php
Your question is pretty literally the answer. Look up call in the dictionary.What is the proper syntax to call a function in "myLib.livecode" from another stack?
-
- VIP Livecode Opensource Backer
- Posts: 2718
- Joined: Sat Dec 22, 2007 5:35 pm
- Location: Genève
- Contact:
Re: Simple example of start using stack
Hi dntknwjck,
If I believe LC dictionary (no tested)
Best regards
Jean-Marc
If I believe LC dictionary (no tested)
You may call your function by its nameThe start using command places a stack's script into the message path after the current stack and before any objects in the backScripts.
Code: Select all
put myFunction(something) into tVar
Jean-Marc
https://alternatic.ch
Re: Simple example of start using stack
A slight correction
should bestart using "myLib.livecode"
Code: Select all
start using stack "myLib.livecode"
Re: Simple example of start using stack
Thanks to all. I now have a working script file.
-
- Livecode Staff Member
- Posts: 818
- Joined: Fri Feb 06, 2015 4:03 pm
Re: Simple example of start using stack
Hello all,
See also the "libraryStack" message in the Dictionary.
Kind regards,
Panos
--
See also the "libraryStack" message in the Dictionary.
Kind regards,
Panos
--
Re: Simple example of start using stack
Thanks Panos, I had forgot to mention that with the BYU link
Re: Simple example of start using stack
Here is a simple example of script stack
in the resource folder put this as file testing.livecodescript
script "testing"
command doSomething
answer "The command doSomething in test.livecodescript has executed"
end doSomething
put his in a button's mouseup event:
on mouseUp
--resources is /home/user on Linux
start using stack (SpecialFolderPath("resources") & "/testing.livecodescript")
doSomething
end mouseup
Tested this on Linux Mint 18.3 and it was successful
in the resource folder put this as file testing.livecodescript
script "testing"
command doSomething
answer "The command doSomething in test.livecodescript has executed"
end doSomething
put his in a button's mouseup event:
on mouseUp
--resources is /home/user on Linux
start using stack (SpecialFolderPath("resources") & "/testing.livecodescript")
doSomething
end mouseup
Tested this on Linux Mint 18.3 and it was successful
Re: Simple example of start using stack
To be precise in the IDE -> SpecialFolderPath("resources")
points to the folder in which the current stack resides, the one that executes the script.
In a standalone to the folder where you added all of your resources via the "Copy files" tab in then "Standalone Application Settings".
This way we can use this SpecialFolderPath as well in the IDE as in a standalone, works on ANY platform!
Re: Simple example of start using stack
Unless the user has made changes (on linux, anyway, not sure about win and mac). There was a thread recently that highlighted just such an issue, where the user changed their 'Documents' folder (linux) to just plain "docs", which specialFolderPath failed to notice.
Note - I don't think this applies to, in this case, ("resources"), but I am still a big fan of building the path manually.
Ah yes, this was the thread I was thinking of: https://forums.livecode.com/viewtopic.p ... ilit=linux
Re: Simple example of start using stack
Hi Bogs,
yes, I remember that thread, but not using Linux, I did not pay much attention to it.
Best
Klaus
yes, I remember that thread, but not using Linux, I did not pay much attention to it.
Exactly, this is a special case, I think.
Yep, I bet you HAVE TO, as a Linux user!
Best
Klaus
Re: Simple example of start using stack
Agreed
Actually, that preference goes back to VS5 on Win, I've seen no reason to change it in all these years
The formula I go with is usually the appPath, which I make sure all sub folders are contained within, although if I ever start writing stuff for Mac again, I suppose I'll have to change that up a bit
Re: Simple example of start using stack
Yes, sure. On a Mac these specialfolderpaths are extremely handy, especially regarding the "unusual" folder hierachy of a Mac standalone. And Mac users ususally do not mess (e.g. rename) with the system folders like "Documents". Ok, some do, but then they are usually erm... licked!
Re: Simple example of start using stack
To be precise in the IDE -> SpecialFolderPath("resources")
points to the folder in which the current stack resides, the one that executes the script.
In a standalone to the folder where you added all of your resources via the "Copy files" tab in then "Standalone Application Settings".
This way we can use this SpecialFolderPath as well in the IDE as in a standalone, works on ANY platform!
[/quote]
Went back and looked at this:
SpecialFolderPath("resources") points to the folder the current stack is
I had used SpecialFolderPath("/resources") which points to my home directory
Don't know is that is the same for Linux or just my configuration.
points to the folder in which the current stack resides, the one that executes the script.
In a standalone to the folder where you added all of your resources via the "Copy files" tab in then "Standalone Application Settings".
This way we can use this SpecialFolderPath as well in the IDE as in a standalone, works on ANY platform!
[/quote]
Went back and looked at this:
SpecialFolderPath("resources") points to the folder the current stack is
I had used SpecialFolderPath("/resources") which points to my home directory
Don't know is that is the same for Linux or just my configuration.