System Variables and System Functions

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:


System Variables

The following topics are covered below:

Purpose

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.

Characteristics of System Variables

The names of all system variables begin with an asterisk (*).

Format/Length

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

Content Modifiable

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.

System Variables Grouped by Function

The Natural system variables are grouped as follows:

For detailed descriptions of all system variables, see the System Variables documentation.

System Functions

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.

Example of System Variables and System Functions

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:

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

Further Examples of System Variables

See the following example programs:

Further Examples of System Functions

See the following example programs: