REPORTER 22.1

Script Objects

Script objects


Script objects are JavaScript scripts that REPORTER can run using an embedded JavaScript interpreter. REPORTER also extends JavaScript by defining a number of classes for things specific to REPORTER. See the JavaScript API reference manual for a reference to these classes.

To insert a script, select the Script tool and then click and drag an area on the page. This will draw the area that the Script item will occupy and then map the script window.

You can load a script into the window with the Load... button and save the script to file with the Save... button. Scripts do not make any output on the page themselves (i.e. the area on the page that the script occupies will not have anything drawn on it from the script) but they can create output indirectly. For example, a script could create an image using the Image class in REPORTER and then this image could be imported with an Image File object.

Scripts do become visible on the page if you select 'show as button in presentation view'. If this checkbox is selected, then the script will run when the user clicks on the button. If you also select 'do not run when template or page is generated', the script will only be run when the button is clicked.

You can select one Script object in your template to be run automatically when the template is opened. REPORTER will only automatically run the first Script object it finds with this checkbox selected.

As a simple example, the script above prints text to the logfile window using the LogPrint function (global class function). This doesn't do anything useful in itself but shows how you can produce useful diagnostic messages. This generates the following output in the logfile window:

For more information on scripting, see Scripting. See also Script File objects, which have all the same features as Script objects, except that they allow you to refer to an external script file rather than embedding your script directly in the template.