repeat with

Hello. I have the following script that I am trying to improve.

tell window 1 of application “Tex-Edit Plus”
select insertion point before paragraph 1 of window 1
repeat
search looking for “100” with searching from cursor
if result is not false then
select paragraph (get paragraph offset of selection)
set color of selection to red
else
exit repeat
end if
end repeat
end tell

tell window 1 of application “Tex-Edit Plus”
select insertion point before paragraph 1 of window 1
repeat
search looking for “110” with searching from cursor
if result is not false then
select paragraph (get paragraph offset of selection)
set color of selection to red
else
exit repeat
end if
end repeat
end tell

It works fine but I was playing around with it to get this

set search_text to {“100”, “110”}
set num_items to length of search_text

repeat with i from 1 to num_items
set an_item to item i of search_text

tell window 1 of application "Tex-Edit Plus"
	select insertion point before paragraph 1 of window 1
	repeat
		search selection looking for an_item with searching from cursor
		if result is not false then
			select paragraph (get paragraph offset of selection)
			set color of selection to red
			
		else
			exit repeat
		end if
	end repeat
end tell

end repeat

Now when I run the improved script LOL, all it finds are the first “100” and first “110” in the file and not all the others.

Now I am pretty sure it has to do with the repeat with loop, since that is what has been changed. Any pointers???

Thanks…

I like your script, but you’ll probably get a lot more info and help from the Tex-Edit Plus web site at…

http://www.malcolmadams.com/te/

There are well over 200 example scripts to choose from that will “greatly enhance” your Tex-Edit experience.

Please post your results here so that we can see what you came up with. Thanks C.Mullins
Signed very interested!