Tuesday, April 25, 2006

Go get XPress - Part 3

This is the third post of the series. Today's function is getText(aRange), which returns a range of text from the current story. The range parameter is specified in a form { location, length }. Note that the location of the first character of a story is 1, which is AppleScript convention of accessing a list object.

on getText(aRange)
  tell application "QuarkXPress"
    set aLocation to item 1 of aRange
    set aLength to item 2 of aRange
    return text from character aLocation to character (aLocation + aLength - 1) of story 1 of current box
  end tell
end getText

The above code will raise an error if you pass 0 to the length element. As far as Wild CAT is concerned, this is not a problem as it never ask for a null text.

1 Comments:

Anonymous Rosemary Q said...

Nice blog, thanks for posting.

9:00 PM  

Post a Comment

<< Home