how can I compile a huge variable list?

I have a script that gets a ton of data. I want to recall each piece of data one at a time and process it. Is there a way to store it in a list, or make a variable for each piece of data and then refer back to their values one at a time later? I know this is vague…and ideas appreciated.

like this…
say i have a script that gets 10 friends phone numbers, one at a time.
when it gets done with getting the 10 numbers, the script goes through each one at a time does actions to them.

possible?

doc:

Simple. At the beginning of your script, simply identify a variable as an empty list:

set friend_phone to {}

Then, after each number is gathered for processing, add it the end of the list:

set end of friend_phone to xxxxxxx

Eventually, you will have a long list of numbers, all in the order they were extracted. You can then write that list to a file for later reference, if necessary.

Craig,
how do i access this data…Lets say I want to make it say everthing.

say friend_phone using “victoria”

how do I make is go through the entire list and do this?

Set it up as a loop:

repeat with A_friend in friend_phone
say A_friend using "victoria"
end

Realize that this will whip through the list pretty fast, so you may want to put a delay in there, or make the script do some other things as well inside the loop.

Is this possible? If i enter in data, and it already exists in the list to not add it again? Thanks!

Certainly. If you already have a partial list, define it at the beginning of the script:

set friend_phone to {2222222,3333333,444444}

Whenever you add to the list, it grows. If this is something that is going to grow continually over time, it would be very smart to write the list to file, then have the script read it every time it executes, add some more, write the new list, etc. It is like having your own retrievable database.

The problem is that i cannot do this at the beging. I do not know what the data is ahead of time. Is there a way to do this as you add the data in?

if xxxxxxx is not in friend_phone then
set end of friend_phone to xxxxxxx
end if