Strategy for start using stack?

Getting into LiveCode for iOS? Ask your questions here.

Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller, robinmiller

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 » Mon Aug 01, 2016 10:01 pm

Do as Jean-Marc suggests and view the package contents of the standalone. Tell us where you find the stack stScripts000.livecode.If the answer dialog doesn't work and the stScripts000.livecode stack isn't in the app package, then the standalone was not built correctly.

I'm confused whether your script is an actual stackfile or a script-only text-based script. Script-only stacks were not officially introduced until LC 8, so they may not build correctly in LC 7.

If your script is in an actual stackfile, try building with LC 7.1.4. Then look inside the app package and see if your stack is in Resources.
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 » Tue Aug 02, 2016 5:12 pm

I wanted to know where I should place my old-fashioned scripts stacks (non-text format, anyway that's supposed to be irrelevant) for "start using" to find them, on desktop standalone and on mobiles.

I wrote a stack to explore the name and contents of each SpecialFolderPath folder. I can't seem to attach the stack, the stack script code is here.

Code: Select all

on preOpenStack
   put "This stack explores the 'specialFolderPaths' and their contents in different environments." & return & return &  \
         "Run it in the IDE, in standalone, in simulator and in mobile environments." & return & return &  \
   "Click to run." into fld "texte"
end preOpenStack

on mouseUp
   put  \  
         "home : The (unique) folder containing the application bundle and its associated data and folders", \
         "documents : The current user's documents folder", \
         "library : The folder in which to store data of various types (backed up by iTunes on sync)", \
         "cache : The folder where transient data that needs to be preserved between launches should be stored (not backed up by iTunes)", \
         "temporary : The folder where temporary files can be placed", \
         "engine : The folder containing the LiveCode engine and the executable files copied in the standalone application", \
         "resources : Same as engine",  \
         "desktop : The current user's desktop folder", \
         "preferences : The current user's preferences folder", \
         "support : The current user's application-specific data folder", \
         "start : The folder that contains Start Menu items", \
         "system : The System Folder (usually /System)", \
         "fonts : The folder that contains fonts" \
         into theSpecialFolders
   put "the ticks=" & the ticks & return into fld "texte"
   put "the environment=" & the environment & return & return after fld "texte"
   repeat for each item theFolder in theSpecialFolders
      put theFolder & return after fld "texte"
      set the textStyle of line -1 of fld "texte" to bold
      get specialFolderPath(word 1 of theFolder)
      if the result is "folder not found" then
         put "doesn't exist" & return after fld "texte" 
         set the textStyle of line -1 of fld "texte" to italic
      else
         set the defaultFolder to specialFolderPath(word 1 of theFolder)
         put the defaultFolder & return after fld "texte"
         set the textStyle of line -1 of fld "texte" to italic
         put "Sub-folder(s):" & return after fld "texte"
         set the textStyle of line -1 of fld "texte" to bold
         put the folders & return after fld "texte" 
         put "File(s):" & return after fld "texte"
         set the textStyle of line -1 of fld "texte" to bold
         put the files & return after fld "texte" 
      end if
      put return after fld "texte"
   end repeat
end mouseUp
I added a script-stack in the "Stacks" thumbnail of the "Standalone Application Settings", and 2 documents in the "Copy Files" thumbnail of the "Standalone Application Settings".

In case someone is interested, I found the following, which was not clear for me in the doc.

Mac standalone:
- the script-stack in the "Stacks" thumbnail was copied in the "engine" special folder; its name had originally no extension but it ended up in the standalone with a ".rev" extension
- the dictionary says that the "resources" special folder is the same as the "engine" special folder; actually they are not quite the same: "engine" contains both the main stack and the script-stack, while "resources" contains only the script-stack
- the files in the "Copy Files" thumbnail of the "Standalone Application Settings" were copied both in the "engine" and in the "resources" special folder";

Mac simulator 9.3:
- The stack I had added in the "Stacks" thumbnail of the "Standalone Application Settings" doesn't appear on the simulator; that thumbnail is dimmed anyway when the target environment is set to "iOS"; I don't know why; this suggests that's NOT the way to add script-stacks to a main stack
- the files from the "Copy Files" thumbnail were copied both in the "engine" and in the "resources" special folder"

iOS 7.1.2:
same as the simulator

Apparently the proper way to start using a script stack on a mobile is NOT to use "start using". Can anyone help on that?
--
François

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

Re: Strategy for start using stack?

Post by Fjord » Tue Aug 02, 2016 5:35 pm

Just dropped that stack in RevOnline, named SpecialFolderPath.
--
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 Aug 02, 2016 7:15 pm

Please physically look into the app package to determine where the files are located. To understand why this is necessary, you need some historical information.

In older versions of LC, all resource files were placed into the same folder in the standalone next to the mainstack (the "engine" folder.) Recently Apple changed the rules for Mac and iOS apps -- nothing is allowed in the engine folder except the actual executable file. All other supporting files must be placed in a Resources folder.

To accomodate backward compatibility with scripts that refer to specialFolderPath("engine"), LC accepts the "engine" file path but will internally re-direct it to Resources. Thus, if you script specialFolderPath("engine") you will actually be getting files from Resources.

To determine where the files really are physically, you have to look yourself in Finder. It isn't hard to do and will take you much less time than writing a script. Right-click on the app, choose "Show package contents", and you will see the internal file hierarchy. Look in both the MacOS folder and the Resources folder.

It is significant that your files had no extension. If you are using a text-based script-only stack, the file name should end with ".livecodescript" and regular stacks should end with ".livecode" or ".rev". It is possible that without an extension, the files won't be copied at all, or will be copied to the wrong place.

Putting a stack in use is usually a very simple process:

1. Use filenames with the correct file extension.
2. Place them in the same folder with your mainstack.
3. In scripts use "start using stack (specialFolderPath("resources') & "/myfile.livecode") -- or "livecodescript"

When building a standalone, add the stacks to the stacks pane. I haven't built a standalone with a script-only stack but it should work; if it doesn't, try adding those to the Copy Files pane instead. Apparently iOS requires that.
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 » Wed Aug 03, 2016 8:17 pm

After experimenting:
1. Use filenames with the correct file extension.
Note that the preferences of Livecode consider adding ".livecode" to the file name as an option. Also:
- when building a desktop standalone, the extension ".rev" is added to stacks mentioned in the "Stacks" thumbnail that do not have an extension;
- when building a mobile app, no extension is appended.
- OTOH if the stack is in the "Copy Files", no extension is ever appended;
The "start using" instruction should take this into account.
2. Place them in the same folder with your mainstack.
I'd rather not do this: I've written many utility, multi-purpose, handlers and do not want to dedicate them to a single project. I'd rather they stay in a separate subfolder of my "Development" folder. That works just fine.
3. In scripts use "start using stack (specialFolderPath("resources') & "/myfile.livecode") -- or "livecodescript"
I agree.

Therefore a simple strategy to build apps for desktop and mobile seems to be:
- name the stacks with or without extension
- put the script stacks in the "Copy Files" thumbnail of the "Standalone Application Settings", not in the "Stacks" thumbnail
- access the script stack with something like

Code: Select all

   switch the environment
      case "development"
         start using stack "/Users/FT/Desktop/Achat/myScriptStack"
         break
      case "standalone application" -- The stack is running as a standalone application.
      case "mobile" -- The stack is running on a mobile device.
         start using specialFolderPath("resources") & "/myScriptStack"
         break
   end switch
I wonder what the "Stacks" thumbnail is for...
Thanks to all who helped me!
--
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 » Thu Aug 04, 2016 8:16 am

Hi François,
Thanks
- put the script stacks in the "Copy Files" thumbnail of the "Standalone Application Settings", not in the "Stacks" thumbnail
That is strange for me. I read "non stack files in the application" in the "Copy Files" thumbnail (LC 7.06)
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 » Thu Aug 04, 2016 1:40 pm

Hi Jean-Marc,
Sorry, I forgot to mention I use 8.0.1
--
François

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

Re: Strategy for start using stack?

Post by Fjord » Thu Aug 04, 2016 2:50 pm

Just now I found (while looking for something different…) the property "stackFiles" in the documentation, which explains the use of the "stacks" thumbnail of the Standalone Settings.
--
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 Aug 09, 2016 4:42 pm

The reason I suggested putting utility stacks in the same folder with the main stack is for ease of development. It isn't required. But if the files are structured that way, the engine is smart enough to look there for the stacks during development and to look in a resources folder in a standalone. That means the same file path works anywhere.

The stackfiles is an alternate solution, but limited to only stacks. Other types of files or folders need file paths in scripts so it's convenient to use the suggested file structure.
Jacqueline Landman Gay | jacque at hyperactivesw dot com
HyperActive Software | http://www.hyperactivesw.com

Post Reply

Return to “iOS Deployment”