Tab Text

Probably an easily answered question.

I have a script that reads a tab text file and gives me the following output

{{“argentina”, “barbados”, “canada”, “denmark”}, {“egypt”, “finland”, “guam”, “holland”}}

What I was wondering is there a way that i can just select each of the individual country names so that i can ust them in a different script as sepaeate variables.

i.e. set q to item 1 of the list, set w to item 2 of the list etc.

To work with your list of lists later in your script - it would first help to set a variable to it.

set theLists to {{"argentina", "barbados", "canada", "denmark"}, {"egypt", "finland", "guam", "holland"}}

Then, you can work with the list itself, its sublists, or the items of each item in a few different ways. Here are some examples.



set theLists to {{"argentina", "barbados", "canada", "denmark"}, {"egypt", "finland", "guam", "holland"}}

--to select a targeted item (say, Egypt)
set thisCountry to (item 1 of item 2 of theLists) as string
-->now use this variable
display dialog "I know where " & thisCountry & " is."

--to select a list of countries from your list of lists
set lisA_thru_D to item 1 of theLists
--returns {"argentina", "barbados", "canada", "denmark"}
--now use this variable
set theAnswer to choose from list lisA_thru_D with prompt "Where in the world is Carmen San Diego?"
-->if not cancelled, returns a list of 1 item
if (item 1 of theAnswer) = "barbados" then
	display dialog "I wish I were in " & (item 1 of theAnswer) & " too."
end if

--to cycle through the list of lists
repeat with thisList from 1 to count theLists
	set listNum to thisList --what list are we on?
	repeat with thisItem in (item thisList of theLists)
		display dialog "List Number: " & listNum & return & (thisItem as string) & "!"
	end repeat
end repeat