Page 1 of 1
Standalones and imported images
Posted: Thu Aug 19, 2010 8:00 am
by Echo
I'm on a Mac (OS 10.6.x) using Rev 2.8.1. I have a program with 120 images (.jpg between 100 & 400 KB). I would like to have those images reside in a folder along with the program file and then call them from within the program rather than preloading each of them in the program itself. I do this for a few reasons: 1) the program is getting bigger and that makes transporting it (e-mail or over a network) cumbersome and 2) I need to save the program as a standalone app, but when I do that then importing from an external folder doesn't seem to work--I get a gray box but no pict. That is another issue completely.
A. Can I import them in a standalone? I don't need them to remain in the program--each time a user uses the program they can be loaded again.
B. If I do preload them all and my program is 20 MB before I even add the standalone engine, will that affect its ability to perform? (In the old HyperCard days, if a stack got over 2 or 3 MB it would crash and get corrupted.)
Thanks in advance!
Re: Standalones and imported images
Posted: Thu Aug 19, 2010 10:52 am
by jmburnod
Hi Echo,
I'm so happy when i'm faster the anglophon users
The paths are not the same for a stack or a standalone
I use this script to create the paths of a subfolder "LeNecessaire" in the same folder of the standalone or the stack
Code: Select all
on FaitPathNec
global gPathNec
put the filename of this stack into bufPath
put bufPath into gPathNec
put the environment into pEnv
put the itemdel into OID
set the itemdel to "/"
put the num of items of gPathNec into nbF
if the platform = "MacOS" then
if pEnv = "standalone application" then
delete item (nbF-3) to nbf of gPathNec
end if
if pEnv = "development" then
delete last item of gPathNec
end if
else
delete last item of gPathNec
end if
set the itemdel to OID
put "/"&"LeNecessaire" after gPathNec
end FaitPathNec
I hope this help
Good luck
Jean-Marc
Re: Standalones and imported images
Posted: Thu Aug 19, 2010 11:02 am
by Dixie
Hi Echo...
After building a standalone, your mainstack is now inside the application bundle, several folders deep. If you want to keep your folder of pictures outside the application bundle after building a standalone then the path you are making to "your stack" won't be where you think it is.
In other words, in the IDE, lets say you have set the defaultFolder to:
/Users/echo/Desktop
But once your mainstack becomes a standalone, your path will change to something like this:
/Users/echo/Desktop/myapp.app/Contents/MacOS/myApp
You need to parse out the trailing items in the path to get back to the folder that is holding the standalone. You can see how the path is laid out by right-clicking your standalone and choosing "Show package contents". Then click your way into /Contents/MacOS/ and you will see your mainstack -- that is where "your stack" path is pointing to.
So, if you want to have your pictures folder alongside your stack in both the IDE and as a standalone... put this into your preOpenStack handler...
Code: Select all
global gdefaultFolder
on preOpenstack
set itemDel to "/"
if environment() = "development" then put item 1 to -2 of (the fileName of this stack) into gdefaultFolder
if environment() = "standalone application" then put item 1 to -5 of (the fileName of this stack) into gdefaultFolder
set the defaultfolder to gdefaultFolder
end preOpenstack
be well
Dixie
Re: Standalones and imported images
Posted: Fri Aug 20, 2010 6:52 am
by Echo
Jean-Marc and Dixie--
Thank you! I knew the path was different for a standalone (learned that from the forums awhile back) but I didn't know about the "environment" and it knowing the difference between "development" and "standalone." I'll play with that and see what happens.