NATURAL

Natural is a fourth-generation programming language from Software AG. It is largely used for building databases output in plain 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++, Java and several other languages, except that it also works within subroutines to both return from the routine and then continue the calling statement's processing loop.

Like continue, it avoids large amounts of indentation 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 trait 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; in C-like languages, it 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 is an example:

DECIDE ON FIRST VALUE MARITAL-STATUS VALUE 'M' DESC := 'Married' VALUE 'D' DESC := 'Divorced' VALUE 'W' DESC := 'Widowed' ANY ONCE-MARRIED := TRUE NONE DESC := 'Single' END-DECIDE

Famous quotes containing the word natural:

    The problem of the novelist who wishes to write about a man’s encounter with God is how he shall make the experience—which is both natural and supernatural—understandable, and credible, to his reader. In any age this would be a problem, but in our own, it is a well- nigh insurmountable one. Today’s audience is one in which religious feeling has become, if not atrophied, at least vaporous and sentimental.
    Flannery O’Connor (1925–1964)

    Parents fear lest the natural love of their children may fade away. What kind of nature is that which is subject to decay? Custom is a second nature which destroys the former. But what is nature? For is custom not natural? I am much afraid that nature is itself only a first custom, as custom is a second nature.
    Blaise Pascal (1623–1662)

    She atoned for want of devotion to God, by devotion to man. She had a woman’s natural tendency towards asceticism, self-extinction, self-abnegation.
    Henry Brooks Adams (1838–1918)