webworks.com, a brand of Quadralay Corporation

1–877–8–WEBWORKS
1–877–893–2967
Contact Information

Online Manuals Previous Next Index Print
ePublisher AutoMap : Script Editor

Script Editor

ePublisher AutoMap includes a simple editor for specifying and writing job scripts. This editor includes a text area for writing or pasting your script and a list of useful ePublisher AutoMap variables that can be used in your scripts or passed to other scripts/applications to enhance its capabilities.

Script writing is not required to use ePublisher AutoMap. However, they provide a way to enhance ePublisher AutoMap’s capabilities and integration with other products or custom workflows.

Scripts can be specified to run before and after a job generates, before and after each target generates, and used to retrieve source documents on a per group basis. For more information on setting up jobs, please see Creating and working with project-based jobs and Creating and working with stationery-based jobs respectively.

To open the script editor:

2.

Click the appropriate Edit Script button to open the script editor window.

To edit the script:

2.

Type your script or paste (CTRL+V) from the clipboard.

To insert a ePublisher AutoMap scripting variable:

2.

Double click the variable name in the Script Variables pane to insert it

3.

Alternatively, you may type the variables name surrounded with ${ }. For example, to include the project directory variable in your script type ${ProjectDir}.

Writing scripts

Scripts may be written directly in the ePublisher AutoMap script editor window or cut and pasted from another text editor. Only text-based scripts are valid. Any formatting or additional information available in a third-party script editor will be lost when the script is pasted into the ePublisher AutoMap script editor window.

In essence, a script specified in ePublisher AutoMap is treated like a DOS batch file. The script must be complete and valid otherwise it will fail when the job generates. Although in many cases, the entire script can be written directly in the ePublisher AutoMap script editor window; this may not always be the best choice.

When calling complex scripts, it may be better to leave the heavy lifting in files stored on the file system and simply call those files from the ePublisher AutoMap script editor window. Since the ePublisher AutoMap script editor window treats the scripts like DOS batch files, you may call other batch files, applications, or scripts written in any scripting language such as VBS, Perl, Python, etc. Further, you may pass parameters to the files that you are calling including passing script variables as parameters.

Some variables only have meaning for certain types of scripts. For example, the DeployFolder variable is specific to a target and will not having meaning in a pre-build or post-build job script.

*

Please see Using scripting variablesfor more details on using ePublisher AutoMap scripting variables.

Working folder

Batch files on Windows are associated with a working folder. A working folder is the current working directory used by an application (or batch file) for processing. For example, if a batch file creates a new file without specifying a path, it will be created in the working folder. Similarly, if it attempts to read a file without a specifying a path, it is assumed to be in the working folder.

The working folder for a ePublisher AutoMap batch file is the job folder itself. This can always be located using the job directory ${JobDir} scripting variable. See Using scripting variables for more information on using ePublisher AutoMap scripting variables.

Scripting examples

The following are some scripting examples to show how the ePublisher AutoMap script editor may be used. This section includes the following examples:

Show time and date

The first example is trivial and simply displays the time and date in the log file by calling the time and date commands built into the DOS command line interface. In this case, the script was added as a pre-build step for the job running before the first target starts generating output.

In the output below, notice that the time and date appear before the first target begins generating. This information could be used to automatically timestamp a job log file or used in conjunction with other scripting to log elapsed time, make decisions, etc.

Using scripting variables

This example will create a simple “mini-report” inside the log file for each target in the job. It is a simple example demonstrating the use of the scripting variables. In this case, the values of the variables are displayed as part of the report using the echo command built into the DOS command line interface.

Notice the “mini-report” displayed immediately after the target starts to build. This same script could be added as a post-build step for the target and a similar “mini-report” would be generated upon completion of the target generated.

Revision control

The previous example scripts demonstrated some simple capabilities of using scripts in ePublisher AutoMap. This next script is an example of how to do something very useful when building ePublisher AutoMap jobs – checking out source files from a revision control system.

Revision control systems let you store files and retain information concerning different version of those files. Among other things, revision control systems provide for robust backups, reverting to previous versions of files, and sharing files among large groups of people. The advantage of using a revision control script to retrieve source files rather than adding them directly ensures that your job is always working with the latest available version of the source files.

There are many different revision control solutions each working a bit differently. ePublisher AutoMap is not tied to a specific revision control solution but rather provides an abstract way of retrieving a file list of source files to be converted. There are a few rules concerning how this list is named and formatted but the actual creation of the file list is left entirely up to the script and scriptwriter.

In fact, the scripting capabilities in the Documents panel are not limited to checking files out of a revision control system. The only requirement is that FileList.txt includes a list of file paths of files to be included. You may access the FileList.txt file and the path to it using the ePublisher AutoMap ${FileListName} and ${FileListPath} scripting variables accordingly. For more information on ePublisher AutoMap scripting variables, see Using scripting variables.

CVS checkout

The following script example calls getfilesaction_cvs.vbs which is installed as part of the ePublisher AutoMap installation. By default, this script is located in the follow path:

\Program Files\WebWorks\ePublisher AutoMap\Scripts\getfilesaction_cvs.vbs

getfilesaction_cvs.vbs is written using the Visual Basic Scripting (VBS) capabilities built into Microsoft Windows to check out files from a CVS (Concurrent Version System) server and create a file list to be processed by ePublisher AutoMap. This script is not meant to be used “as is” but is a starting point including everything necessary to set up a working script for your particular environment.

The getfilesaction_cvs.vbs script is completely documented and can be followed by someone who has scripting experience. Again, it is only a starting point. Minimally, you will need to set the CVS attributes for your user name, server name, and type of authentication, and adjust for how CVS is installed and called on your system. These areas of the script are highlighted below:

Below is a screenshot showing an example call of the getfilesaction_cvs.vbs script. The parameters passed indicate the module to checkout and to filter on the .doc extension. When this script runs, it checks out the indicated module from CVS, filters those files based on the .doc extension, and adds those .doc files to FileList.txt. That file list is then used for the AutoMap job conversion.

This is only one possible way of creating a file list of files to convert. Once you understand the mechanism that ePublisher AutoMap uses to retrieve its list of source documents to convert, you may create that list using any means you like. Whether that is a script or application, as long as it is accessible to ePublisher AutoMap, it may be invoked from the Script Editor panel.

Scripting variables

The following is a summary of the available script variables.

Variable

Description

Scope

FileListName

Returns the name of the file containing the source documents list.

Document scripts only.

FileListPath

Returns the directory path of the file containing the source documents list.

Document scripts only.

GroupName

Returns the documents group name that is currently being processed.

Document scripts only.

BuildAction

Returns whether the current build action is PreBuild or PostBuild.

Job scripts, target scripts, and document scripts.

JobDir

Returns the directory path of the job (.waj) file.

Job scripts, target scripts, and document scripts.

JobFile

Returns the directory path to the job file.

Job scripts, target scripts, and document scripts.

JobName

Returns the name of the job.

Job scripts, target scripts, and document scripts.

ProjectDir

Returns the directory path of the temporary project file that ePublisher AutoMap created for the job.

Job scripts, target scripts, and document scripts.

ProjectFile

Returns the file path of the temporary project file that ePublisher AutoMap created for the job.

Job scripts, target scripts, and document scripts.

DeployFolder

Returns the deployment directory path.

Target scripts only.

ErrorCount

Returns the number of errors reporting during generation.

Target scripts only.

TargetDeployKey

Returns the deploy target name.

Target scripts only.

TargetName

Returns the name of the target being generated.

Target scripts only.

TargetOutputDir

Returns the target’s directory path of the output.

Target scripts only.


Related Topics
 
ePublisher