8.18/6/2018

Define (procedure)

This command creates a new local variable, or redefines an existing one. The define procedure must appear before the variable is actually used. PlanetPress Talk scripts require all variables to be defined either as a global variable in your document, or a local scope variable within your PlanetPress Talk script.

Syntax

define( name, type, value )

Arguments

name

The name of the variable, prefixed with the ampersand (&) character. The name must conform to the rules for names described in Names.

type

Constant value specifying the variable type, either integer, measure, string, Boolean, or an array type. The array types are color, arrayinteger, arraymeasure, arraycurrency, arrayBoolean, arraystring or directory. Once a type is assigned to a variable, it cannot be changed, unless the variable is redefined.

value

An initial value for the variable, of the same type as the variable (for example if the variable is of type integer, this value must be an integer). This value can also be a valid PlanetPress Talk expression. In the case of any array variable other than a color array or an array of type directory, the initial value can be either the number of elements you want the array to contain, or the set of values you want the array to contain. In the former case you assign values to the array elements in subsequent commands. In the latter case, you separate each value by a comma, and enclose the complete set of elements in square brackets. In the case of a string array, you must also quote each of the array elements. In an array of type directory, you specify the pathname to the folder and the file name filter you want to apply to each of the files in that folder; this in turn determines the number of elements in the array.

Code Sample Example


define( &customer_name, string, 'Smith' )
define( &invoice_number, integer, strtoint(@(1,1,10)) )
define( &left_margin, measure, 1.5 )
define( &is_bottom, boolean, (&current.line > 50) )
define( &my_array,arrayinteger,[12,3,76,109,4] )
define( &my_array,arrayinteger, 5 )
define( &prices,arraycurrency, 6)
define( &greetings,arraystring,['hello','bonjour','ola'] )
define( &mustard,color,[0,12,84,16] )
define( &image_paths, directory, 'c:\\images\\*.JPG' )
define( &cost, currency, 0.00 )