Quark XPress 4.1 find/replace

hello,
i want to process multiple find/replace in a row (in the current document) with Applescript in Quark XPress 4.1.
I already found how to do it for a simple find/replace of a single character:

What i can’t do is using this method to find a string and replace it with a character or another string (for exemple : find two spaces and replace them with one).
Another mystery for me is how to identify in AS the invisible characters special to XPress like the c,n and other special characters?
And at last, how to process a find/replace with formatting involved (the search string in styleA with the replaceString in styleB)?
a lot of mystery to solve alone…
Thanks for any help.
Vincent

hi

I do not know if this helps - but here is a script that allows to find/replace strings with different focus.

set originalStringList to {"  "}
set replaceStringList to {" "}

set originalStringCount to count originalStringList
repeat with s from 1 to originalStringCount
	xPstringReplace({}, {}, item s of originalStringList, item s of replaceStringList)
end repeat

on xPstringReplace(pageList, textboxList, originalString, replaceString)
	tell application " xPress 4J"
		tell document 1
			if pageList = {} then
				set pageList to index of every page
				if class of pageList ≠ list then set pageList to {pageList}
			end if
			set pageCount to count of pageList
			repeat with p from 1 to pageCount
				tell page (item p of pageList)
					if textboxList = {} then
						set textboxList to index of every text box
						if class of textboxList ≠ list then set textboxList to {textboxList}
					end if
					set textboxCount to count of textboxList
					repeat with t from 1 to textboxCount
						tell story 1 of text box (item t of textboxList)
							repeat
								try
									set stringOffset to my getStringOffset(contents, originalString)
									set characters stringOffset thru (stringOffset + (length of originalString) - 1) to ""
									set character stringOffset to (replaceString & character stringOffset)
								on error errmsg
									exit repeat
								end try
							end repeat
						end tell
					end repeat
				end tell
			end repeat
		end tell
	end tell
end xPstringReplace

on getStringOffset(xPstory, originalString)
	return offset of originalString in xPstory
end getStringOffset