Page 1 of 1

populating a drop down list...

Posted: Fri Nov 14, 2008 8:24 pm
by TheBigDuck
I am getting a variable from a shell command.

for example I want a list of files in a folder

do shell("cd /Applications/") <<Note, this doesn't seem to work
put shell ("PWD") into field "Result"
put shell ("ls") after field "Result"

So I get a list of files... and I want those files to be translated to a drop down list.

(This has nothing to do with files, I am actually getting a list from a shell command and I want that list to be a CHOICE in my drop down)

Any pointers?

Posted: Sat Nov 15, 2008 6:12 am
by Obleo
do shell("cd /Applications/") <<Note, this doesn't seem to work
put shell ("PWD") into field "Result"
put shell ("ls") after field "Result"
I tied the exact same script you had above but replaced the field with a option menu button.

I just replaced field "Result" with button "resultMenu" and it worked, The change I made is below.

Code: Select all

do shell("cd /Applications/") -- Note, this doesn't seem to work 
put shell ("PWD") into button "ResultMenu" 
put shell ("ls") after button "ResultMenu" 
If you trying to add this to the menu bar, it is also just a button.

Posted: Sat Nov 15, 2008 12:52 pm
by Klaus
Yep, "shell" is a function and not a handler.

And you can simply put text "into btn xyz", where the button should be some kind of menu. This is a shortcut for "set the text of btn xyz to mystring"

Therefore it is pretty easy to manipulate the contens of a menubutton, since this is just a "normal" string/text operation!


Best

Klaus