Is it possible to make the buttons on a display dialog be loaded dynamically from an array?
set srcdisk to list disks
display dialog "Disk?" buttons {srcdisk}
Is it possible to make the buttons on a display dialog be loaded dynamically from an array?
set srcdisk to list disks
display dialog "Disk?" buttons {srcdisk}
it works - but there is a maximum of three buttons with display dialog:
set srcdisk to (list disks)
if (count of srcdisk) ≤ 3 then
set thisdisk to (display dialog "Disk?" buttons srcdisk)
else
set thisdisk to (choose from list srcdisk)
end if
Interesting. I am about to try to make a script that would look in a folder and then display all the files it saw in that folder as a list for the user to choose from. I want to do this to restrict the user to choosing from that folder. If I just had a choose file instruction, they could navigate to anywhere.
Has anyone tried this before? If someone had some code that I could start with I would appreciate it.
Model: Mac G5 OS 10.3.9
Browser: Safari 312.3.1
Operating System: Mac OS X (10.3.9)
Matt-Boy,
The “choose from list” command sounds like exactly what you need. Check the standard additions dictionary for all the available features.
WF
set theList to {"item1", "item2", "item3", "etc"}
set theFile to choose from list theList
Now how do you make this a drop down list instead of showing all the files?
Not exactly sure what you are asking. “Choose from list” works with any sort of list in Applescript and shows everything in the list. Matt-boy would set his list to the contents of the folder he is interested in. Hope this helps.
WF
I mean, how do you get a drop down list instead of a list that shows all options. Like a drop down menu?!?
I have used choose from list before so I know what I would do once I have the list. The only part I haven’t done is to get a list of files from a directory and save those file names into a list.
So, to get all of the files in a folder as a list, what would be the syntax?
set FileList to (every file in folder x) as list
Something like that??
This should get you started:
set theFolder to (path to shared documents folder)
list folder theFolder without invisibles
set userFileList to choose from list (result)
if result is false then error number -128
You would need to use AppleScript Studio, or some third-party solution, to do that.
You have to tell the Finder to do it. Also, you can either have it get the complete paths to the files, which won’t look pretty, or you can have it get the names of the files and fill in the rest of the path later. Leave out “name of” if you want the complete path.
WF
tell application "Finder"
set theList to name of every file of folder x
end tell
You don’t have to use the Finder.