I feel like this is going to have the simplest answer and that I’m just not seeing what’s right in front of my face, but I have to ask about this.
For context, I have literally used the exact same if statement successfully in another script. Here’s what I’m trying to do:
- user selects a language from a list of about 40
- the script assigns the language a 2-letter all caps code
In the script I’ve designed language_code from the outset as “Null” just to make sure it actually changes. Similarly, the dialog box is also there only as a check, to make sure that language_code was properly set.
set language_code to "NULL"
set language_choices to {"Arabic (AR)", "Amharic (AM)", "Armenian (HY)", "Azerbaijani (AZ)", "Belarusian (BE)", "Bosnian (BS)", "Bulgarian (BG)", "Chinese (ZH)", "Croatian (HR)", "Czech (CS)", "Danish (DA)", "Dutch (NL)", "English (EN)", "Estonian (ET)", "Farsi (FA)", "Finnish (FI)", "French (FR)", "German (DE)", "Greek (EL)", "Hebrew (HE)", "Hindi (HI)", "Hungarian (HU)", "Indonesian (ID)", "Italian (IT)", "Japanese (JP)", "Kazakh (KK)", "Korean (KO)", "Latvian (LV)", "Lithuanian (LT)", "Malay (MS)", "Norwegian (NO)", "Polish (PL)", "Portuguese (PT)", "Romanian (RO)", "Russian (RU)", "Serbian (SR)", "Slovak (SK)", "Spanish (ES)", "Swahili (SW)", "Swedish (SV)", "Thai (TH)", "Turkish (TR)", "Ukrainian (UK)", "Urdu (UR)", "Vietnamese (VI)"}
set language_chosen to {choose from list language_choices}
if language_chosen is item 1 of language_choices then
set language_code to "AR"
end if
display dialog language_code
All I ever get back is “null” (and before I had the “null” variable I just kept getting an error that said it language_code wasn’t defined but, like, wasn’t it just defined above by my if-statement?)
Thanks again guys. Like I said, I’m sure it’s just something really simple that I’m not seeing so late in the day…