|
|
#1 |
|
AppleScript - Button Returned of Results from a List
Hello, Im new to AppleScript programming and having some trouble trying to get the returned result of the clicked button
I have a list of list of items, and two buttons (Show, Hide). I want to do an If then else statement depending on if the button selected was show or Hide... Here is an example of what im trying to do.. Code:
set SelectedItem to (choose from list {"User Library", "Hidden Files", "Something1", "Thinking"} with prompt "Choose" with title "Show/Hide" OK button name "Show" cancel button name "Hide")
if SelectedItem is "User Library" then
error "Can’t get button returned of {\"User Library\"}." number -1728 from button returned of {"User Library"} I would select "User Library" from the List and then Select the Button "Show" Expecting the Display dialog box to show "Button Returned Show" I'm usually doing Visual Basic or SQL and apple script is new to me, so any help would be wonderful Thank you. |
|
|
|
0
|
|
|
#2 |
|
The choose from list command returns either false, or a list of chosen items, so you have to check the returned list for the items you want to check.
Like this. Code:
set chosen_city to choose from list {"New York", "Boston", "Chicago"}
if chosen_city is false then
return "Cancelled Button Clicked" as text
else if chosen_city contains "New York" then
return "You chose New York" as text
else
return "You did not choose New York" as text
end if
to allow multiple selections. Like this. Code:
set chosen_city to choose from list {"New York", "Boston", "Chicago"} with multiple selections allowed
if chosen_city is false then
return "Cancelled Button Clicked" as text
else
return chosen_city count
end if
like this. Code:
set chosen_city to choose from list {"New York", "Boston", "Chicago"}
if chosen_city is false then
error number -128
else if chosen_city contains "New York" then
return "You chose New York" as text
end if
Code:
if SelectedItem is "User Library" then Code:
if SelectedItem contains "User Library" then Regards Mark Last edited by Mark FX; Jan 13, 2013 at 02:12 PM. |
|
|
|
0
|
![]() |
|
«
Previous Thread
|
Next Thread
»
| Thread Tools | Search this Thread |
| Display Modes | |
|
|
All times are GMT -5. The time now is 08:11 PM.






Linear Mode
