How to Create a System Variable

You can create your own system variable by selecting New -> System Variable from the File menu:

Let's say it is to be a dynamic variable which is part of an existing application. In this case you need to first write an evaluation LANSA function which calculates its value.

This example shows how to create a special variable, using a shipped 3GL program which allocates a next number, returning either a numeric or alpha value and storing the latest value. (There are two shipped evaluation programs: M@SYSDTA is used to define a variable which retrieves a value from a data area, M@SYSNUM is used to define a system variable which returns the next number in a series, as a numeric or character value.)

See Special Variables in the Technical Reference guide.

1.     Select New -> System -> System Variable from the File menu. Complete the New System Variable dialog based on the following. Note that system variable names must begin with * (asterisk).

Name

*MyNextNumber

Description

Next 7 digit Number

Derivation

Dynamic

Data type

Numeric

Length

7

Decimals

0

Program Type

3GL program

Program Name

M@SYSNUM

 

2.     Click Create to create the new system variable. This completes the definition.

3.     On the Repository tab, see Resources -> System Variables -> M to find your variable. System Variables are listed without their leading *.

4.     Refer to this system variable in your RDML code, like this, for example:

* assign next number to field STD_NUM
#std_num := *mynextnumber

        Note: The evaluation program maintains an internal SQL table which stores the "next number" value. An entry is created the first time the system variable is referenced.

See System Variables for use in System Evaluation Programs.