Select Quark text from point a to b

Hello, all!

I’m changing a bunch of Quark files (4.11-OS 9.2.2). I’m trying to select contiguous, multi-paragraph text in the same text box that all begins with a unique word and ends with a unique word. Unique, meaning the starting word is used only once in that text box and the ending word is used only once in that text box. The starting and stoping words are consistant.

In other words, select text between point a and point b.

I’ve been toying with various attempts surrounding the variable/statement:

set myselection to (a reference to text of story 1) and later…

select (text from (a reference to (text of myselection is “point a”)) to (text from (a reference to (text of myselection is “point b”))

… all to no avail!

Any suggestions?

Hope all is well.
Thanks to all!

Hi there,
This method with temporarily changed AS Item Delimiters does well on my machine.
Works with current box.


-- sets selection to text from textStart thru textEnd
set textStart to "startingString"
set textEnd to "endingString"
tell application "QuarkXPress 4.11" 
	tell document 1
		set theText to text of current box
		set selStart to count characters of (my getTID(theText, textStart, 1))
		set selEnd to count characters of (my getTID(theText, textEnd, -1))
		
		set selection to text from character selStart to character (-selEnd) of current box
	end tell
end tell


on getTID(theString, theDelimiter, theItem)
-- for this fragment, tons of thank you's to Shirley W. Hopkins, who wrote 
-- "AppleScripting QuarkXPress". I use this a lot.

	set theReturn to ""
	set oldDelim to AppleScript's text item delimiters
	set AppleScript's text item delimiters to theDelimiter
	try
		set theList to text items of theString
		if theItem = 0 then
			set theReturn to theList
		else
			set theReturn to item theItem of theList
		end if
		set AppleScript's text item delimiters to oldDelim
	on error
		set AppleScript's text item delimiters to oldDelim
	end try
	return theReturn
end getTID

Thank you, ev!

Yes, that works perfectly! Counting the characters to the start and end insertion points… I understand.

Many thanks, again, ev!