These are some script fragments to create basic elements in InDesign and in Quark

  1. Essentials: The right record
  2. Essentials: Passing
  3. Graphics: New Document InD QXP
  4. Text: Simple Add Text InD QXP
  5. Text: Simple Get Text InD QXP
  6. Graphics: Simple Add Rectangle InD QXP
  7. Graphics: Simple Get Rectangle InD QXP
  8. Essentials: Close Documents InD QXP
  9. Graphics: Transform Reference Point InD QXP
  10. Conclusion: U. I. InD QXP

return

The right record

InD

When dealing with FileMaker from an AppleScript perspective it is necessary to tell it which record to get data from or set data to as well as which field (in AppleScript terms a 'cell'). Being in a record is not enough. Also note that fields must actually be on the current layout (or must be addressed with a 'tell layout' whatever its name or id is. The first 'set' command in the AppleScript uses the first record of the current found records. In the same way 'record 4' is the fourth. Both will change with the found set. To the left is the FileMaker script that runs the AppleScripts. It adds a 'tell' to address the current record.


 set myFirst to repetition 1 of cell "parameters"
 tell current record
  set mySecond to repetition 1 of cell "parameters"
  set myThird to repetition 2 of cell "parameters"
 end tell
 tell record 4
  set myFourth to repetition 1 of cell "parameters"
 end tell
 set myResult to {myFirst, mySecond, myThird, myFourth}
 --we quietly omitted the first record on opening. The next command runs a FileMaker script to show all. If you run the AppleScript again you will see different results.
 do script "showAll" -- A FileMaker script

return

Passing

InD

While one might well always pass a single parameter from an AppleScript variable to FileMaker Fields, we are using repeating fields to pass groups of parameters. In AS they will be stored as lists and in FP as repeating fields. btw the 'Clear' button above runs a simple AppleScript using this fact to clear all the repetitions in the returns field: tell current record set cell "returns" to {"", "", "", "", "", "", "", ""} end tell


 tell current record
  set fred to cell "parameters"
  set cell "returns" to reverse of fred
 end tell

return

New Document

InD

This creates a new document using whatever the default settings are.


tell application "Adobe InDesign CS2"
 activate
 set tempdoc to make new document --gives us a reference to the document
end tell

QXP


tell application "QuarkXPress"
 activate
 set tempdoc to make new document --gives us a reference to the document
end tell

return

Simple Add Text

InD

This adds a block of text, again using the default font, but setting the size and leading. It also sets the units to points (just in case yours are set to, say, inches The order for the bounds is: {top, left, bottom, right}


tell current record
 set myText to repetition 1 of cell "parameters"
end tell
 
tell application "Adobe InDesign CS2"
 activate
  tell view preferences
   set horizontal measurement units to points
   set vertical measurement units to points
  end tell
 set tempdoc to document 1 --gives us a reference to  an existing document
 tell tempdoc
  set tempbox to make text frame with properties {geometric bounds:{10.6, 131, 259.3, 548.7}, fill color:"None", contents:myText}
  set properties of every paragraph of tempbox to {point size:20, leading:26}
 end tell
end tell

QXP


tell current record
 set myText to repetition 1 of cell "parameters"
end tell

tell application "QuarkXPress"
 activate
 set tempdoc to document 1 --gives us a reference to an existing document
 tell tempdoc
  set horizontal measure to points
  set vertical measure to points
  set temppage to page 1 of tempdoc
  tell temppage
   --the guts of the script
   set tempbox to make text box at beginning with properties {class:text box, color:null, bounds:{10.6, 131, 259.3, 548.7} as points rectangle}
   tell tempbox
    set temptext to make new paragraph at beginning with properties {size:"20", leading:"26"}
    set text of temptext to myText
   end tell
   --the end of the guts of the script
  end tell
 end tell
end tell

return

Simple Get Text

InD

This gets text that we created in the previous step.


tell application "Adobe InDesign CS2"
 set tempdoc to document 1 
 tell tempdoc
  set myreturns to {"InD", contents of page item 1 of page 1, ""}
 end tell
end tell

QXP


tell application "QuarkXPress"
 set tempdoc to document 1 
 tell tempdoc
  set myreturns to {"QXP", "", text of text box 1 of page 1}
 end tell
end tell

return

Simple Add Rectangle

InD

This creates a rectangle with a given size and stroke.


tell application "Adobe InDesign CS2"
 activate
 set tempdoc to document 1
 tell tempdoc
  set tempbox to make rectangle with properties {geometric bounds:{200, 200, 300, 400}, stroke weight:3.0, stroke color:"Black"}
 end tell
end tell

QXP


tell application "QuarkXPress"
 activate
 set tempdoc to document 1
 tell tempdoc
  set tempbox to make picture box at end with properties {bounds:{"200 pt", "200 pt", "300 pt", "400 pt"} as points rectangle, frame:{width:"3.0 pt"}}
 end tell
end tell

return

Simple Get Rectangle

InD

This gets the bounds of the graphic that we created in the previous step.


tell application "Adobe InDesign CS2"
 set tempdoc to document 1
 tell tempdoc
  set myreturns to geometric bounds of rectangle 1 of page 1
 end tell
end tell

QXP


tell application "QuarkXPress"
 set tempdoc to document 1
 tell tempdoc
  set myreturns to (bounds of picture box 1 of page 1) as list
 end tell
end tell

return

Close Documents

InD

This closes the documents we were working with, without saving. Try is used for error trapping (we can have an "on error" handler to deal with any errors).


tell application "Adobe InDesign CS2"
 activate
 try
  close every document saving no
   --constants: ask, no, yes
 end try
end tell

QXP


tell application "QuarkXPress"
  activate
 try
  close every document saving no
 end try
end tell

return

Transform Reference Point

InD

Here we start to meet the bigger differences between InDesign and QuarkXpress’Äîthe InD script uses a concept that is absent from QXP. I happen to like being able to set the reference point for transformations and use it quite often. (In the QXP version the shell script used to set the view scale can cause problems (if, for example, it includes a refresh rate---as it did in the session :-) )


tell application "Adobe InDesign CS2"
 set tempdoc to make new document with properties {page height: "450 pt", page width: "700 pt"}
 activate
 tell tempdoc
  -- we make some guides so we can better see what's happening
  make new guide with properties {orientation:vertical, location:200}
  make new guide with properties {orientation:vertical, location:300}
  make new guide with properties {orientation:vertical, location:400}
  make new guide with properties {orientation:horizontal, location:200}
  make new guide with properties {orientation:horizontal, location:250}
  make new guide with properties {orientation:horizontal, location:300}
  --this is the guts of the script
  delay 2
  tell layout window 1
   set transform reference point to top left anchor
   --choices
   --top left anchor/top center anchor/top right anchor
   --left center anchor/center anchor/right center anchor
   --bottom left anchor/bottom center anchor/bottom right anchor
  end tell
  set tempbox to make rectangle with properties {geometric bounds:{200, 200, 300, 400}, stroke weight:3.0, stroke color:"Black"}
  delay 2
  rotate tempbox by 45
  delay 2
  tell layout window 1
   set transform reference point to bottom right anchor
  end tell
  set tempbox to make rectangle with properties {geometric bounds:{200, 200, 300, 400}, stroke weight:3.0, stroke color:"Black"}
  delay 2
  rotate tempbox by 45
  delay 2
  tell layout window 1
   set transform reference point to center anchor
  end tell
  set tempbox to make rectangle with properties {geometric bounds:{200, 200, 300, 400}, stroke weight:3.0, stroke color:"Black"}
  delay 2
  rotate tempbox by 45
  delay 2
 end tell
end tell


QXP


property pageSize : {450, 700}

tell application "QuarkXPress"
 activate
 set tempdoc to make new document --gives us a reference to the document
 tell tempdoc
  set horizontal measure to points
  set vertical measure to points
  set page height to ((item 1 of pageSize) as text) & "¬Ýpt"
  set page width to ((item 2 of pageSize) as text) & "¬Ýpt"
  set view scale to (((last word of (do shell script "system_profiler SPDisplaysDataType | grep Resolution") as number) - 250) * 100 / (item 1 of pageSize))
  tell page 1
   make new vertical guide at end with properties {position:200}
   make new vertical guide at end with properties {position:300}
   make new vertical guide at end with properties {position:400}
   make new horizontal guide at end with properties {position:200}
   make new horizontal guide at end with properties {position:250}
   make new horizontal guide at end with properties {position:300}
  end tell
  set tempbox to make picture box at end with properties {bounds:{"200 pt", "200 pt", "300 pt", "400 pt"} as points rectangle, frame:{width:"3.0 pt"}}
  delay 2
  set rotation of tempbox to 45
  display dialog "Sorry can't do the rest!" buttons "OK"
 end tell
end tell

return

U. I.

InD

You will often want to suppress the user interaction of scripts. This InD script could set the user interaction to the opposite of what it is ...I mean was ... but it makes more sense this way There is an intermediate level of "interact with alerts" which will display alerts but not dialogs and I haven't found a use for that yet. I have not been able to find anything similar in QXP


tell current record
 set myFlag to repetition 1 of cell "parameters"
end tell
tell application "Finder"
 set myFile to (choose file)
end tell

tell application "Adobe InDesign CS2"
 --if user interaction level of script preferences is never interact then
 --   (that would let you run this as a toggle)
 if myFlag is "interact" then
  set user interaction level of script preferences to interact with all
 else
  set user interaction level of script preferences to never interact
 end if
 set myResult to (user interaction level of script preferences) as text
 open myFile
end tell


QXP


tell application "Finder"
 set myFile to (choose file)
end tell

tell application "QuarkXPress"
 open myFile
 set myResult to "QXP ??"
end tell

return