Try OpenEdge Now
skip to main content
Guide for New Developers
An overview of ABL : Understanding ABL Syntax : Blocks
 

Blocks

In ABL, 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 below shows a typical layout of blocks in a procedure:
/* 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 */
A block within a procedure or class file is bracketed by an ABL keyword that ends with the ":' character, any number of ABL statements, followed by the "end." statement.