Strategy for start using stack?
Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller, robinmiller
-
- VIP Livecode Opensource Backer
- Posts: 7215
- Joined: Sat Apr 08, 2006 8:31 pm
- Location: Minneapolis MN
- Contact:
Re: Strategy for start using stack?
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.
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
HyperActive Software | http://www.hyperactivesw.com
Re: Strategy for start using stack?
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.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?
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
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
François
Re: Strategy for start using stack?
Just dropped that stack in RevOnline, named SpecialFolderPath.
--
François
François
-
- VIP Livecode Opensource Backer
- Posts: 7215
- Joined: Sat Apr 08, 2006 8:31 pm
- Location: Minneapolis MN
- Contact:
Re: Strategy for start using stack?
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.
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
HyperActive Software | http://www.hyperactivesw.com
Re: Strategy for start using stack?
After experimenting:
- 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.
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
I wonder what the "Stacks" thumbnail is for...
Thanks to all who helped me!
Note that the preferences of Livecode consider adding ".livecode" to the file name as an option. Also:1. Use filenames with the correct file extension.
- 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.
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.2. Place them in the same folder with your mainstack.
I agree.3. In scripts use "start using stack (specialFolderPath("resources') & "/myfile.livecode") -- or "livecodescript"
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
Thanks to all who helped me!
--
François
François
-
- VIP Livecode Opensource Backer
- Posts: 2718
- Joined: Sat Dec 22, 2007 5:35 pm
- Location: Genève
- Contact:
Re: Strategy for start using stack?
Hi François,
Thanks
Jean-Marc
Thanks
That is strange for me. I read "non stack files in the application" in the "Copy Files" thumbnail (LC 7.06)- put the script stacks in the "Copy Files" thumbnail of the "Standalone Application Settings", not in the "Stacks" thumbnail
Jean-Marc
https://alternatic.ch
Re: Strategy for start using stack?
Hi Jean-Marc,
Sorry, I forgot to mention I use 8.0.1
Sorry, I forgot to mention I use 8.0.1
--
François
François
Re: Strategy for start using stack?
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
François
-
- VIP Livecode Opensource Backer
- Posts: 7215
- Joined: Sat Apr 08, 2006 8:31 pm
- Location: Minneapolis MN
- Contact:
Re: Strategy for start using stack?
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.
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
HyperActive Software | http://www.hyperactivesw.com