Scripting in FrameMaker

What is scripting?

Scripting is a powerful tool that can be used to control and automate many features of Adobe FrameMaker—saving you so much time and effort that it can completely change the way you approach your work.

Why use scripting?

Your work is characterized by creativity, but many of the actual hands-on tasks are anything but creative. Most likely, you spend much time doing the same or similar procedures over and over again. Would it not be great to have an assistant—one that happily does the mind-numbing tasks, follows your instructions with perfect and predictable consistency, is available any time you need help, works at lightning speed, and never even sends an invoice? Scripting can be that assistant. With a small investment of time, you can learn to script the simple but repetitive tasks that eat up your time. However, while it’s easy to get started, FrameMaker scripts provide the necessary depth to handle sophisticated jobs. As your scripting skills grow, you may move on to more complex scripts that work all night while you’re sleeping.

Getting started with scripting

A script is a series of statements that tells an application to perform a set of tasks. The trick is writing the statements in a language that the applications understand. FrameMaker support ExtendScript as its scripting language.

There are two ways of running scripts: from within FrameMaker and by using the ExtendScript Toolkit (ESTK).

Run scripts from within FrameMaker

FrameMaker includes a menu entry that makes it easy to manage and run scripts.

  • To run a script:

    1. Click File > Script > Run.

    2. From the Script browser, select the script to be run.

    3. Click Open. The script is run from within FrameMaker.

  • To create a script:

    1. Click File > Script > New Script

    2. Compose your script in the ExtendScript TookKit (ESTK) that is opened.

    3. Save the script. Either run the script from within ESTK or run it from within FrameMaker.

Manage your scripts from within FrameMaker

FrameMaker includes a script catalog that allows you to easily manage your scripts. Launch the catalog from File > Script > Catalog.

The Catalog looks as follows:

Scripts Catalog

The catalog lets you manage favorite scripts, autorun scripts, and registered (notification) scripts.

Select the Favorites option in the catalog to manage your favorite scripts.

You can perform the following operations from this screen:

  • To add a script as a favorite, click Add. Select the script from the script browser and click Select. The script is then added as a favorite.

  • To remove a script from the Favorites list, select the script and then click Remove.

  • Click Refresh to refresh the list of favorite scripts.

  • To mark a script as an Autorun script, select the script and click Move To AutoRun. The script is then copied from its exiting location into the autorun (startup) folder.

Manage favorite scripts

Select the Favorites option in the catalog to manage your favorite scripts.

You can perform the following operations from this screen:

  • To add a script as a favorite, click Add. Select the script from the script browser and click Select. The script is then added as a favorite.

  • To remove a script from the Favorites list, select the script and then click Remove.

  • Click Refresh to refresh the list of favorite scripts.

  • To mark a script as an Autorun script, select the script and click Move To AutoRun. The script is then copied from its exiting location into the autorun (startup) folder.

Manage autorun scripts

Select the Autorun option in the catalog to manage your autorun scripts.

Autorun scripts are run automatically each time FrameMaker is launched. Any script that is placed in the following directories, becomes an autorun script.
  • <FrameMaker installation folder>\startup

  • <user's home folder>\startup

All scripts are run in alphabetical order.

You can perform the following operations:
  • To add a script as an autorun script, click Add. Select the script from the script browser and click Select. The script is then placed in the startup folder and added to the autorun list.

  • To delete a script from the autorun list, select the script and click Delete.

  • Click Refresh to refresh the list of favorite scripts.

Manage registered (notification) scripts

Select the Registered option in the catalog to manage your registered scripts. Registered scripts are also called as notification scripts. These scripts are run when the events for which they are registered are triggered.

Notification is the internal mechanism through which a script registered for a particular event is run when the event is triggered.

Any script that is registered to run when an event is triggered is displayed in the notifications list in the catalog.

To unregister a notification script, select the script and click Unregister. The script is then unregistered. Once a script is unregistered, the script is not run, when the event for which it was previously registered is triggered.

Note: To add a notification script, see the section on notifications in the appendix.

Other features

There are two features that are common to every script type that you can manage through the catalog: view and delete broken scripts and select, edit and run a script.

View and delete broken scripts

When a script that has already been added to the catalog is moved or deleted from its current location in the file system, it is termed as a broken script.

To view such scripts, select the Show Broken only option in the catalog. The catalog then displays all the scripts that are broken.

You can then delete such scripts from the catalog. When you delete a script, it is only deleted from the catalog and not from its location in the file system.

Select, edit, and run a script from the catalog
  • To run a script from within the catalog, select the script from the list and click Run.

  • To edit a script from within the catalog, select the script from the list and click Edit. The script is opened in the ExtendScript ToolKit editor.

  • To run a new script (not added to the catalog yet), select the option marked New and click Run. Then, select the script from the script browser and click Open.

Use the ExtendScript Toolkit

FrameMaker includes the ExtendScript ToolKit (ESTK). The ESTK is a development and debugging tool for ExtendScript scripts.

The ESTK has many features that make it easier to use than a text editor, including a built-in syntax checker that identifies where the problems are in your script and tries to explain how to fix them, and the ability to run your scripts right from the ESTK without saving the file.

All ExtendScript scripts are JavaScripts. The ESTK also includes a JavaScript debugger that allows you to:

  • Single-step through JavaScript scripts (JS or JSX files) inside an application.

  • Inspect all data for a running script.

  • Set and execute breakpoints.

Note: For more information on ESTK, navigate to http://www.adobe.com/devnet/scripting.
Note: For more information on using ESTK in Technical Communication Suite, see Working with ExtendScript, in the Technical Communication Suite Using Guide.