REPORTER 22.1

Adding Scripts to the Library

Adding Scripts to the library

REPORTER has a JavaScript interpreter built into it. The scripts which are available in the library are run inside REPORTER.

To add a new script to the library save it into the scripts directory of your Library. Then you need to add the following special comment at the top of the file:

/* A description of your script

PROGRAM::<script_name>
DESC::<description>
FOLDER::<folder>                            (optional)
RETURN::<output_type>
[+-]ARG::<description>[::<default text>]    (repeat for as many arguments as required)
EXPAND_ARGS::false                          (optional)
END_INFO
*/

Note the /* at the beginning and */ at the end.

The lines have the following meaning:

PROGRAM <script_name> is the name of the JavaScript program. It should have the extension js
DESC <description> is a description of the program/script that will appear in the Insert program from library window
FOLDER The programs in the Insert program from library window are shown in a 'tree' view. <folder> indicates which folder or 'branch' of the tree the program is shown in. This is the same as for library pages above.
RETURN <output_type> is the type of output the program returns. Currently the only value supported is text .
ARG <description> is the argument description that will appear in the Insert program from library window. Optionally the line can be prefixed with a + or - sign. If a - sign is used the argument is optional. If a + sign is used (default) the argument is mandatory. Optionally an argument can be followed by <default_text> which will be used as a default for the argument in the window.
EXPAND_ARGS Normally any variables in program arguments get expanded to their actual values and so you would omit this line. There may be instances where you do not want to expand them. In this case use the line EXPAND_ARGS::false (e.g. see data_file_from_variables.js).
END_INFO This line indicates the end of the informat and must be included

For example, the following lines

/*
PROGRAM::example.js
DESC::Example program
FOLDER::examples/programs
RETURN::text
ARG::argument1::default1
ARG::argument2
-ARG::argument3::default3
END_INFO
*/

would give the output: