Strategy for start using stack?

Getting into LiveCode for iOS? Ask your questions here.

Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller, robinmiller

Fjord
Posts: 132
Joined: Sat Dec 06, 2008 6:18 pm
Location: France

Strategy for start using stack?

Post by Fjord » Fri Jul 22, 2016 8:56 am

Hi,
I have a few script-only stacks which I've built for years.

I use "start using stack absolutePath/ScriptStack0" in the preOpen handler of my main stack.
The "libraryStack" handler of "ScriptStack0" in turn starts using some more script stacks, like ScriptStack1, ScriptStack2 etc.
Fine.

Now, what's the best strategy to achieve the same result on the iPhone simulator or on the iPhone?
--
François

Fjord
Posts: 132
Joined: Sat Dec 06, 2008 6:18 pm
Location: France

Re: Strategy for start using stack?

Post by Fjord » Mon Jul 25, 2016 9:50 am

No answer after a few days... maybe I should have been more precise:

- the 1st & 2nd paragraphs of my post describe the strategy I use to develop desktop apps on Mac: the scripts-only stacks are in folders, my main app just goes and find them (based on a few pathnames) to "start using" them;

- I can't drop the scripts stacks in folder of the mobile (is that right?); therefore my main app can't go find them at runtime...

So, can someone describe a strategy for handling a main stack (the app) that uses several scripts-only stacks?

Thanks for the help!
--
François

jmburnod
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 2718
Joined: Sat Dec 22, 2007 5:35 pm
Location: Genève
Contact:

Re: Strategy for start using stack?

Post by jmburnod » Mon Jul 25, 2016 10:40 am

Hi François,
If I understand you correctly, your stack "ScriptStack0" store scripts only and will not change.
If this is the case I think you can add stack "ScriptStack0" to stack files app in standalone application setting.
Can someone confirm this ?
Best regards
Jean-Marc
https://alternatic.ch

Fjord
Posts: 132
Joined: Sat Dec 06, 2008 6:18 pm
Location: France

Re: Strategy for start using stack?

Post by Fjord » Mon Jul 25, 2016 3:04 pm

(English version below)
Bonjour Jean-Marc (avec ce prénom, je suppose que tu lis le français :-)

1) sur le Mac dans l'outil de développement "Livecode Community Edition", j'écris ma pile "main.livecode". Dans un de ses scripts je fais "start using /Users/.../.../utilityScripts.livecode". Ensuite j'utilise des handlers définis dans "utilityScripts.livecode". Quand je fais tourner la pile principale tout va bien, le handler est appelé.
2) je fabrique le standalone, je le fais tourner sur mon Mac. Ca marche pareil. La pile utilityScripts est donc bien trouvée.
3) dans le "Standalone Settings" j'enregistre la pile "utilityScripts" dans la liste des stacks (2ème onglet); je re-fabrique le standalone, je le fais tourner sur mon Mac. Ca marche pareil mais ça ne veut rien dire
4) je déplace la pile /Users/.../.../utilityScripts.livecode; je refais tourner le même standalone; le handler n'est PAS appelé.

J'en conclus que dans le standalone, le "start using" va chercher la pile sur mon disque et que ça ne sert à rien de l'enregistrer dans les "Standalone Settings". Et que si je déplace le standalone sur un autre Mac ça ne marchera pas non plus. Tout ça me paraît assez logique.

Comment est-ce que j'organise la même chose pour avoir accès à "utilityScripts" dans un standalone, ou sur le simulateur ou l'iPhone? J'ai dû louper un truc!

(English version here)
1) on my Mac in the IDE "Livecode Community Edition", I write a stack "main.livecode". In one of the handlers I do "start using /Users/.../.../utilityScripts.livecode". Then I use the handlers defined in "utilityScripts". When I run the main stack, all's right, the handler is called correctly.
2) I build a standalone and run it the Mac. It works fine: the stack "utilityScripts" is found.
3) in "Standalone Settings" I add the stack "utilityScripts" in the list of stacks (2nd thumbnail); I re-build the standalone, run it on the Mac; it works the same but doesn't really mean anything
4) I move the stack /Users/.../.../utilityScripts.livecode to another folder; I run the very same standalone: the handler is NOT called.

