Greggo
The actual problem I am working on is, of course, more complex than what I put out. I am trying to figure out a repeating sequence in which there is a variable that functions as a counter – i.e. set varA to varA + 1 on each repetition.
The idea is to create a mail merge for Eudora with a list of names extracted from another document. The counter would progress through the list. The counter would be part of a function which would do this, but do it inside the context of a variable.
FIRST EXAMPLE
set theNames to {“John”, “Mary”, “Freddie”, “Elizabeth”}
set oneName to item 2 of theNames
result “Mary”
SECOND EXAMPLE
set theNames to {“John”, “Mary”, “Freddie”, “Elizabeth”}
set listCount to 0
repeat
set listCount to listCount + 1
set oneName to item listCount of theNames
if listCount > (number of items in list) then exit repeat
end repeat
results of repetitions:
“John”
“Mary”
“Freddie”
“Elizabeth”
THIRD EXAMPLE
set theNames to {“John”, “Mary”, “Freddie”, “Elizabeth”}
set listCount to 0
set oneName to item listCount of theNames
repeat
set listCount to listCount + 1
set message listCount to oneName
if listCount > (number of items in list) then exit repeat
end repeat
results of repetitions:
“John”
“Mary”
“Freddie”
“Elizabeth”
FOURTH EXAMPLE
–Here is some of the actual script–
set theNames to {“John”, “Mary”, “Freddie”, “Elizabeth”}
set myMessage to “The text for the email message.”
set listCount to 0
set oneName to item listCount of theNames
set wholeMessage to "Dear " & oneName & return & return & myMessage
–When listCount increases by 1 on each repetition, I want the name (item in an aray) to change–
repeat
set listCount to listCount + 1
if listCount > 4 then exit repeat
set body to wholeMessage
end repeat
–The result of, say, the third repetition would be:
"Dear Freddie
The text for the email message."