Inliner
Searches all stories in a Quark XPress file and applies a style sheet supplied by user to the text between two special characters.
set beginChar to "Æ"
set endChar to "û"
set theStyle to text returned of (display dialog "What is the name of the style sheet?" default answer {"Normal"})
tell application "QuarkXPressª"
activate
if not doc content showing then set doc content showing to true
try
tell document 1
--set wordsList to {}
set numStories to number of stories
repeat with storyIndex from 1 to numStories
--set storyRef to a reference to story 1 of selection
set storyRef to (a reference to story storyIndex)
try
tell storyRef
-- make list of the offset of each special character, then work backwards
--through the list "making" a return at that spot
--First the beginning character (BC)
set BCtextOffsets to (offset of (every text where it = beginChar) of storyRef)
if (class of BCtextOffsets is not equal to list) then
set BCtextOffsets to ECtextOffsets as list
end if
set numOffsets to count of items in BCtextOffsets
repeat with i from -1 to -numOffsets by -1
make word at character (1 + (item i of BCtextOffsets)) with data (return & beginChar)
end repeat
--Then the ending character (BC)
set ECtextOffsets to (offset of (every text where it = endChar) of storyRef)
if (class of ECtextOffsets is not equal to list) then
set ECtextOffsets to ECtextOffsets as list
end if
set numOffsets to count of items in ECtextOffsets
repeat with i from -1 to -numOffsets by -1
make word at character (1 + (item i of ECtextOffsets)) with data (return & endChar)
end repeat
--apply the stylesheet to the marked paragraphs
tell ((every paragraph) where the text of it contains beginChar)
set style sheet to theStyle
end tell
delete (character before every character where the text of it is beginChar)
delete (every character where the text of it is beginChar)
delete (character before every character where the text of it is endChar)
delete (every character where the text of it is endChar)
end tell
on error
display dialog "Something has gone horribly wrong."
end try
end repeat
end tell
display dialog "In-line coding complete!" & return & numOffsets & " instances changed."
on error errStr
display dialog errStr
end try
end tell
Copyright 2000 Missives, Confessions, Recipes to john@dorsey.org