I conclude from these experiments that "start using" finds the stack in real time on my disk and it's useless to add it in "Standalone Settings". And if I move my standalone to another Mac it won't run anymore. It makes sense.

How do I organize my script-stacks so that my main stack can run a handler in the standalone, on the simulator or on the iPhone? I must have missed something!
--
François

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

Re: Strategy for start using stack?

Post by jacque » Tue Jul 26, 2016 7:42 pm

LiveCode will use the hard-coded path you provided in the "start using" statement, which takes precedence over anything else. To make the engine use a relative path you should use one of the specialFolderPath variables which cause the engine to look in the correct location on each platform. In this case I think you want specialFolderPath("resources").

During development, place the utility stack in the same folder with all the other related stacks, including the one that becomes the standalone. That is where the "resources" reference will point. When a standalone is built, a "resources" folder will be created in the proper location and the stacks will be placed there.

Your file path should be: specialFolderPath("resources") & "/utilityScripts.livecode"
Jacqueline Landman Gay | jacque at hyperactivesw dot com
HyperActive Software | http://www.hyperactivesw.com

Fjord
Posts: 132
Joined: Sat Dec 06, 2008 6:18 pm
Location: France

Re: Strategy for start using stack?

Post by Fjord » Sun Jul 31, 2016 10:44 am

Thanks for your time and your answer. I experimented... and failed again.
I created 2 stacks:

1) "myScriptStack", stack script as follows:

Code: Select all

function myAdd x , y
   return x+y
end myAdd
2) "myMainStack", 1 card, 1 text field "t", no stack script, card script as follows:

Code: Select all

on preopenCard
   put empty into fld "t" -- just a simple text field
end preopenCard

on mouseUp
   put "the environment =" && the environment & return into fld "t"
   put "specialFolderPath('resources') =" && specialFolderPath("resources") & return after fld "t"
   switch the environment
      case "development"
         start using specialFolderPath("resources") & "/myScriptStack"
         break
      case "standalone application" -- The stack is running as a standalone application.
         start using specialFolderPath("resources") & "/myScriptStack"
         break
      case "mobile" -- The stack is running on a mobile device.
         start using specialFolderPath("resources") & "/myScriptStack"
         break
   end switch
   put the stacksinuse & return after fld "t"
   put "3 + 2 =" && myAdd(3,2) after fld "t" 
end mouseUp
I repeated the "start using" in each case just in case I wanted to write variants.

This works fine in the IDE, field "t" shows:

Code: Select all

the environment = development
specialFolderPath('resources') = /Users/FT/Desktop/TestStartUsing
myScriptStack
revSBLibrary
revSaveAsStandalone
3 + 2 = 5
Now I build a standalone, including both stacks: see attachment Capture.png
The standalone stops before the end of the program:

Code: Select all

the environment = standalone application
specialFolderPath('resources') = /Users/FT/Desktop/TestStartUsing1/TestStartUsing.app/Contents/Resources/_MacOS/
and doesn't go any further.

Frankly, a "how-to" would help. What am I missing? Any hints / help appreciated!
And this is just a desktop standalone, I want to be able to run this on the simulator then on a mobile...
Attachments
Capture.png
--
François

jmburnod
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 2718
Joined: Sat Dec 22, 2007 5:35 pm
Location: Genève
Contact:

Re: Strategy for start using stack?

Post by jmburnod » Sun Jul 31, 2016 5:07 pm

Hi François,
Yes, I speak french better than my terrible english, but english is better for community.
You can use private messages for french messages.

I tried this :
1. One main stack "TestScript001"
2. One main stack "TestScript000"
Both are in the stack files

TestScript001 stack script:

Code: Select all

on openstack
   start using stack "stScripts000" -- works without special file path
end openstack
script of btn "testMe" on cd 1 of stack "TestScript001"

Code: Select all

on mouseUp
   doMyTest
end mouseUp
TestScript000 stack script:

Code: Select all

on doMyTest
   answer "DoMYTest"
end doMyTest
IDE and standalone works for me (LC 7.06) also with copy to an other machine

I tested for iOS without success at this moment :D

BUT I can't modify stack file list even if I locked messages = true before openstack :shock:

Best regards
Jean-Marc
https://alternatic.ch

