Progress
Programming
Handbook


Examples

This is an external procedure that displays the names of all the customers in the sports database, sorted by name.

FOR EACH customer BY name: DISPLAY name. 

NOTE: Any statement or group of statements that you enter in a Procedure Editor buffer become an external procedure when you save or execute the buffer. Also, all the procedure files saved by AppBuilder are external procedures. For information on the Procedure Editor, see the Progress Basic Database Tools (Character only) manual, and in graphical interfaces, the on-line help for the Procedure Editor. For information on the AppBuilder, see the Progress AppBuilder Developer’s Guide.

This is an external procedure that returns, as an output parameter, the name of a customer in the sports database when given a customer number as an input parameter. If the specified customer does not exist, the procedure returns the unknown value (?) as the customer name:

p-exprc1.p
DEFINE INPUT PARAMETER pcust-num LIKE customer.cust-num. 
DEFINE OUTPUT PARAMETER pname LIKE customer.name INITIAL ?. 
FOR EACH customer: 
    IF customer.cust-num = pcust-num THEN DO: 
        pname = customer.name. 
        RETURN. 
    END. 
END. 

This external procedure calls p-exprc1.p with a user-specified customer number and displays the resulting customer name in a message. Note that p-exprc2.p is a top-level, application-driven procedure:

p-exprc2.p
DEFINE VARIABLE vcust-num LIKE customer.cust-num INITIAL 0. 
DEFINE VARIABLE vname LIKE customer.name. 
DO WHILE NOT vcust-num = ?: 
    SET vcust-num LABEL "Customer Number" WITH SIDE-LABELS. 
    IF NOT vcust-num = ? THEN DO: 
        RUN p-exprc1.p (INPUT vcust-num, OUTPUT vname). 
        MESSAGE "Customer" vcust-num "is" vname + ".". 
    END. 
END. 

For more information on the application- and event-driven models, the two basic techniques for writing Progress applications, see Programming Models."


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