One solution would be to create a list of state abrievations, in the order you want them (i.e., “CA” would be the fifth item). Then run a loop to search for a given state in the list. When the state is found, you have your number.
I’m sure there’s a more elegant way of doing this, but this should get you started.
This would be one of Emmanuel’s solutions (appart from using Smile to do it): :lol:
set theList to {"a", "b", "c", "d", "e", "f", "g"}
IndexOfItem("c", theList) --> 3
on IndexOfItem(theItem, theList) -- credits Emmanuel Levy
set text item delimiters to return
set theList to return & theList & return
set text item delimiters to {""}
try
-1 + (count (paragraphs of (text 1 thru (offset of (return & theItem & return) in theList) of theList)))
on error
0
end try
end IndexOfItem