NATURAL

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 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


Wikimedia Foundation. 2010.

Игры ⚽ Поможем написать реферат
Synonyms:

Look at other dictionaries:

  • Natural — Nat u*ral (?; 135), a. [OE. naturel, F. naturel, fr. L. naturalis, fr. natura. See {Nature}.] 1. Fixed or determined by nature; pertaining to the constitution of a thing; belonging to native character; according to nature; essential;… …   The Collaborative International Dictionary of English

  • natural — adjetivo 1. De la naturaleza o producido por la naturaleza, y no por el hombre: fronteras naturales, recursos naturales. Me gusta la fruta natural, no la que viene en conserva. Las tormentas son un fenómeno natural. ciencias naturales. luz*… …   Diccionario Salamanca de la Lengua Española

  • natural — (Del lat. naturālis). 1. adj. Perteneciente o relativo a la naturaleza o conforme a la cualidad o propiedad de las cosas. 2. Nativo de un pueblo o nación. U. t. c. s.) 3. Hecho con verdad, sin artificio, mezcla ni composición alguna. 4.… …   Diccionario de la lengua española

  • natural — NATURÁL, Ă, naturali, e, adj., adv., s.n. I. adj. 1. Care se referă la natură (1), care aparţine naturii; care se găseşte în natură. ♢ Bogăţie naturală = bogăţie (necultivată) a solului sau a subsolului, a unei regiuni, a unei ţări. Ştiinţele… …   Dicționar Român

  • natural — [nach′ər əl, nach′rəl] adj. [OFr < L naturalis, by birth, according to nature] 1. of or arising from nature; in accordance with what is found or expected in nature 2. produced or existing in nature; not artificial or manufactured 3. dealing… …   English World dictionary

  • Natural — es un adjetivo que se refiere a la Naturaleza. Puede referirse a: Persona nacida en un determinado lugar (véase también vecino, ciudadano y súbdito) Lenguaje natural Números naturales Espacio natural Parque natural Reserva natural Ciencias… …   Wikipedia Español

  • natural — nat·u·ral adj 1: based on an inherent sense of right and wrong natural justice see also natural law, natural right 2 a: existing as part of or determined by nature …   Law dictionary

  • natural — adj 1 *regular, normal, typical Analogous words: ordinary, *common, familiar: *usual, customary, habitual, accustomed, wonted Antonyms: unnatural: artificial: adventitious 2 Natural, simple, ingenuous, naive, unsophisticated, artless, unaffected… …   New Dictionary of Synonyms

  • natural — adj. 2 g. 1. Da natureza ou a ela relativo. 2. Produzido pela Natureza. 3. Oriundo, originário. 4. Que não tem artifício, composição ou mistura. 5. Não artificial. 6. Não postiço; próprio. 7. Simples, singelo; sem doblez nem impostura. 8. Lógico; …   Dicionário da Língua Portuguesa

  • Natural — Nat u*ral (?; 135), n. 1. A native; an aboriginal. [Obs.] Sir W. Raleigh. [1913 Webster] 2. pl. Natural gifts, impulses, etc. [Obs.] Fuller. [1913 Webster] 3. One born without the usual powers of reason or understanding; an idiot. The minds of… …   The Collaborative International Dictionary of English

Share the article and excerpts

Direct link
Do a right-click on the link above
and select “Copy Link”