referring to folder in standalone
Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller, robinmiller
referring to folder in standalone
Hi.
I see that I can include a folder of files along with a standalone. How would I refer to that folder/files within the livecode stack? I have a bunch of images I want to use in my stack. Is it better to just create a library of those images rather than putting them in a folder? I can see with a standalone, this might amount to the same thing?
Thanks for any guidance.
-Chuck
I see that I can include a folder of files along with a standalone. How would I refer to that folder/files within the livecode stack? I have a bunch of images I want to use in my stack. Is it better to just create a library of those images rather than putting them in a folder? I can see with a standalone, this might amount to the same thing?
Thanks for any guidance.
-Chuck
-
- VIP Livecode Opensource Backer
- Posts: 10052
- Joined: Sat Apr 08, 2006 7:05 am
- Contact:
Re: referring to folder in standalone
See the specialFolderPath function in the dictionary. Also, to help with setting up those paths differently between development and runtime, see the environment function.
Richard Gaskin
LiveCode development, training, and consulting services: Fourth World Systems
LiveCode Group on Facebook
LiveCode Group on LinkedIn
LiveCode development, training, and consulting services: Fourth World Systems
LiveCode Group on Facebook
LiveCode Group on LinkedIn
Re: referring to folder in standalone
Hi Chuck,
I use often specialFolderPath("documents") to store files used by stacks.
Sometimes I use path of the folder where the stack or standalone is.
This function return it for stack and standalone in OSX and windows
Best regards
Jean-Marc
I use often specialFolderPath("documents") to store files used by stacks.
Sometimes I use path of the folder where the stack or standalone is.
This function return it for stack and standalone in OSX and windows
Code: Select all
function getPathFolder
put the filename of this stack into P
set the itemdel to "/"
if the environment = "development" then
delete item-1 of P
put p
else -- It's in a StandAlone mode.
if the platform = "MacOS" then
delete item -4 to -1 of P
else
delete item-1 of P
end if
end if
set the itemdel to ","
return p
end getPathFolder
Jean-Marc
https://alternatic.ch
Re: referring to folder in standalone
Thanks very much for the code-- it was the different paths between Windows and Mac standalones that was troubling me.
Re: referring to folder in standalone
Hi Chuck,
if you are "only" using referenced images/media in your stack, simply use RELATIVE pathnames for the filenames of your images and video/audio in the IDE.
Do like this:
1. put the folder(s) with your images/media into the same folder as your stack, the one you make a standalone from.
2. enter something like this for the filenames of your images, I use a folder named "images" in my example:
images/name_of_image.jpg
Know what I mean?
Et voila, this will work on Mac and WIndows, as long as you add this/these folders via the "Copy files" tab in the standalone builder.
LC will put the folders into the right place so the filename(s) will always be correct, no disappeared images
Best
Klaus
if you are "only" using referenced images/media in your stack, simply use RELATIVE pathnames for the filenames of your images and video/audio in the IDE.
Do like this:
1. put the folder(s) with your images/media into the same folder as your stack, the one you make a standalone from.
2. enter something like this for the filenames of your images, I use a folder named "images" in my example:
images/name_of_image.jpg
Know what I mean?
Et voila, this will work on Mac and WIndows, as long as you add this/these folders via the "Copy files" tab in the standalone builder.
LC will put the folders into the right place so the filename(s) will always be correct, no disappeared images

Best
Klaus
Re: referring to folder in standalone
Even better. Thanks.
Just to be clear, I don't need to set any specialfolder or default path?
Just to be clear, I don't need to set any specialfolder or default path?
Re: referring to folder in standalone
Hi
about referring to folder in standalone Klaus says:
[indent]" ...Do like this:
1. put the folder(s) with your images/media into the same folder as your stack, the one you make a standalone from.
2. enter something like this for the filenames of your images, I use a folder named "images" in my example:
images/name_of_image.jpg
Know what I mean?
Et voila, this will work on Mac and WIndows, as long as you add this/these folders via the "Copy files" tab in the standalone builder.
LC will put the folders into the right place so the filename(s) will always be correct, no disappeared images
"[/indent]
I use a folder named "Data" and a .txt file "fileBckpCorsi" so:
Data/fileBckpCorsi.txt
But creating the standalone via the "Copy Files" tab in the builder, suggested by Klaus, it does correctly work in "Windows XP", but NOT in "MacOS 10.6.8". In MacOS-standalone the file named "fileBckpCorsi.txt" in my folder "Data" is not loaded by "openStack" handler while correctly does in Windows. Yes, folder (with its .txt file) is put into the right place by LC (right-click in standalone bundle), but no trace of the text file.
Someone telling me what am I doing wrong?
thanks
xanant
about referring to folder in standalone Klaus says:
[indent]" ...Do like this:
1. put the folder(s) with your images/media into the same folder as your stack, the one you make a standalone from.
2. enter something like this for the filenames of your images, I use a folder named "images" in my example:
images/name_of_image.jpg
Know what I mean?
Et voila, this will work on Mac and WIndows, as long as you add this/these folders via the "Copy files" tab in the standalone builder.
LC will put the folders into the right place so the filename(s) will always be correct, no disappeared images

