Is this an array or list?

I am taking a cell value from filemaker such as a state “CA”.

I want to equate that state with a number in an applescript whereas each state is represented by a number from 1 to 50.

So, If my variable is “CA”, the result in the applescrpt would be the number associated with it, such as “5”.

What I want to do is to turn that state “CA” into a number variable associaated with it.

Can someone point me in the correct direction?

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.

Brad Bumgarner, CTA

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