QuarkXpress Script Problems

I’m writing an applescript to automate the placement of labels on photographs in our publication. I have two questions if anyone has QuarkXpress scripting experience.

  1. This script runs fine when a left hand page is selected. When a right hand page is selected, it crashes. Anyone have problems with Left vs Right hand pages in a script?

  2. In two different places in the script I read a value and then essentially am looking up a value to define a variable. The only way I can think to do it is in an “If Then, Else If” section. Is there a way to create a “lookup table” that would be more efficient.

Thanks for the help. Script is below.
Mike Milchanowski

set myInterval to 1 
set numObjects to text returned of (display dialog "How many aerial objects would you like?" default answer "1") as integer 
repeat numObjects times 
if myInterval = 1 then 
set myOrigin to {"1"", "1""} 
else if myInterval = 2 then 
set myOrigin to {"1.25"", "1""} 
else if myInterval = 3 then 
set myOrigin to {"1.5"", "1""} 
end if 
set myName to text returned of (display dialog "Named Aerial Object" default answer "") 
set myChar to (count characters of myName) as integer 
if myChar = 1 then 
set myWidth to ".312"" 
else if myChar = 2 then 
set myWidth to ".322"" 
else if myChar = 3 then 
set myWidth to ".335"" 
else if myChar = 4 then 
set myWidth to ".463"" 
else if myChar = 5 then 
set myWidth to ".518"" 
else if myChar = 6 then 
set myWidth to ".562"" 
else if myChar = 7 then 
set myWidth to ".638"" 
else if myChar = 8 then 
set myWidth to ".668"" 
else 
set myWidth to "2"" 
end if 
tell application "QuarkXPress" 
set myProj to get project 1 
tell layout space 1 of project 1 
tell current page 
make new text box at beginning with properties {class:text box, color:color spec "Black" of myProj, locked:false, rotation:"0°", runaround:none runaround, selected:true, shade:"100%", box shape:rounded corner, suppress printing:false, text outset:{"1 pt", "1 pt", "1 pt", "1 pt"}, bounds:{"1"", "1"", "1.158"", "2.5""}, corner radius:"0.125"", skew:"0°", columns:1, first baseline minimum:ascent baseline, first baseline offset:"0"", gutter:"0.167"", inter para max:"0"", runaround all sides:false, text angle:"0°", text inset:"2 pt", text skew:"0°", vertical justification:centered} 
tell text box 1 
set width of bounds to myWidth 
set origin of bounds to myOrigin 
end tell 
tell story 1 of text box 1 
set contents of it to myName 
set properties to {base shift:"-1.05 pt", color:color spec "White" of myProj, font:"FrnkGothITC Dm BT", horizontal scale:"100%", shade:"100%", size:"8 pt", justification:centered} 
end tell 
end tell 
end tell 
end tell 
set myInterval to myInterval + 1 
end repeat