NATURAL

From Wikipedia, the free encyclopedia

Jump to: navigation, search

NATURAL is a Fourth-generation programming language from Software AG.

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

It has the "ESCAPE TOP" flow control instruction, which is similar to "continue" in C, or "Continue For" in "Visual Basic.Net 2005", 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 identation 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

Advanced Search
Included Web Search Engines


Safe Search

close

Top Matching Results

Occasionally Search.com will highlight specialized results that are based on the context of your query. Examples of specialized results include specific links to news, images, or video.

Top Matching Results may highlight information from other Search.com pages, content from the CNET Network of sites, or third party content. The listings are based purely on relevance. Search.com does not receive payment for listings in this section but our partners that provide this data may get paid for listing these products.

Sponsored Links

This section contains paid listings which have been purchased by companies that want to have their sites appear for specific search terms and related content. These listings are administered, sorted and maintained by a third party and are not endorsed by Search.com.

Search Results

Search.com sends your search query to several search engines at one time and integrates the results into one list which has been sorted by relevance using Search.com's proprietary algorithm. You can customize the list of search engines included in your metasearch from the preferences.

The search engines that are used in your metasearch may allow companies to pay to have their Web sites included within the results. To view the Paid Inclusion policy for a specific search engine, please visit their Web site. Search.com does not accept payment or share revenue with any search engine partner for listings in this section.