Natural for OpenVMS Version 6.3.12 for OpenVMS
 —  Programming Guide  —

User Comments

User comments are descriptions or explanatory notes added to or interspersed among the statements of the source code. Such information may be particularly helpful in understanding and maintenaing source code that was written or edited by another programmer. Also, the characters marking the beginning of a comment can be used to temporarily disable the function of a statement or several source code lines for test purposes.

In Natural, you have the following possibilities for entering your comments in source code:


Using an Entire Source Code Line for Comments

If you wish to use an entire source-code line for a user comment, you enter one of the following at the beginning of the line:

*  USER COMMENT
** USER COMMENT
/* USER COMMENT

Example:

As can be seen from the following example, comment lines may also be used to provide for a clear source code structure.

** Example 'LOGICX03': BREAK option in logical condition
************************************************************************
DEFINE DATA LOCAL
1 EMPLOY-VIEW VIEW OF EMPLOYEES
  2 NAME
  2 FIRST-NAME
  2 BIRTH
*
1 #BIRTH (A8)
END-DEFINE
*
LIMIT 10
READ EMPLOY-VIEW BY BIRTH
  MOVE EDITED BIRTH (EM=YYYYMMDD) TO #BIRTH
  /*
  IF BREAK OF #BIRTH /6/
    NEWPAGE IF LESS THAN 5 LINES LEFT
    WRITE / '-' (50) /
  END-IF
  /*
  DISPLAY NOTITLE BIRTH (EM=YYYY-MM-DD) NAME FIRST-NAME 
END-READ 
END

Top of page

Using the Latter Part of a Source Code Line for Comments

If you wish to use only the latter part of a source-code line for a user comment, you enter a blank, a slash and an asterisk ( /*); the remainder of the line after this notation is thus marked as a comment:

ADD 5 TO #A         /* USER COMMENT

Example:

** Example 'LOGICX04': IS option as format/length check
************************************************************************
DEFINE DATA LOCAL
1 #FIELDA (A10)          /* INPUT FIELD TO BE CHECKED
1 #FIELDB (N5)           /* RECEIVING FIELD OF VAL FUNCTION
1 #DATE   (A10)          /* INPUT FIELD FOR DATE
END-DEFINE
*
INPUT #DATE #FIELDA
IF #DATE IS(D)
  IF #FIELDA IS (N5)
    COMPUTE #FIELDB = VAL(#FIELDA)
    WRITE NOTITLE 'VAL FUNCTION OK' //  '=' #FIELDA '=' #FIELDB
  ELSE
    REINPUT 'FIELD DOES NOT FIT INTO N5 FORMAT'
            MARK *#FIELDA
  END-IF
ELSE
  REINPUT 'INPUT IS NOT IN DATE FORMAT (YY-MM-DD) '
          MARK *#DATE
END-IF
*
END

Top of page