Natural Overview and Concepts
NATURAL is a programming language developed and marketed by Software AG.
NATURAL supports Rapid Application Development to RDBMS environments with applications that are portable, scaleable and interoperable across multiple computing platforms.
Applications developed using NATURAL are modular, which contributes to its success as a tool for Rapid Application Development. In general, each module is created, maintained and stored independently of any others.
Programs
The simplest type of module is a program. A program may be free-standing or may “call” lower level modules, such as subprograms and subroutines, that also contain executable code.
A NATURAL program can execute in either batch or on-line mode, with full access to database files.
Data definition
DEFINE DATA
.
END-DEFINE
READ Control logic
IF
PERFORM subroutine_1
END-IF
END-READ
DEFINE subroutine_1.
** Comments
END-SUBROUTINE
END END statement
Subprograms
Common logic (i.e. logic needed by multiple modules or multiple applications) is coded in subprograms so that it can be “called” as needed. For flexibility, parameter data can be passed directly between a subprogram and the “calling” routine. Using subprograms effectively avoids redundant code, so makes application maintenance
Subroutines
Subroutines are used to code discreet sub-functions to simplify logic and improve the readability and maintainability of the code.
There are 2 types of subroutines:
· in-line subroutines
· external subroutines
In-line subroutines
A program or subprogram will typically contain one or more in-line subroutines.
External subroutines
An external subroutine is the same as an in-line subroutine, except that it exists independently (in a module of type subroutine) and can be “called” from any other module.
Copycode
Copycode modules contain lines of source code that can be invoked at “compilation time” into programs, subprograms or external subroutines by means of an in-line INCLUDE statement.
Defining data
In NATURAL there are 2 ways to define data:
· in-line data definitions
· data definition modules
There are 3 types of data definition modules:
· local data areas (LDAs)
· parameter data areas (PDAs)
· global data areas (GDAs)
Data definition using a GDA
DEFINE DATA
GLOBAL USING INVDATA /* GDA FOR INVOICING APPLICATION
LOCAL USING INVREDEF /* LDA REDEFINING INVOICING GDA
.
END-DEFINE
For global data there is nothing equivalent to in-line definition.
Programs and external subroutines (including any in-line subroutines within them) have direct access to global data, whereas subprograms (including any in-line subroutines within them) do not.
An application, batch or on-line, can utilize a global data area (GDA) to store common data that is needed throughout the application. Since the data is stored in memory, access is very efficient.
Report
Edit masks
MOVE EDITED #INVOICE-AMT (EM=ZZZZZZ9.99-)
TO #INV-AMT
Display DISPLAY #DEPT-NBR #DOLLARS(#DEPT-NBR)
Write
DISPLAY statements are generally used only for casual output, e.g. during debugging. For more formatted output, such as a report, WRITE statements are generally preferred.
WRITE
#DEPT-NBR
7X
#DOLLARS(#DEPT-NBR) (EM=Z,ZZZ,ZZ9.99)