Re: Repeat With question (newbie level)
Re: Repeat With question (newbie level)
- Subject: Re: Repeat With question (newbie level)
- From: Bill Planey <email@hidden>
- Date: Wed, 14 Feb 2001 11:43:40 -0600
>
On 2/14/01 8:51 AM, Bill Planey <email@hidden> wrote:
>
>
>Is there a way to set each alphabetic character into a list
>
>{"a", "b", "c", "d", etc.} and have the variable be redefined
>
>to the next letter in the list upon the completion of a step
>
>until the last letter has been used? I know this is possible
>
>with numbers (ie,: Repeat with i from 1-9), but how about letters?
>
>
set the alphalist to {"a", "b", "c", "d"}
>
repeat with currentLetter in the alphalist
>
display dialog currentLetter
>
end repeat
>
>
--Michelle
Thanks Michelle,
I implemented your suggestion thus:
set the alphalist to {"a", "b", "c", "d", "e", "f", "g", "h", "i", "j",
"k", "l", "m", "n", "o", "p", "q", "r", "s", "t", "u", "v", "w", "x",
"y", "z"}
repeat with currentLetter in the alphalist
set FindString1 to "^p" & currentLetter
set FindString2 to currentLetter & "^p"
set ChangeString1 to " " & currentLetter
set ChangeString1 to currentLetter & " "
tell TextSubObject
yesCReplace(FindString1, ChangeString1)
yesCReplace(FindString2, ChangeString2)
if currentLetter = "n" then
JustSave()
end if
end tell
end repeat
... as I had two separate lists of replaces (26 x 2) to make,
one where the character preceded a carriage return (^p) and
one where it followed. This saved a lot of space!! Just for
good measure, I tossed in an if statement to save the document
when the currentLetter was at the halfway point through the
list (using the JustSave handler defined elsewhere).
Thanks!!!
Bill Planey