Release 10.1A: OpenEdge Development:
Progress 4GL Handbook

> ## 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 Progress 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. The intelligent editor colors comments in green by default. The editor can also type the comment symbols for you, if you type CMT and press the SPACEBAR in the editor window. Here’s the final procedure with a few added comments:

> h-CustSample.p
>     /* h-CustSample.p— shows a few things about the Progress 4GL */

>     DEFINE VARIABLE cMonthList AS CHARACTER  NO-UNDO
>         INIT "JAN,FEB,MAR,APR,MAY,JUN,JUL,AUG,SEP,OCT,NOV,DEC".
>     DEFINE VARIABLE iDays      AS INTEGER    NO-UNDO.   /* used in calcDays proc */
>     /* First display each Customer from New Hampshire: */
>     FOR EACH Customer WHERE state = "NH" BY City:
>         DISPLAY CustNum NAME City.
>         /* Show the Orders unless the Credit Limit is less than
>            twice the balance. */
>         IF CreditLimit < 2 * Balance THEN
>             DISPLAY "Credit Ratio:" CreditLimit / Balance .
>         ELSE FOR EACH Order OF Customer:
>             DISPLAY OrderNum LABEL "Order"
>                  OrderDate 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 ShipDate NE ? THEN
>               DISPLAY ENTRY(MONTH(ShipDate), cMonthList) LABEL "Month".
>             RUN calcDays (INPUT 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.

> You’ve learned a tremendous amount about the Progress 4GL in the course of writing a procedure barely over twenty lines long, which retrieves and merges data from two different database tables, and performs a number of extra calculations and formatting operations along the way. These first chapters have tried to provide you with some insight into the power of the Progress 4GL. Feel free to experiment with the language statements and functions you’ve encountered.

> In the next chapters, you’ll look at another major OpenEdge development tool, the AppBuilder, and use it to generate the code you need to create an application window that looks a lot closer to the kind of graphical interface you might expect in your applications. Later chapters then introduce you to a world of creating applications with almost no code at all!

Copyright © 2005 Progress Software Corporation www.progress.com Voice: (781) 280-4000 Fax: (781) 280-4095