World Library  
Flag as Inappropriate
Email this Article

Natural

Article Id: WHEBN0006055139
Reproduction Date:

Title: Natural  
Author: World Heritage Encyclopedia
Language: English
Subject: Software AG, Fourth-generation programming language, List of light sources, Nat, List of Texas state parks
Collection: Procedural Programming Languages, Software Ag
Publisher: World Heritage Encyclopedia
Publication
Date:
 

Natural

Natural is a fourth-generation programming language from Software AG. It is largely used for working with Software AG's ADABAS.

Language Features

* 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

External links

  • Official website
  • Natural Developer Community
  • Adabas and Natural Community
  • Free Natural Software for developers
  • nEDIT: Editor gratuito de Natural / Free Natural Editor Software
  • Free Natural Utilities and code samples
This article was sourced from Creative Commons Attribution-ShareAlike License; additional terms may apply. World Heritage Encyclopedia content is assembled from numerous content providers, Open Access Publishing, and in compliance with The Fair Access to Science and Technology Research Act (FASTR), Wikimedia Foundation, Inc., Public Library of Science, The Encyclopedia of Life, Open Book Publishers (OBP), PubMed, U.S. National Library of Medicine, National Center for Biotechnology Information, U.S. National Library of Medicine, National Institutes of Health (NIH), U.S. Department of Health & Human Services, and USA.gov, which sources content from all federal, state, local, tribal, and territorial government publication portals (.gov, .mil, .edu). Funding for USA.gov and content contributors is made possible from the U.S. Congress, E-Government Act of 2002.
 
Crowd sourced content that is contributed to World Heritage Encyclopedia is peer reviewed and edited by our editorial staff to ensure quality scholarly research articles.
 
By using this site, you agree to the Terms of Use and Privacy Policy. World Heritage Encyclopedia™ is a registered trademark of the World Public Library Association, a non-profit organization.
 


Copyright © World Library Foundation. All rights reserved. eBooks from Project Gutenberg are sponsored by the World Library Foundation,
a 501c(4) Member's Support Non-Profit Organization, and is NOT affiliated with any governmental agency or department.