This document describes the purpose of Natural system variables and Natural system functions and how they are used in Natural programs.
The following topics are covered:
The following topics are covered below:
System variables are used to display system information. They may be referenced at any point within a Natural program.
Natural system variables provide variable information, for example, about the current Natural session:
the current library;
the user and terminal identification;
the current status of a loop processing;
the current report processing status;
the current date and time.
The typical use of system variables is illustrated in the Example of System Variables and System Functions below and in the examples contained in library SYSEXPG.
The information contained in a system variable may be used in Natural
programs by specifying the appropriate system variables. For example, date and
time system variables may be specified in a DISPLAY
,
WRITE
,
PRINT
,
MOVE
or
COMPUTE
statement.
The names of all system variables begin with an asterisk (*).
Information on format and length is given in the detailed descriptions in the System Variables documentation. The following abbreviations are used:
Format | |
---|---|
A | Alphanumeric |
B | Binary |
D | Date |
I | Integer |
L | Logical |
N | Numeric (unpacked) |
P | Packed numeric |
T | Time |
In the individual descriptions, this indicates whether in a Natural program you can assign another value to the system variable, that is, overwrite its content as generated by Natural.
The Natural system variables are grouped as follows:
For detailed descriptions of all system variables, see the System Variables documentation.
Natural system functions comprise a set of statistical and mathematical functions that can be applied to the data after a record has been processed, but before break processing occurs.
System functions may be specified in a DISPLAY
,
WRITE
,
PRINT
,
MOVE
or
COMPUTE
statement
that is used in conjunction with an AT
END OF PAGE
, AT END
OF DATA
or AT
BREAK
statement.
In the case of an AT END OF PAGE
statement, the
corresponding DISPLAY
statement must include the
GIVE SYSTEM
FUNCTIONS
clause (as shown in the example
below).
The following functional groups of system functions exist:
For detailed information on all system functions available, see the System Functions documentation.
See also Using System Functions in Processing Loops (in the System Functions documentation).
The typical use of system functions is explained in the example programs given below and in the examples contained in library SYSEXPG.
The following example program illustrates the use of system variables and system functions:
** Example 'SYSVAX01': System variables and system functions ************************************************************************ DEFINE DATA LOCAL 1 MYVIEW VIEW OF EMPLOYEES 2 CITY 2 NAME 2 JOB-TITLE 2 INCOME (1:1) 3 CURR-CODE 3 SALARY 3 BONUS (1:1) END-DEFINE * WRITE TITLE LEFT JUSTIFIED 'EMPLOYEE SALARY REPORT AS OF' *DAT4E / * READ (3) MYVIEW BY CITY STARTING FROM 'E' DISPLAY GIVE SYSTEM FUNCTIONS NAME (AL=15) JOB-TITLE (AL=15) INCOME (1:1) AT START OF DATA WRITE 'REPORT CREATED AT:' *TIME 'HOURS' / END-START AT END OF DATA WRITE / 'LAST PERSON SELECTED:' OLD (NAME) / END-ENDDATA END-READ * AT END OF PAGE WRITE 'AVERAGE SALARY:' AVER (SALARY(1)) END-ENDPAGE END
Explanation:
The system variable
*DATE
is output with the WRITE
TITLE
statement.
The system variable
*TIME
is output with the AT START OF
DATA
statement.
The system function OLD
is used in the
AT END OF DATA
statement.
The system function AVER
is used in the
AT END OF PAGE
statement.
Output of Program SYSVAX01:
Note how the system variables and system function are displayed.
EMPLOYEE SALARY REPORT AS OF 11/11/2004 NAME CURRENT INCOME POSITION CURRENCY ANNUAL BONUS CODE SALARY --------------- --------------- -------- ---------- ---------- REPORT CREATED AT: 14:15:55.0 HOURS DUYVERMAN PROGRAMMER USD 34000 0 PRATT SALES PERSON USD 38000 9000 MARKUSH TRAINEE USD 22000 0 LAST PERSON SELECTED: MARKUSH AVERAGE SALARY: 31333
See the following example programs:
EDITMX05 - Edit mask (EM for date and time system variables)
READX04 - READ (in combination with FIND and the system variables *NUMBER and *COUNTER)
See the following example programs: