REPORTER 22.1

Creating a Variable Using an External Program/Script

Creating a variable using an external program/script

Rather than using the Variables window to create and define a variable it is also possible to use a program/script to create a variable. (See Appendix D  for some examples of programs/scripts)

When REPORTER generates a report and it runs an external program/script, any output lines that take the form

VAR <NAME> VALUE="<value>" DESCRIPTION="<description>"
or
VAR <NAME> VALUE="<value>"

will not inserted into the report as text but will be used to create a variable where

  • <NAME> - will become the variable name
  • <value> - will become the value of the variable
  • <description> - will become the variable description

here are a couple of examples

Program/Script Output
Variable Name
Description
Value
VAR DEFAULT_DIR VALUE="/data/test" DEFAULT_DIR (none) /data/test
VAR SPEED VALUE="1000" DESCRIPTION="Impact Speed" SPEED Impact speed 1000

So if you inserted a program/script object "Text output from a program/script" (see Program objects for more detail on inserting program/script objects) that's output was

VAR SPEED VALUE="1000"

then REPORTER would create a variable called SPEED with the value 1000, and because there is no other output then the inserted text object would come up blank when the report was generated. If the output however was

VAR SPEED VALUE="1000"
Impact Speed: %SPEED%

then REPORTER would create a variable called SPEED with the value 1000, and also create the following text object with the new variable SPEED substituted in.

Impact Speed: 1000

By default any variables that you read from an external program/script will be marked as "temporary". If you do not want the variable to be temporary then the variable name can appended with '!' and this will tell REPORTER not to mark it as temporary. Alternatively '#' can be used to mark the variable as temporary (although this is not needed as it is the default). For example the following two lines would both mark the variable SPEED as temporary (the default)

VAR SPEED VALUE="1000"
VAR SPEED# VALUE="1000"

The following line would mark the variable SPEED as not being temporary.

VAR SPEED! VALUE="1000"