Hi.
What you’ve got is good enough for a short list like that. In general, though, if you need to access a fetched value (such as a record in your list) more than once, it’s more efficient to fetch it just once and store it in a variable, from which it can be accessed more quickly:
set Aarons_Stores to {¬
{store_number:"F0346", city:"Grand Junction", region:"R0002"}, ¬
{store_number:"F0394", city:"Cortez", region:"R0002"}, ¬
{store_number:"F0657", city:"Vernal", region:"R0001"}, ¬
{store_number:"F0739", city:"Rock Springs", region:"R0001"}, ¬
{store_number:"F0858", city:"Riverton", region:"R0001"}, ¬
{store_number:"F0910", city:"Rifle", region:"R0002"}, ¬
{store_number:"F0935", city:"Ontario", region:"R0003"}, ¬
{store_number:"F1132", city:"Evanston", region:"R0001"}, ¬
{store_number:"TM001", city:"Cortez", region:"R0002"} ¬
}
repeat with x from 1 to length of Aarons_Stores
set thisRecord to item x of Aarons_Stores -- Fetch from the list just once and store in a variable
set Store to store_number of thisRecord -- Read from the variable.
set region to region of thisRecord -- Ditto.
display dialog "Store #" & x & " is " & Store & " and is aligned in Region " & region
end repeat
There are also ways to read several properties of a record with just one command — although I’m not sure how “one command” they are beneath the bonnet!
repeat with x from 1 to length of Aarons_Stores
set {Store, region} to {store_number, region} of item x of Aarons_Stores
display dialog "Store #" & x & " is " & Store & " and is aligned in Region " & region
end repeat
Or:
repeat with x from 1 to length of Aarons_Stores
set {store_number:Store, region:region} to item x of Aarons_Stores
display dialog "Store #" & x & " is " & Store & " and is aligned in Region " & region
end repeat
When posting AppleScript code here, it would be great if you could wrap it in MacScripter’s special [applescript] and [/applescript] tags. These make it appear as above when posted, in a box with a clickable link which opens it it people’s default editors. There’s an “Applescript” button for them just above the text field in posting pages.