Try OpenEdge Now
skip to main content
ABL Essentials
Running ABL Procedures : Adding comments to your procedure
 

Adding comments to your procedure

The final step in this exercise is to add some comments to your procedure to make sure you and everyone else can follow what the code does. In ABL you begin a comment with the characters /* and end it with */. A comment can appear anywhere in your procedure where white space can appear (that is, anywhere except in the middle of a name or other token). You can put full-line or multi-line comments at the top of each section of code, and shorter comments to the right of individual lines. Just make sure you use them, and make them meaningful to you and to others. Here's the final procedure with a few added comments:
h-CustSample.p
/* h-CustSample.p — shows a few things about ABL */

DEFINE VARIABLE cMonthList AS CHARACTER NO-UNDO
  INITIAL "JAN,FEB,MAR,APR,MAY,JUN,JUL,AUG,SEP,OCT,NOV,DEC".
DEFINE VARIABLE iDays AS INTEGER NO-UNDO.

/* First display each Customer from New Hampshire: */
FOR EACH Customer NO-LOCK WHERE Customer.State = "NH" BY Customer.City:
  DISPLAY Customer.CustNum Customer.Name Customer.City.
  /* Show the Orders unless CreditLimit is less than twice the balance. */
  IF Customer.CreditLimit < (2 * Customer.Balance) THEN
    DISPLAY "Credit Ratio:" Customer.CreditLimit / Customer.Balance.
  ELSE
  FOR EACH Order OF Customer NO-LOCK:
    DISPLAY
      Order.OrderNum LABEL "Order"
      Order.OrderDate
      Order.ShipDate FORMAT "99/99/99" WITH CENTERED.
    /* Show the month as a three-letter abbreviation, along with the number
of days since the order was shipped. */
    IF Order.ShipDate NE ? THEN
      DISPLAY ENTRY(MONTH(Order.ShipDate), cMonthList) LABEL "Month".
    RUN calcDays (INPUT Order.ShipDate, OUTPUT iDays).
    DISPLAY iDays LABEL "Days" FORMAT "ZZZ9".
  END.
END.

PROCEDURE calcDays:
  /* This calculates the number of days since the Order was shipped. */
  DEFINE INPUT PARAMETER pdaShip AS DATE NO-UNDO.
  DEFINE OUTPUT PARAMETER piDays AS INTEGER NO-UNDO.

  piDays = IF pdaShip = ? THEN 0 ELSE TODAY - pdaShip.
END PROCEDURE.