creating guides

Discuss AppleScripting for QuarkXPress 10, 9 & 8 (and before)
Post Reply
mathews
Posts: 0
Joined: 20 Oct 2009, 09:55

creating guides

Post by mathews » 15 May 2013, 18:23

Hi Genius,

I am using iMac
Mac OS X - version 10.6.8

Applescript Editor - version 2.3 (118)
Applescript 2.1.2

QuarkXpress - version 8

Jean-Marie Schwartz has wrote the below AS to find the tab positions in a paragraph and to create guides in that tab positions.

While I compile the script, it shows the syntax error as (expected end of line but found "reference") in the below line

set sel to the object reference of selection

Can anyone help me to fix this?


Below AS for your reference:

property ParagraphReturn : "
"

tell application "QuarkXPress"
tell document 1
set sel to the object reference of selection
set the_offset to offset of sel
if the_offset > 0 then
set the_text to (text from character 1 to character the_offset of story 1 of current box) as Unicode text
set oldDelims to AppleScript's text item delimiters
set AppleScript's text item delimiters to {ParagraphReturn}
set my_number to number of text items in the_text
set AppleScript's text item delimiters to oldDelims
else
set the_offset to (65536 + the_offset)
set the_text to (text from character 1 to character the_offset of story 1 of current box) as Unicode text
set oldDelims to AppleScript's text item delimiters
set AppleScript's text item delimiters to {ParagraphReturn}
set my_number to number of text items in the_text
set AppleScript's text item delimiters to oldDelims
end if
set {T, L, B, R} to bounds of current box as list
tell story 1 of current box
set the_paragraph_properties to properties of paragraph my_number
end tell
set the_tab_list to tab list of the_paragraph_properties
repeat with i from 1 to length of the_tab_list
set the_position to position of item i of the_tab_list
set the_position to ((the_position as number) + (L as number)) as vertical measurement
my CreateVerticalGuide(the_position)
end repeat
my Bip(2)
end tell
end tell

on Bip(x)
tell me to beep x
end Bip

on CreateVerticalGuide(guide_position)
tell application "QuarkXPress"
tell document 1
tell current page
make vertical guide at beginning with properties {position:guide_position}
end tell
end tell
end tell
end CreateVerticalGuide

Jean-Marie Schwartz
Posts: 1174
Joined: 23 Nov 2004, 04:30

creating guides

Post by Jean-Marie Schwartz » 15 May 2013, 21:27

Hi Mathews! Have you tried replacing the 2 following lines at the beginning of the script
set sel to the object reference of selection
set the_offset to offset of selwith the single one:
set the_offset to offset of the selection
Sorry I'm on v9 and could hardly make tests on v8. Let me know.

EDIT: Oops! sorry I just discovered your reply on the other forum.
So can you please try with this line:
set the_offset to offset of character 1 of the selection
Note that some text must be selected in order to run properly. I shall investigate further as to get elements only from the cursor position so you'd not have to select text but just place the cursor in the desired para. HTH!

Jean-Marie Schwartz
Posts: 1174
Joined: 23 Nov 2004, 04:30

creating guides

Post by Jean-Marie Schwartz » 15 May 2013, 21:59

Oh! Wait a minute! I think the following solution is better. Just hope it'll work in v8.

set sel to selection
set the_offset to offset of sel
It works here wether some text is selected or not. HTH.

mathews
Posts: 0
Joined: 20 Oct 2009, 09:55

creating guides

Post by mathews » 16 May 2013, 16:27

Hi Jean,

I tried it with and without selection. It quit my quark.

Replies shows as below:

tell application "QuarkXPress"
get selection of document 1
--> text from character 2 to character 25 of text flow 1 of text box 1 of document "Project1"
get offset of text from character 2 to character 25 of story 1 of text box 1 of document "Project1"
Result:
error "QuarkXPress got an error: Connection is invalid." number -609

Jean-Marie Schwartz
Posts: 1174
Joined: 23 Nov 2004, 04:30

creating guides

Post by Jean-Marie Schwartz » 16 May 2013, 20:57

Have you disabled EAText.xnt and other necessary XT's for scripting text in Quark?

mathews
Posts: 0
Joined: 20 Oct 2009, 09:55

creating guides

Post by mathews » 19 May 2013, 15:35

Im using version 8.1
I not found any EAText.xnt in my extension folder and my XTensions Disabled folder is null.

"other necessary XT's for scripting text in Quark"
I have no idea about XTensions folder. These are the list of XTension files found in my XTensions folder. Should anyone to be disabled from the list.

Bannerlines.xnt
Blacklining.xnt
Checksums.xnt
CompositionZone.xnt
Custom Bleeds.xnt
Dejavu.xnt
DocPorter.xnt
DropShadow.xnt
EditOriginal.xnt
ExtensisFontManagementQXT8.xnt
FitText.xnt
FullResPreview.xnt
GlyphPalette.xnt
Guide Manager Pro.xnt
Hyph_CNS_1.xnt
Hyph_CNS_2.xnt
Hyph_CNS_3.xnt
HyphDieckmann.xnt
Item FindChange.xnt
Item Styles.xnt
Jabberwocky.xnt
JobPalette.xnt
Kern-Track Editor.xnt
MPS Administrator.xnt
MPS Copy Grabber.xnt
MPS Tab Grabber.xnt
Overflow.xnt
PDF Filter.xnt
Scale.xnt
Scissors.xnt
Script.xnt
SEC ASCII.xnt
Shape of Things.xnt
SmartItems.xnt
Super Step and Repeat.xnt
TypeTricks.xnt
Vista.xnt
Word 6-2000 Filter.xnt
XPress Tags Filter.xnt

Jean-Marie Schwartz
Posts: 1174
Joined: 23 Nov 2004, 04:30

creating guides

Post by Jean-Marie Schwartz » 20 May 2013, 21:41

You should try disabling every 3rd party XTs (I can see you have quite a lot) and relaunch Quark then run the script. I suspect a XT conflict. Unless someone else states my code just does not work properly in v8 or v9 in other environment? Let me know for I'm curious about why it won't run at your end.

Post Reply

Return to “QuarkXPress 8, 9 & 10: AppleScript”