define
define
VARIABLE
,
VALUE

The define statement performs an assignment, much like an equals sign or the assign statement. However, the define statement only performs the assignment if the variable is currently undefined. If the variable already has a value, the define statement leaves it alone. The define statement is especially useful for initializing permanent variables.

Parameters

This statement has two parameters:

variable – is the name of the variable that you want to modify.

value – calculates the value that will be placed into the variable.

Description

This statement defines a value for a variable, unless that variable already has a value. In other words, this statement will initialize the variable if the variable’s value has not been defined yet, but if the variable already has a value it will not touch the value. (If the variable doesn’t exist at all, it is created as a fileglobal variable and given the specified value.)

The procedure below will initialize the variables DefaultAreaCode and TaxRate unless they have already been initialized.

    permanent DefaultAreaCode,TaxRate
    define DefaultAreaCode,"714"
    define TaxRate,4.25

In other words, if some other procedure has already assigned the DefaultAreaCode as 323 and the TaxRate as 8.25, this procedure will not change those values. But if the DefaultAreaCode and TaxRate have never been set, they will be initialized to 714 and 4.25.

See Also

- assign -- assigns a value to a field or variable.
- assignfield -- performs an assignment, much like an equals sign or the assign statement. However, the *assignfield* statement only performs the assignment to a database field, not to any variable.
- assignfieldwithsideeffects -- performs an assignment, much like an equals sign or the assign statement. However, the *assignfieldwithsideeffects* statement only performs the assignment to a database field, not to any variable. After performing the assignment, it will run any side effects associated with the field, including formulas and code associated with the field.
- assignfileglobal -- performs an assignment, much like an equals sign or the assign statement. However, the *assignfileglobal* statement only performs the assignment to a fileglobal variable.
- assignglobal -- performs an assignment, much like an equals sign or the assign statement. However, the *assignglobal* statement only performs the assignment to a global variable.
- assignlocal -- performs an assignment, much like an equals sign or the assign statement. However, the *assignlocal* statement only performs the assignment to a local variable.
- assignwindowglobal -- performs an assignment, much like an equals sign or the assign statement. However, the *assignwindowglobal* statement only performs the assignment to a windowglobal variable.
- fileglobal -- creates one or more fileglobal variables.
- let -- creates a local variable and assigns a value to it.
- letfileglobal -- creates a fileglobal variable and assigns a value to it.
- letglobal -- creates a global variable and assigns a value to it.
- letpermanent -- creates a permanent variable and assigns a value to it.
- letservervariable -- creates a server variable and assigns a value to it.
- letwindowglobal -- creates a windowglobal variable and assigns a value to it.
- set -- performs an assignment, much like an equals sign or the assign statement. However, the destination of the assignment can be calculated on the fly.
- setfield -- performs an assignment, much like an equals sign or the assign statement. However, the destination field of the assignment can be calculated on the fly.
- setglobal -- sets a value into a global variable. The name of the global variable is calculated on the fly.
- setlocal -- sets a value into a local variable. The name of the local variable is calculated on the fly.
- setlocalsfromdictionary -- converts a dictionary into a collection of local variables. The names and values of the local variables will be derived from the dictionary contents.

History

Version | Status | Notes
10.0 | No Change | Carried over from Panorama 6.0. (Note: In the 6.0 documentation it was not mentioned that define would create a fileglobal variable if the specified variable didn't exist at all.)