||This article only describes one highly specialized aspect of its associated subject. (November 2012)|
||This article focuses too much on specific examples without clearly discussing its abstract general subject. (November 2012)|
|This article does not cite any references (sources). (November 2012)|
Natural is an English-like fourth-generation programming language from Software AG (SAG). It is largely used to access and maintain data in SAG's database management system (DBMS), ADABAS, although Natural can also be used with other DBMS's like DB2, and VSAM.
The first version of Natural was Natural 1, a query language for ADABAS.
Natural 2 is a more complete, COBOL-like, programming language.
* Hello World in NATURAL WRITE 'Hello World!' END
Natural is English-like in that the statements (instructions) are defined using English words, rather than symbols.
For example: MOVE #A TO #B
This line of Natural code sets the variable #B to the value of the variable, #A.
Control flow Statements
- DECIDE ON VALUE OF variable
- DECIDE FOR CONDITION
- PERFORM subroutine (internal or external)
- REPEAT WHILE
- REPEAT UNTIL
- ESCAPE BOTTOM (label.)
- ESCAPE TOP
- ESCAPE ROUTINE
- ESCAPE PROGRAM
Natural has the
ESCAPE TOP flow control instruction, similar to the continue statement of many other languages, which continues execution at the next iteration of the innermost loop containing it.
DEFINE DATA LOCAL 1 I (N3) /* 3 digits without decimals END-DEFINE FOR I = 2 TO 100 IF (I / 2 * 2) = I AND I > 2 WRITE 'Number' I 'is divisible by 2' ESCAPE TOP END-IF IF (I / 3 * 3) = I AND I > 3 WRITE 'Number' I 'is divisible by 3' ESCAPE TOP END-IF IF (I / 5 * 5) = I AND I > 5 WRITE 'Number' I 'is divisible by 5' ESCAPE TOP END-IF IF (I / 7 * 7) = I AND I > 7 WRITE 'Number' I 'is divisible by 7' ESCAPE TOP END-IF IF (I / 11 * 11) = I AND I > 11 WRITE 'Number' I 'is divisible by 11' ESCAPE TOP END-IF WRITE 'Number' I 'is prime' END-FOR END
ESCAPE BOTTOM command terminates the innermost containing loop, similar to other languages' exit or break statement, unless the ESCAPE BOTTOM statement includes reference to a label or line number.
Natural's has a structured case statement,
DECIDE ON FIRST VALUE MARITAL-STATUS VALUE 'M' ASSIGN DESC = 'Married' VALUE 'D' ASSIGN DESC = 'Divorced' VALUE 'W' ASSIGN DESC = 'Widowed' ANY ASSIGN ONCE-MARRIED = TRUE NONE ASSIGN DESC = 'Single' END-DECIDE