Repeat and append strings to variable in BBEdit 6.1

I’m trying to take a selection of words in BBEdit, and replace the spaces with plus signs, as part of a script to put the resulting string into a URL like <A HREF=http://us.imbd.com/find?lastName,+FirstName+MiddleName">FirstName LastNAme

I try to do Repeat with i from 1 to n
Copy aVar &“+” to aVar
end repeat

BUT the string doesn’t accumulate with each iteration.

How do I get the Repeat thing to create a concatenated string? please

You don’t really need a repeat loop to do it. This is what I’d use:

set myString to “this is my string”
set plusSign to “+”

tell window 1 of application “BBEdit”

--set grep mode
set GrepS_options to {search mode:grep, starting at top:true, wrap around:false, reverse:false, case sensitive:true, match words:true, extend selection:false}
select insertion point before character 1
set text 1 to myString
--test for presence of search item first; if present, replace it
set srchRslt to (find "\s" options GrepS_options with selecting match)
if found of srchRslt then
	tell application "BBEdit"
		replace "\s" using plusSign searching in text 1 of text window 1 options GrepS_options
	end tell
end if

end tell

Please bear in mind that this has only been tested in BBEdit 7; I don’t know whether it’ll work in BBEdit 6.1.

HTH,

Ethan