Write your own FrameMaker ExtendScript, Part 2
In January, long-time FrameMaker maven, Rick Quatro of Carmen Publishing, did a guest appearance in the second of a 2-part series on FrameMaker ExtendScripts. You may view the recording of “FrameMaker: How to write your own ExtendScripts, Part 2” here.
This session (Part 2) continues the process of creating a broadly useful ExtendScript for automating common tasks in FrameMaker, step-by-step. You can get a recording of the session here.
Please also see our blog post for Part 1 of the session here.
NOTE: This session displays a “Files” pod, which enables you to download the actual script that Rick is creating, for your own hands on.
Minute Markers for key highlights in the webinar recording “FrameMaker: How to write your own ExtendScript, Part 2”
Identify which SW you are targeting (e.g. FrameMaker, not InDesign)
Determining insertion point for insertion of a variable
Object Model Viewer to see Classes and Properties/Methods available in ExtendScript
Using the fm12 Object Reference 1.0 *.chm file, which lists QuickLinks to “methods” or what behaves like VERBS
PROPERTIES describe relevant document properties necessary for letting a method work.
NewAnchoredFormattedVar (can copy the sample code and then fill-in the blanks)
var modDate so it will use “Modification Date (Long)” as the format
Specifying text location:- a paragraph - “0” to indicate beginning of the paragraph
Commenting out the first working task, so the 2nd task can be created and tested separately
Creating a temporary text frame and manually inserting a DATE system variable so format of date can be inserted into a marker
NewTextFrame object. Noting that this can have a parent object (e.g. an Anchored Frame)
Pop-up menu of hints appears as you type in your definition for a method
Demonstration of the process for selecting an appropriate parent object
Designating a text location within a temporary textframe. Goal: get the textframe and the variable within the textframe.
Locating the “delete” method to be used to delete a temporary textframe with DATE variable that is used to establish current time in specified format.
getSystemVariableValue (Goal is to have a generic “get system variable” that would work with any system variable. Variables are made of building blocks … and their order counts.
Getting the value from a system variable via script … demonstrating a successful text
After testing functions for VARIABLES, cluster them together towards the top of the script
Using an “alert” to have retrieved variable value DISPLAY in a pop-up menu
MetaModDate markers need to be deleted at end of process
Running test of the final script – marker has been inserted with current date in desired format (extracted from a SYSTEM VARIABLE) … and temporary TEXTFRAME has been deleted.
Running script a 2nd time, we get a 2nd marker with a new current time.
Now have desire to delete the previous markers if you need to update insertion of marker with current time in it.
What to do if there is no “current active” document
Testing the script when there is no active document. Code on line 13 of script will invoke a pop-up menu alerting you to need for an open/active document
Example of a minor failure because PGF object has not been created.
WHERE DO YOU SAVE PORTIONS OF SCRIPTS TO BE REUSEDRick uses FileLocator Pro
FINAL SCRIPT DEMO … Rick creates a script that deals with the document that has multiple, redundant markers at the beginning of the first paragraph in the document. Specify the type of marker (name) to determine if it should be deleted … this creates a “loop” …
Get the full recordings of Part 1 and Part 2 of our webinars “FrameMaker: How to write your own ExtendScripts” here: