Progress
Programming
Handbook


Elements of Progress Syntax

Progress is a block-structured, but statement-oriented language. That is, much of the behavior of a Progress application depends on how statements are organized into blocks. However, the basic executable unit of a Progress application is the statement.

Statements

This is the basic syntax of a Progress application:

SYNTAX
statement { . | : } [ statement { . | : } ... 

Thus, a Progress 4GL application consists of one or more statements. Each statement consists of a number of words and symbols entered in a statement-specified order and terminated by a period ( . ) or a colon ( : ), depending on the type of statement.

This is a one-statement application that displays “Hello, World!” in a message alert box:

p-hello1.p
MESSAGE "Hello, World!" VIEW-AS ALERT-BOX. 

Comments

A Progress application can also contain non-executable comments wherever you can put white space (except in quoted strings). Each comment begins with “/*” and terminates with “*/”, and you can nest comments within other comments:

p-hello2.p
/*/* Simple Application */*/ 
MESSAGE /* Statement Keyword */ "Hello, World!" /* String */  
    VIEW-AS ALERT-BOX /* Options */ . /*/* Period Terminates */ 
                                   -^--------^-    Statement */ 

Blocks

In Progress, a block is a sequence of one or more statements, including any nested blocks, that share a single context. A context consists of certain resources that a block of statements share. The content of this shared context depends on the type of block and its relationship to other blocks. The sample procedure, p-blocks.p, shows a typical layout of blocks in a procedure:

p-blocks.p
/* BEGIN EXTERNAL PROCEDURE BLOCK */ 
DEFINE BUTTON bSum LABEL "Sum Customer Balances". 
DEFINE VARIABLE balsum AS DECIMAL.  
DEFINE FRAME A bSum.  
ON CHOOSE OF bSum IN FRAME A DO:   /* BEGIN Trigger Block */  
    RUN SumBalances(OUTPUT balsum). 
    MESSAGE "Corporate Receivables Owed:"  
        STRING(balsum, "$>,>>>,>>>,>>9.99") VIEW-AS ALERT-BOX. 
END.                                /* END Trigger Block */ 
ENABLE bSum WITH FRAME A.  
WAIT-FOR WINDOW-CLOSE OF FRAME A.  
PROCEDURE SumBalances:  /* BEGIN Internal Procedure Block */ 
DEFINE OUTPUT PARAMETER balance-sum AS DECIMAL INITIAL 0. 
    FOR EACH customer FIELD (Balance):  /* BEGIN Iterative Block */ 
        balance-sum = balance-sum + Balance. 
END.                                    /* END Iterative Block */ 
END.                    /* END Internal Procedure Block */ 
/* END EXTERNAL PROCEDURE BLOCK */ 

In response to choosing a button, this procedure calculates the sum of all customer balances in the sports database and displays it in a message alert box.

The most basic block is the procedure, and the most basic procedure is an external procedure—a file containing one or more statements—because this is the smallest unit that Progress can compile separately. Thus, p-hello2.p is an external procedure with one statement, and p-blocks.p is an external procedure with several statements. An external procedure block is also the only type of block that requires no special syntax to define it. Progress always defines an external procedure block, by default, when the procedure executes.

You must begin all other types of blocks with appropriate header statements. Header statements, such as the DO, FOR, and PROCEDURE statements shown in p-blocks.p, are typically terminated with a colon, although you can use a period. You generally must terminate the block begun with a header statement with an END statement.


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