Hello guys,
I am trying to create an app in Automator using Applescript but am getting stuck on one part.
In my script, I have a Choose From List prompt which lists a number of items to select from. Each one of these items starts with a specific alphanumeric site code (i.e. CA01, US01, US02, etc.) and then is followed by an underscore and a more descriptive location (i.e. CA01_Vancouver).
I need to take the site code from the selected item and put it into a variable for use later in the script, but am unsure of how to do this. Can you help?
Example:
set sites to {"CA01_Vancouver", "US01_NewYork", "US02_Atlanta"}
set site_prompt to choose from list sites with prompt "select site" with title "Select site" default items {"CA01_Vancouver"} OK button name {"Next"} cancel button name {"Cancel"}
if site_prompt is false then error number -128
# set site_code to first 4 of site_prompt ***this of course is the part I need help with as I know this is not valid code
# do other stuff here using site_code variable