Fjord
Posts: 132
Joined: Sat Dec 06, 2008 6:18 pm
Location: France

Re: Strategy for start using stack?

Post by Fjord » Sun Jul 31, 2016 9:15 pm

Thanks for your help.
I tried to recreate your example with LC 7.0.6
With your code

Code: Select all

on openstack
   start using stack "stScripts000" -- works without special file path
end openstack
when I start the stack I get an error on the second line

Code: Select all

stack "stScripts001": execution error at line 2 (Chunk: can't find stack), char 1
although both stack are in the stacks section of the standalone settings and both stack files are in the same folder (Mac El Capitan).

If I write

Code: Select all

on openstack
   get specialFolderPath("resources") & "/stScripts000"
   start using stack it
end openstack
the start using works fine. I don't understand how your statement can work without the special folder path :shock:
--
François

Fjord
Posts: 132
Joined: Sat Dec 06, 2008 6:18 pm
Location: France

Re: Strategy for start using stack?

Post by Fjord » Sun Jul 31, 2016 9:18 pm

Now I notice that after the start using in the openStack, the stackInUse returns correctly: stScripts000.
But after I've built a standalone, the stacksInUse returns revSBLibrary; and stScripts000 is not in use anymore.
Is that normal / documented?
--
François

Fjord
Posts: 132
Joined: Sat Dec 06, 2008 6:18 pm
Location: France

Re: Strategy for start using stack?

Post by Fjord » Sun Jul 31, 2016 9:22 pm

And also: in stadalone, answer doesn't work, whether I choose to let Livecode choose the inclusions or I choose to check answer dialog. Seem to remember reading something about that some time ago but can't find it anymore.
--
François

jmburnod
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 2718
Joined: Sat Dec 22, 2007 5:35 pm
Location: Genève
Contact:

Re: Strategy for start using stack?

Post by jmburnod » Sun Jul 31, 2016 10:31 pm

I don't understand how your statement can work without the special folder path
Me too.
In package, stScripts000.livecode is in "Contents/Resources/_macOS/" folder
and stScripts001 file is in "Contents/MacOS" folder. :roll:

I tested it with yosemite 10.10.3

Jean-Marc
https://alternatic.ch

Fjord
Posts: 132
Joined: Sat Dec 06, 2008 6:18 pm
Location: France

Re: Strategy for start using stack?

Post by Fjord » Mon Aug 01, 2016 8:09 am

What do you call a "package"?
--
François

jmburnod
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 2718
Joined: Sat Dec 22, 2007 5:35 pm
Location: Genève
Contact:

Re: Strategy for start using stack?

Post by jmburnod » Mon Aug 01, 2016 8:26 am

What do you call a "package"?
What you discover when you choose "Afficher le contenu du paquet" after a right-clic on one standalone
Jean-Marc
https://alternatic.ch

Fjord
Posts: 132
Joined: Sat Dec 06, 2008 6:18 pm
Location: France

Re: Strategy for start using stack?

Post by Fjord » Mon Aug 01, 2016 5:30 pm

@Jean Marc: OK. On the other hand, I'm not trying to understand the internal structure of a standalone app. I'm just trying to find how to manage scripts stacks in standalone or iOS apps.

Apparently
1) that's not obvious
2) that's not really documented in a lesson
3) I haven't found an example

Am I mistaken?
I tried to follow the advice that Jacqueline explained above but it still doesn't work; maybe I misunderstood something.
Livecode 7.0.6 and 8.0.1, OS X 10.11.6 El Capitan.
--
François

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

Re: Strategy for start using stack?

Post by FourthWorld » Mon Aug 01, 2016 6:45 pm

Fjord wrote:I'm just trying to find how to manage scripts stacks in standalone or iOS apps.
A script-only stack is the same as any other stack except for the storage format. All methods of working with a script-only stack should be the same as with any other in terms of opening, closing, saving, etc. You can even add objects and custom properties in a script-only stack; just remember that the storage format is the one thing that's different, and will only save the stack script.
Richard Gaskin
LiveCode development, training, and consulting services: Fourth World Systems
LiveCode Group on Facebook
LiveCode Group on LinkedIn

Post Reply

Return to “iOS Deployment”