Re: newbie to Quark Scripting
Re: newbie to Quark Scripting
- Subject: Re: newbie to Quark Scripting
- From: Hans Haesler <email@hidden>
- Date: Fri, 20 Apr 2001 21:30:57 +0200
On Fri, 20 Apr 2001, Barry Conner wrote:
>
As an experiment to get my feet wet, I'm interested in making a small script >that will do within the open (or dropped upon applet?) document: - create a >small text box at the lower left hand corner of page 1 and plop in there the >time, date, and path/location of the document. So, to get started, I need to >know how to create a new text box in a specific location. Suggestions for >appropriate resources are much appreciated.
Barry,
a very simple task... but there are some pit-falls:
- the measurement units: you may think "points" but the document
is in inches. The box would be huge.
- the Item Coordinates: when set to "Spread" instead of "Page", the
box may be created on the paste-board when "facing pages" is true.
- the Page Rule Origin: must be zero/zero, else the box could be
created anywhere but on the desired position.
- get the file path: if you don't use a specific form (see below) then
you can't save the document anymore (unless you restart the app)
- get the modification date: must be done outside of the XPress tell block.
(or do you mean the current date?)
---
tell document 1 of application "QuarkXPress 4.11"
--bring QXP to the front
activate
--initialize flags
set isc to 0
set mes to 0
--get the Measurement Units
set vMes to vertical measure as text
set hMes to horizontal measure as text
--if the units are not in points, set the flag to 1, but don't change
--the units, yet
if vMes is not "UPNT" or hMes is not "UPNT" then
set mes to 1
end if
--if the Item Coordinates are not set to "Page" then set the flag to 1
if item spread coords = true then set isc to 1
--change the properties in one sweep, depending on the flags
--(the reason for this: the document "jumps" only once)
if isc = 1 and mes = 1 then
set properties to {vertical measure:points, horizontal measure:points, item spread coords:false}
else if isc = 0 and mes = 1 then
set properties to {vertical measure:points, horizontal measure:points}
else if isc = 1 and mes = 0 then
set item spread coords to false
end if
--get the page rule origin
set pRO to page rule origin as list
set pROy to item 1 of pRO as real
set pROx to item 2 of pRO as real
--if the page rule origin is not {0.0, 0.0} then we must set it to zero,
--else the box will not be placed at the correct position
if pROy is not 0 or pROx is not 0 then set page rule origin to {0, 0}
--get the path of the document
--Warning: don't remove neither the 'get' nor the parentheses,
--else you can't save the document anymore. You must quit and restart
--XPress to restore things
set docPath to (get file path) as text
--initialize the variable
set modDate to ""
--call the handler for getting the modification date
try
set modDate to my getModDate(docPath, modDate)
on error
set modDate to "Not registered"
end try
--get the page height. We need this as "start value" for the box
set pHeight to page height as point units as real
--create the box, name it, so it can be addressed easier
--Note: the 'bounds' is a rectangle of four values {Y1, X1, Y2, X2}
--that's right: top of bounds is the first value, then left of bounds,
--right of bounds and bottom of bounds.
--'at beginning' creates the box in front of the others and is required
--'at end' would create the box at the very back
tell page 1
make text box at beginning with properties {bounds:{pHeight - 32, 12, pHeight - 12, 252}, name:"doc_info"}
end tell
--fill the info in the box
copy modDate & return & docPath to after paragraph 1 of text box "doc_info"
tell text box "doc_info"
--change the size and the leading of the text
tell story 1
set properties of every paragraph to {size:8, leading:9}
end tell
end tell
--restore, if necessary, the Measurement Units and the Item Coordinates
if mes = 1 then
if isc = 0 then
set properties to {vertical measure:vMes, horizontal measure:hMes}
else if isc = 1 then
set properties to {vertical measure:vMes, horizontal measure:hMes, item spread coords:true}
end if
else if mes = 0 then
if isc = 1 then
set item spread coords to true
end if
end if
end tell
--get the modifiaction date of the document
on getModDate(p, d)
set d to (modification date of (info for file p)) as text
end getModDate
---
If you need to batch process your documents: the droplet is ready, but
I don't want to add it to this message...
>
other question:
>
Is Quark 4.11 attachable, i.e. can I put a reference to the script on a quark >menu or toolbar?
My choice is: save the script as run-only version and put it in the
QuarkXPress Scripts Folder created by OSA Menu.
HTH,
Hans
---
Hans Haesler | email@hidden