looping through comma delimited string - Need Help

I have a comma delimited string that I need to work through and fire a method on each of the pieces of that string.

For instance: I might have a variable that hold the value 2,69,12

I need to loop through that and call a method on 2 then the same method on 69 and finally on 12.

I can not figure out how to loop through or how to get each piece of that string.

Thanks in advance.

Hi,

The way I’d do it is by using text item delimiters, these provide a fast way of dividing a string to make a list. Like this

set aString to "2,69,12"

set {myTID, AppleScript's text item delimiters} to {AppleScript's text item delimiters, {","}}
set myList to text items of aString -- Gives list {"2", "69", "12"}
set AppleScript's text item delimiters to myTID -- It's considered good practice to return the TID's to their original state

repeat with myItem in myList -- Loop through the items in the list
	--Do your method call here
end repeat

Best wishes

John M

Given the nature of your sample data, you could also:

set x to words of x
repeat...