I have a folder full of sound files that are necessary for a stack I'm working on. It's working now on my machine, but I'd like to be able to give the stack and sound files to others, and that means I want them to work on other machines.
To do that, I want to use a script to establish the pathName (or is it called filepath?) for the folder full of sounds.
I think there's a way to do this, but I don't know how. There are a couple of necessary commands or functions I don't know.
--Click on a button
--I get a dialog box showing a directory of my hard drive.
--I navigate through the directory until I find the file or folder I want, select it.
--The long pathname of the file or folder gets returned somehow
--I can store the pathname in a field or something, so when the stack is first used on a new machine, a script will be able to find the designated file or folder
--If the script is unable to find the right folder, the user is prompted to identify it, as above.
I don't need all the details, just a few hints. If someone can give me the general idea, I'd sure appreciate it.
I'm on Mac OS, current version, LC Community Edition, version 8.1.2.
Thanks in advance,
Tim
Looking up a file pathname
Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller
Looking up a file pathname
It's better to be happy and rich than poor and sad -- W. C. Fields
-
- VIP Livecode Opensource Backer
- Posts: 858
- Joined: Wed Jun 24, 2009 1:17 pm
- Location: Plymouth, UK
- Contact:
Re: Looking up a file pathname
Hi Tim - hopefully the following will give you some ideas:
You could then call this handler in 'preOpenStack' or similar.
However if you'll be distributing your project as a standalone to other computers you won't be able to save the folder path as you would with a stackfile - you'll have to use a little text file (or similar) to save the folder path instead of a custom property or field.
Dave
Code: Select all
on checkForSoundFiles
put the uSoundFiles of the current stack into tFolder
put tFolder & slash & "fileThatIsAlwaysPresent.wav" into tFile
if there is not a file tFile then
answer "Unable to find Timothy's Sound Files!"
answer folder "Find Timothy's Sound Files"
if the result is empty then
put it into tFolder
put files(tFolder) into tList
if there is a file (tFolder & slash & "fileThatIsAlwaysPresent.wav") then
set the uSoundFiles of the current stack to tFolder
answer "All OK now"
else
answer "file" && quote & "fileThatIsAlwaysPresent.wav" & quote && "not found"
end if
end if
end if
end checkForSoundFiles
However if you'll be distributing your project as a standalone to other computers you won't be able to save the folder path as you would with a stackfile - you'll have to use a little text file (or similar) to save the folder path instead of a custom property or field.
Dave
"...this is not the code you are looking for..."
Re: Looking up a file pathname
Thanks so much Dave.
Your suggestion will work just fine, of course, and I appreciate your detailed script. If I understand your script correctly, I am looking for something slightly different.
Let's say I have already manually copied the folder containing the sound files to the new machine's hard drive. I want the script to be able to find that folder.
I want to write a script that will show me the directory of the new hard drive, allow me to identify the folder in question and return the path name of that folder. I'll put it into a field or something for use in a script that will find the folder containing the sound files when needed. I don't need a detailed script, just a suggestion for the commands and functions I might need to to this.
Your suggestion will work just fine, of course, and I appreciate your detailed script. If I understand your script correctly, I am looking for something slightly different.
Let's say I have already manually copied the folder containing the sound files to the new machine's hard drive. I want the script to be able to find that folder.
I want to write a script that will show me the directory of the new hard drive, allow me to identify the folder in question and return the path name of that folder. I'll put it into a field or something for use in a script that will find the folder containing the sound files when needed. I don't need a detailed script, just a suggestion for the commands and functions I might need to to this.
It's better to be happy and rich than poor and sad -- W. C. Fields
Re: Looking up a file pathname
It's in there above: the script does a little more to check that the user didn't click the cancel button and various other helpful things, but this is the important line for you to check in the dictionary
Code: Select all
answer folder "Find Timothy's Sound Files"
Re: Looking up a file pathname
Okay, I understand now. I'll explore those LC features. Thanks again.
T'im
T'im
It's better to be happy and rich than poor and sad -- W. C. Fields