NATURAL
Encyclopedia
NATURAL is a fourth-generation programming language
Fourth-generation programming language
A fourth-generation programming language is a programming language or programming environment designed with a specific purpose in mind, such as the development of commercial business software. In the history of computer science, the 4GL followed the 3GL in an upward trend toward higher...

 from Software AG
Software AG
Founded in 1969, Software AG is an enterprise software company with over 10,000 enterprise customers in over 70 countries. The company is the second largest software vendor in Germany, the fourth in Europe and among the top 25 globally...

. It is largely used for building database
Database
A database is an organized collection of data for one or more purposes, usually in digital form. The data are typically organized to model relevant aspects of reality , in a way that supports processes requiring this information...

s output in plain text
Plain text
In computing, plain text is the contents of an ordinary sequential file readable as textual material without much processing, usually opposed to formatted text....

 form, for example.

* Hello World in NATURAL
WRITE 'Hello World!'
END

It has the ESCAPE TOP flow control instruction, which is similar to continue in C
C (programming language)
C is a general-purpose computer programming language developed between 1969 and 1973 by Dennis Ritchie at the Bell Telephone Laboratories for use with the Unix operating system....

, C++, Java
Java (programming language)
Java is a programming language originally developed by James Gosling at Sun Microsystems and released in 1995 as a core component of Sun Microsystems' Java platform. The language derives much of its syntax from C and C++ but has a simpler object model and fewer low-level facilities...

 and several other languages, except that it also works within subroutine
Subroutine
In computer science, a subroutine is a portion of code within a larger program that performs a specific task and is relatively independent of the remaining code....

s to both return from the routine and then continue the calling statement's processing loop.

Like continue, it avoids large amounts of indentation
Indentation
An indentation may refer to:* A notch, or deep recesses; for instance in a coastline, or a carving in rock* The placement of text farther to the right to separate it from surrounding text....

 levels when using nested instruction blocks inside any loop.

Example with ESCAPE TOP:

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

The levels of indentation can be automatically adjusted with the STRUCT command in the Natural Editor.

The same example, without ESCAPE TOP:

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'
ELSE
IF (I / 3 * 3) = I AND I > 3
WRITE 'Number' I 'is divisible by 3'
ELSE
IF (I / 5 * 5) = I AND I > 5
WRITE 'Number' I 'is divisible by 5'
ELSE
IF (I / 7 * 7) = I AND I > 7
WRITE 'Number' I 'is divisible by 7'
ELSE
IF (I / 11 * 11) = I AND I > 11
WRITE 'Number' I 'is divisible by 11'
ELSE
WRITE 'Number' I 'is prime'
END-IF
END-IF
END-IF
END-IF
END-IF
END-FOR
END

Another powerful flow control instruction command is the ESCAPE BOTTOM, which is similar to ESCAPE TOP except that it continues the processing from end of the calling statement's processing loop.
Example with ESCAPE BOTTOM:

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 BOTTOM
END-IF
IF (I / 3 * 3) = I AND I > 3
WRITE 'Number' I 'is divisible by 3'
ESCAPE BOTTOM
END-IF
IF (I / 5 * 5) = I AND I > 5
WRITE 'Number' I 'is divisible by 5'
ESCAPE BOTTOM
END-IF
IF (I / 7 * 7) = I AND I > 7
WRITE 'Number' I 'is divisible by 7'
ESCAPE BOTTOM
END-IF
IF (I / 11 * 11) = I AND I > 11
WRITE 'Number' I 'is divisible by 11'
ESCAPE BOTTOM
END-IF
WRITE 'Number' I 'is prime'
END-FOR
END

One thing that sets NATURAL apart from most other languages is its rich syntax. For example, many languages have a simple switch case statement that can be used to replace nested IF statements pertaining to a single variable. This is prone to logic errors since it is necessary to BREAK out of the statement programatically. NATURAL has a much cleaner/richer DECIDE statement which is easier to understand and code. Here are some examples of this:

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

External links

The source of this article is wikipedia, the free encyclopedia.  The text of this article is licensed under the GFDL.
 
x
OK