Word delimiters in Quark

The result of

tell application "QuarkXPress Passport"
	make new document
	tell front document
		make new text box at beginning with properties {bounds:{"10 mm", "10 mm", "200 mm", "200 mm"}}
		set story 1 to "Some words of this text |are| surrounded by pipes."
		words of story 1
	end tell
end tell

is {“Some”, “words”, “of”, “this”, “text”, “are”, “surrounded”, “by”, “pipes.”}

How can I do to get {“Some”, “words”, “of”, “this”, “text”, “|are|”, “surrounded”, “by”, “pipes.”}

My concept is that a word is somethiing surrounded by spaces.
It seems that for Quark the meanning of word is a set of numbers or letters surrounded by any thing not numbers or letters.
And Applescript thinks different:

The result of

words of "Some words of this text |are| surrounded by pipes."

is {“Some”, “words”, “of”, “this”, “text”, “|”, “are”, “|”, “surrounded”, “by”, “pipes”}

So… What is a word ???

Some idea? Thanks in advance.

You can use AppleScript’s text item delimiters to get around this problem:


tell application "QuarkXPress Passport"
	make new document
	tell front document
		make new text box at beginning with properties {bounds:{"10 mm", "10 mm", "200 mm", "200 mm"}}
		set story 1 to "Some words of this text |are| surrounded by pipes."
		set thestory to story 1
	end tell
end tell

set storywords to my getwords(thestory)

on getwords(txt)
	set olddelims to AppleScript's text item delimiters
	set AppleScript's text item delimiters to {space}
	set txtitems to text items of txt
	set AppleScript's text item delimiters to olddelims
	return txtitems
end getwords

I have not tested with the pipe character but Quark has its own delimit table which you can change use then change back in pretty much the same way as Applescript TID’s here is an example that I was playing with only yesterday. It should give you some ideas.

tell application "QuarkXPress"
	activate
	set DT1 to delimit item "£" of delimit table 1
	set delimit item "£" of delimit table 1 to can be contained in word
	set DT2 to delimit item "."
	set delimit item "." to can be contained in word
	if not (exists document 1) then error "No document is open."
	if not (exists current box) or box type of current box is not text box type then error "No text box is selected"
	tell document 1
		set Selected_Box to current box
		--
		set Price_List to my Get_Paras()
		set Price_Count to count of Price_List
		--
		tell Selected_Box
			set Para_Count to count of paragraphs
			if Para_Count = Price_Count then
				-- Ignore list header para & last para for rule below
				repeat with i from 2 to Para_Count - 1
					tell paragraph i
						set text of word before last word to first word of item i of Price_List
						set text of last word to last word of item i of Price_List
					end tell
				end repeat
			else
				display dialog "The paragraph count is incorrect" giving up after 3
			end if
		end tell
	end tell
	set delimit item "£" of delimit table 1 to DT1
	set delimit item "." of delimit table 1 to DT2
end tell
--
on Get_Paras()
	activate me
	set Text_File to choose file with prompt "Please locate the text that you wish to read." default location (path to desktop) without invisibles
	set The_Prices to paragraphs of (read Text_File)
	return The_Prices
end Get_Paras