Get the count of delimited text items

Hi all …

I’m trying to get the Total number of delimited items of a variable … You can see below I’ve split up 3 variables using item delimiters… What I want is a way to set a new variable to the TOTAL NUMBER of delimited items of variable “Result”.



set TempTID to AppleScript's text item delimiters -- save the current delimiter
	set AppleScript's text item delimiters to "_"
	set VerifyA to first text item of Result as string
	set VerifyB to second text item of Result as string
	set VerifyC to third text item of Result as string
	set AppleScript's text item delimiters to TempTID -- restore the original delimiter


Thanks a lot guys!

-Mel

Hi,

first of all, result is a reserved word, it contains always the result of the most recent line,
in your example result contains “_” after the second line (setting the text item delimiters)
and “” after the third line.
try something like this


set TempTID to AppleScript's text item delimiters -- save the current delimiter
set AppleScript's text item delimiters to "_"
set TIDnum to count text items of theResult
set VerifyA to first text item of theResult -- no coercion!! a TEXT item is always class TEXT
set VerifyB to second text item of theResult
set VerifyC to third text item of theResult
set AppleScript's text item delimiters to TempTID -- restore the original delimiter