Wednesday, May 17, 2006

Go get XPress - Part 5

The 5th function, setSelection(aRange) is called to select a specified range of text in the current story. The tricky part is that it uses a separate line of script in order to place the cursor before a character. This case, you are given aRange parameter with zero value in the second element.

on setSelection(aRange)
  tell application "QuarkXPress"
    set aLocation to item 1 of aRange
    set aLength to item 2 of aRange
    if aLength = 0 then
      set selection to (insertion point before character aLocation of story 1 of current box)
      set selection to (text from character aLocation to character (aLocation + aLength - 1) of story 1 of current box)
    end if
  end tell
end setSelection

Well, it gets more and more complicated.

Monday, May 01, 2006

Go get XPress - Part 4

The 4th function too is simple. The getSelection() function returns the selected range in a form described in the last post.

on getSelection()
  tell application "QuarkXPress"
    set aSelection to selection
    return {(offset of aSelection) + 1, (length of aSelection)}
  end tell
end getSelection

Now we have 3 more functions to go.