Natural Article Index for
Natural
Articles about
Natural
Website Links For
Natural
 

Information About

Natural




  • 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
  • 3 digits without decimals

  • END-DEFINE

FOR I = 2 TO 100
  • 2) = I AND I > 2

  • WRITE 'Number' I 'is divisible by 2'

ESCAPE TOP
END-IF
  • 3) = I AND I > 3

  • WRITE 'Number' I 'is divisible by 3'

ESCAPE TOP
END-IF
  • 5) = I AND I > 5

  • WRITE 'Number' I 'is divisible by 5'

ESCAPE TOP
END-IF
  • 7) = I AND I > 7

  • WRITE 'Number' I 'is divisible by 7'

ESCAPE TOP
END-IF
  • 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
  • 3 digits without decimals

  • END-DEFINE

FOR I = 2 TO 100
  • 2) = I AND I > 2

  • WRITE 'Number' I 'is divisible by 2'

ELSE
  • 3) = I AND I > 3

  • WRITE 'Number' I 'is divisible by 3'

ELSE
  • 5) = I AND I > 5

  • WRITE 'Number' I 'is divisible by 5'

ELSE
  • 7) = I AND I > 7

  • WRITE 'Number' I 'is divisible by 7'

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


EXTERNAL LINKS