Ive been stuck on this for days now and have had to reach out for help,
I have a Duck, Lobster, Moth and an Onion Merchant on a list.
You have to choose one of them.
I need the list items to return under their real names, which are
1 (Duck) ,2 (Lobster) 3 (Moth) and 4 for onion Man
ive tried setting variables… listing properties, their numeric values are showing up on the variable board, but not being recognised by other variables down the line which are expecting to be met with numbers. ie; if onion man is chosen from the list, from then on i would like him to be known as 4. I cant handle another google search session
set theList to {"Duck", "Lobster", "Moth", "Onion Merchant"}
set userNameSelection to (choose from list theList)
if userNameSelection = false then
error number -128
else
set userNameSelection to item 1 of userNameSelection
end if
repeat with i from 1 to (count theList)
if item i of theList = userNameSelection then
set userNumberSelection to i
exit repeat
end if
end repeat
-- later in script
-- perhaps this
set aVariable to item userNumberSelection of theList
-- or maybe this
set aVariable to (userNumberSelection as text) & " (" & (item userNumberSelection of theList) & ")"
set TheCharacters to {"Duck", "Lobster", "Moth", "Onion Man"}
set WhatTheyOwn to {"a beak.", "claws.", "antennae.", "a bicycle."}
set ChosenCharacter to choose from list TheCharacters with prompt "Choose a character:"
if ChosenCharacter is false then return -- user cancelled
set CharacterNumber to 1
repeat with EachCharacter in TheCharacters
if ChosenCharacter as string = EachCharacter as string then
exit repeat
else
set CharacterNumber to CharacterNumber + 1
end if
end repeat
--further down the line:
display dialog (ChosenCharacter as string) & " has " & item CharacterNumber of WhatTheyOwn