DEFSYSV

The DEFSYSV procedure creates a new system variable called Name initialized to Value .

Calling Sequence

DEFSYSV, Name, Value [, Read_Only]

Arguments

Name

A scalar string containing the name of the system variable to be created. All system variable names must begin with the character `!'.

Value

An expression from which the type, structure, and initial value of the new system variable is taken. Value can be a scalar, array, or structure.

Read_Only

If the Read_Only argument is present and nonzero, the value of the newly-created system variable cannot be changed (i.e., the system variable is read-only, like the !PI system variable). Otherwise, the value of the new system variable can be modified.

Keywords

EXISTS

Set this keyword to a named variable that returns 1 if the system variable specified by Name exists. If this keyword is specified, Value can be omitted. For example, the following commands could be used to check that the system variable XYZ exists:

DEFSYSV, '!XYZ', EXISTS = i

IF i EQ 1 THEN PRINT, '!XYZ exists' ELSE PRINT, '!XYZ does not exist'

Example

To create a new, floating-point, scalar system variable called !NEWVAR with an initial value of 2.0, enter:

DEFSYSV, '!NEWVAR', 2.0

You can both define and use a system variable within a single procedure:

PRO foo

DEFSYSV, '!foo', 'Rocky, watch me pull a squirrel out of my hat!';

PRINT, !foo; Print !foo; after defining it.

END

See Also

.