I use a folder named "Data" and a .txt file "fileBckpCorsi" so:
Data/fileBckpCorsi.txt
But creating the standalone via the "Copy Files" tab in the builder, suggested by Klaus, it does correctly work in "Windows XP", but NOT in "MacOS 10.6.8". In MacOS-standalone the file named "fileBckpCorsi.txt" in my folder "Data" is not loaded by "openStack" handler while correctly does in Windows. Yes, folder (with its .txt file) is put into the right place by LC (right-click in standalone bundle), but no trace of the text file.
Someone telling me what am I doing wrong?
thanks
xanant
Re: referring to folder in standalone
Hi xanant,
this is supposed to work with images, sound and video files, but obviously not for other files
Could you please show us your "openstack" script?
Best
Klaus
this is supposed to work with images, sound and video files, but obviously not for other files

Could you please show us your "openstack" script?
Best
Klaus
Re: referring to folder in standalone
Hi Klaus
thanks for replay. This is my handler:
on openStack
-- carica i files registrati all'ultimo utilizzo (load files saved in last backUp)
put URL "file:Data/fileBckpNomeCorsi.txt" into fld "ElencoNomeCorsi" of stack Corsi
put URL "file:Data/fileBckpCorsi.txt" into fld "ElencoCorsi" of stack Corsi
put fld "ElencoNomeCorsi" of stack Corsi into btn "Scegli il Corso..."
end openStack
The idea is to keep data separated from the interface, using the fields only to work or to see the data. I don't want to use custom properties or array neither specialFolder or relative path, so a closeStack save data into the URL and, on next start, the openStack re-load data from the URL. I always use Copy Files tab on Standalone Application Settings. My trouble is that this works correctly in Windows but not in Mac. Folder "Data" with its "text files" is at right location, in bundle (right-click) on Mac and in folder Windows in Win (so also in Linux). I wonder why Mac doesn't see the folder Data and its contents while yes in Windows?
Best regards
xanant
thanks for replay. This is my handler:
on openStack
-- carica i files registrati all'ultimo utilizzo (load files saved in last backUp)
put URL "file:Data/fileBckpNomeCorsi.txt" into fld "ElencoNomeCorsi" of stack Corsi
put URL "file:Data/fileBckpCorsi.txt" into fld "ElencoCorsi" of stack Corsi
put fld "ElencoNomeCorsi" of stack Corsi into btn "Scegli il Corso..."
end openStack
The idea is to keep data separated from the interface, using the fields only to work or to see the data. I don't want to use custom properties or array neither specialFolder or relative path, so a closeStack save data into the URL and, on next start, the openStack re-load data from the URL. I always use Copy Files tab on Standalone Application Settings. My trouble is that this works correctly in Windows but not in Mac. Folder "Data" with its "text files" is at right location, in bundle (right-click) on Mac and in folder Windows in Win (so also in Linux). I wonder why Mac doesn't see the folder Data and its contents while yes in Windows?
Best regards
xanant
Re: referring to folder in standalone
Hi xanant,
ah, I see!
Problems are:
1. relative filenames obviously only work with images, sound and audio files!
2. "the defaulfolder" is different on Mac and Windows, due to the special folder structure of APPs on Mac!
On WIndows "the defaultfolder" is the one where the EXE resides, on the Mac that is the folder
where the complete APP bundle resides.
On both platform the folder "Any folder" will be "the defaultfolder" when your app starts,
that's why this works on Windows only!
Do something like this, will also work crossplatform:
ah, I see!
Problems are:
1. relative filenames obviously only work with images, sound and audio files!
2. "the defaulfolder" is different on Mac and Windows, due to the special folder structure of APPs on Mac!
On WIndows "the defaultfolder" is the one where the EXE resides, on the Mac that is the folder
where the complete APP bundle resides.
Code: Select all
Windows:
Any folder
Your.Exe
folderwithmedia
Mac:
Any folder
Your.app
Contents
MacOS
YOUR (the actual binary app)
folderwithmedia
that's why this works on Windows only!
Do something like this, will also work crossplatform:
Code: Select all
on openstack
put the effective filename of this stakc into tPath
set itemdel to "/"
## Delete the EXE or filename of stack from the path
delete last item of tPath
put tPath & "/Data/fileBckpNomeCorsi.txt" tFile1
put tPath & "/Data/fileBckpCorsi.txt" into tFile2
## Now use these 2 pathnames:
put URL ("file:" & tFile1) into fld "ElencoNomeCorsi" of stack "Corsi"
etc...
## HINT: Unless CORSI is a VARIABLE, please ALWAYS use QUOTES around names/strings/code]
Best
Klaus
Re: referring to folder in standalone
Hi Klaus
thank you so much... now it's going well on MacOs and Win!
The distinction is subtle and very useful, indeed crucial.
Thanks also for the Hint about quotes on stack names.. had missed.
Best regards
xanant
thank you so much... now it's going well on MacOs and Win!
The distinction is subtle and very useful, indeed crucial.
Thanks also for the Hint about quotes on stack names.. had missed.
Best regards
xanant