G’day
I’ve struck a real hassle with a routine for gang printing to Quark.
The script runs fine as a script, but as a part of an application, it crashes.
I’ve marked the line below, variable theRef as part of the on Size_ThisGroup() subroutine, but I’m also finding the same problem with the Thisbox variable.
The error message is … Can’t make <> into type real
Any suggestions welcome.
Regards
Santa
-->> Handlers
on Make_PicBox(ThisPicture)
tell application "QuarkXPress Passport"
tell document DocName
set QuarkError to false
tell current page
try
set PicBox to make new picture box at end with properties {bounds:{Top_Origin, Left_Origin, Top_Origin + Size_Origin, Left_Origin + Size_Origin}}
tell PicBox
set image 1 to file ((ThisPicture) as text)
set PicBounds to (bounds of image 1)
set TheWidth to item 3 of PicBounds
set TheHeight to item 4 of PicBounds
set width of bounds to TheWidth
set height of bounds to TheHeight
set runaround to none runaround
end tell
on error
-- in case we strike crook file
set QuarkError to true
return {PicBox, 1 as real, 1 as real}
end try
end tell
end tell
end tell
try
return {PicBox, TheHeight as real, TheWidth as real}
on error
display dialog TheHeight & " " & TheWidth as string
end try
end Make_PicBox
on Make_CropMarks(ThisBox)
tell application "QuarkXPress Passport"
tell document DocName
tell current page
try
--copy (coerce (bounds of ThisBox as points rectangle) to list) to {T, L, B, R}
set temp to (coerce (bounds of ThisBox as points rectangle) to list)
copy temp to {T, L, B, R}
set T to T as real
set L to L as real
set B to B as real
set R to R as real
set L1 to L - CropMarks_Offset - CropMarks_Length
set L2 to L - CropMarks_Offset
set R1 to R + CropMarks_Offset
set R2 to R + CropMarks_Offset + CropMarks_Length
set T1 to T - CropMarks_Offset - CropMarks_Length
set T2 to T - CropMarks_Offset
set B1 to B + CropMarks_Offset
set B2 to B + CropMarks_Offset + CropMarks_Length
set Crop1 to make new line box at end with properties {start point:{T, L1}, end point:{T, L2}, width:CropMarks_Thickness}
set Crop2 to make new line box at end with properties {start point:{T, R1}, end point:{T, R2}, width:CropMarks_Thickness}
set Crop3 to make new line box at end with properties {start point:{B, L1}, end point:{B, L2}, width:CropMarks_Thickness}
set Crop4 to make new line box at end with properties {start point:{B, R1}, end point:{B, R2}, width:CropMarks_Thickness}
set Crop5 to make new line box at end with properties {start point:{T1, L}, end point:{T2, L}, width:CropMarks_Thickness}
set Crop6 to make new line box at end with properties {start point:{B1, L}, end point:{B2, L}, width:CropMarks_Thickness}
set Crop7 to make new line box at end with properties {start point:{T1, R}, end point:{T2, R}, width:CropMarks_Thickness}
set Crop8 to make new line box at end with properties {start point:{B1, R}, end point:{B2, R}, width:CropMarks_Thickness}
on error TheError number errNum
set Crop1 to make new line box at end with properties {start point:{0, 0}, end point:{0, 0}, width:CropMarks_Thickness}
set Crop2 to make new line box at end with properties {start point:{0, 0}, end point:{0, 0}, width:CropMarks_Thickness}
set Crop3 to make new line box at end with properties {start point:{0, 0}, end point:{0, 0}, width:CropMarks_Thickness}
set Crop4 to make new line box at end with properties {start point:{0, 0}, end point:{0, 0}, width:CropMarks_Thickness}
set Crop5 to make new line box at end with properties {start point:{0, 0}, end point:{0, 0}, width:CropMarks_Thickness}
set Crop6 to make new line box at end with properties {start point:{0, 0}, end point:{0, 0}, width:CropMarks_Thickness}
set Crop7 to make new line box at end with properties {start point:{0, 0}, end point:{0, 0}, width:CropMarks_Thickness}
set Crop8 to make new line box at end with properties {start point:{0, 0}, end point:{0, 0}, width:CropMarks_Thickness}
set QuarkError to true
end try
end tell
end tell
end tell
return {Crop1, Crop2, Crop3, Crop4, Crop5, Crop6, Crop7, Crop8}
end Make_CropMarks
on Make_LabelBox(FromHeight, BoxWidth, ThisLabel)
tell application "Finder"
set ThisLabel to name of file ThisLabel
end tell
tell application "QuarkXPress Passport"
set ParaStyle to object reference of style spec "Label" of document DocName
tell document DocName
tell current page
set TextBox to make new text box at end with properties {bounds:{FromHeight, Left_Origin, FromHeight + LabelHeight, Top_Origin + BoxWidth}}
tell TextBox
try
set contents of story 1 to ThisLabel
set style sheet of paragraph 1 of story 1 to ParaStyle
set runaround to none runaround
end try
end tell
end tell
end tell
end tell
return TextBox
end Make_LabelBox
on Size_ThisGroup()
tell application "QuarkXPress Passport"
display dialog "Size thisgroup"
tell document DocName
set TheRef to (object reference of selection)
display dialog 2
-- This line below crashes
set PlacingWidth to (width of bounds of TheRef) as real
display dialog 3
set PlacingHeight to (height of bounds of TheRef) as real
display dialog 4
my DoMenu("Edit", "Cut")
end tell
set end of QuarkFileList to ThisItem as string
set end of QuarkSizeList to (PlacingWidth as integer)
set end of QuarkAreaList to PlacingWidth * PlacingHeight
set end of QuarkPrintedList to false
end tell
end Size_ThisGroup
on Place_ThisGroup(ThisFile)
tell application "QuarkXPress Passport"
tell document DocName
set TheRef to (object reference of selection)
set PlacingWidth to (width of bounds of TheRef) as real
set PlacingHeight to (height of bounds of TheRef) as real
my DoMenu("Edit", "Cut")
set Place_Found to false
repeat with ThisPage from 1 to Page_Spaces's length
set SpaceList to (item ThisPage of Page_Spaces)
if Place_Found is false then
repeat with PlaceIndex from 1 to SpaceList's length
set ItsTop to TheTop of item PlaceIndex of SpaceList
set ItsLeft to TheLeft of item PlaceIndex of SpaceList
set ItsWidth to TheWidth of item PlaceIndex of SpaceList
set ItsHeight to TheHeight of item PlaceIndex of SpaceList
if PlacingWidth ≤ ItsWidth and PlacingHeight ≤ ItsHeight then
set Place_Found to true
-- Remove used space from available space of that page
set (item ThisPage of Page_Spaces) to my DeleteItem(PlaceIndex, item ThisPage of Page_Spaces)
-- Separates the space vertically at Item's width and create remaining free space infos
if PlacingWidth < ItsWidth then -- There will be some free space to the right after placement
set FreeSpaceRight to {TheTop:ItsTop, TheLeft:ItsLeft + PlacingWidth, TheWidth:ItsWidth - PlacingWidth, TheHeight:ItsHeight}
set end of (item ThisPage of Page_Spaces) to FreeSpaceRight
end if
if PlacingHeight < ItsHeight then -- There will be some free space to the bottom after placement
set FreeSpaceDown to {TheTop:ItsTop + PlacingHeight, TheLeft:ItsLeft, TheWidth:PlacingWidth, TheHeight:ItsHeight - PlacingHeight}
set end of (item ThisPage of Page_Spaces) to FreeSpaceDown
end if
exit repeat
end if
end repeat
end if
end repeat
if Place_Found is true then
set QuarkPrintedFlag to true
set current page to page ThisPage
my DoMenu("Edit", "Paste")
do updates
my DoMenu("Item", "Group")
set TheRef to (object reference of selection)
set origin of bounds of TheRef to {ItsTop, ItsLeft}
set QuarkRunningPrintedArea to QuarkRunningPrintedArea + (PlacingWidth * PlacingHeight)
set item QuarkCounter of QuarkPrintedList to true -- Set true that it's placed on page
else
tell application "Finder"
if not (exists folder "Quark Printing Holding" of folder Mail_Printing_Folder) then make new folder at Mail_Printing_Folder with properties {name:"Quark Printing Holding"}
move file (ThisFile) to folder "Quark Printing Holding" of folder Mail_Printing_Folder
if (count of (get every file of folder SourceFolder)) = 0 then
my moveFromHoldingFolder()
if QuarkPrintedFlag then my GoAndPrintQuark()
else
--do nuttin...
end if --
end tell
end if
end tell
end tell
end Place_ThisGroup
on SetTool(This_Tool)
tell application "QuarkXPress Passport"
tell document DocName
if This_Tool is "Contents" then
set tool mode to contents mode
else if This_Tool is "Drag" then
set tool mode to drag mode
end if
end tell
end tell
end SetTool
on DoMenu(This_Menu, This_SubMenu)
tell application "QuarkXPress Passport"
try
select menu item This_SubMenu of menu This_Menu
on error errMsg number errNum
display dialog ("An error " & errNum & " has occured" & return & return & errMsg) with icon stop
end try
end tell
end DoMenu
Model: intel 24" iMac
Browser: Safari 525.20
Operating System: Mac OS X (10.5)