Table of Contents
Progress 4GL and ABL Language Elements
This article describes Progress 4GL and OpenEdge ABL language elements.
A Progress 4GL program consists of one or more statements terminated by a period ( . ) or a colon ( : ), depending on the type of statement.
In Progress 4GL, a comment begins with /* and terminates with */ and you can nest comments within other comments.
In Progress 4GL, a block is a sequence of one or more statements, including any nested blocks, that share one context. This shared context depends on the type of block.
A typical layout of blocks in a procedure (.p file):
/* BEGIN - External Procedure Block */ ON CHOOSE OF bOk IN FRAME A DO: /* BEGIN - Trigger Block */ MESSAGE "Ok" VIEW-AS ALERT-BOX. END. /* END - Trigger Block */. PROCEDURE RunOk: /* BEGIN - Internal Procedure Block */ FOR EACH customer: /* BEGIN - Iterative Block */ RUN proc2.P END. /* END - Iterative Block */ END. /* END - Internal Procedure Block */ /* END - External Procedure Block */
In Progress 4GL/ABL, an external procedure or a procedural file is a .p file containing one or more statements and this is the smallest unit of code that Progress can compile and execute.
An external procedure is the only type of block that does not begin with any special keyword or header clause. The external procedure block beginning and end is the first and last statement in the file.
The RUN statement is used to run an external procedure from another ABL procedure.
External procedures can accept INPUT and OUTPUT parameters
RUN GetOrder.p (INPUT v1, OUTPUT v2).
Trigger and internal procedure blocks can be only defined in the external procedure block.
Any variables defined within the context of a procedure or trigger block, are available only to the statements of that procedure or trigger block.
Any variables defined within other types of blocks are always assigned to the nearest enclosing procedure or trigger context, not the context of the block where they are defined.
FOR EACH Customer FIELDS (Balance): DEFINE VARIABLE balance-sum AS DECIMAL INITIAL 0. balance-sum = balance-sum + Balance. END. MESSAGE "Balance:" STRING(balance-sum) VIEW-AS ALERT-BOX.
In this example, the MESSAGE statement can access the variable balance-sum defined in the FOR EACH block.
Scope is the duration that a resource is available and it depends on the resource.
- Record Buffer Scope
The FOR statement defines an implicit record buffer, and its scope is identical to the context of the FOR block, because the buffer is deleted when the FOR block finishes.
In the example above, the MESSAGE statement following the FOR block can access balance-sum variable, but it can no longer access the Balance field in the Customer record buffer.
- Procedure Scope
Progress calls a procedure, it creates its variables and user interface resources and deletes them when the procedure returns.
- Dynamic External Procedures Context (Persistent Procedures)
In Progress 4GL, you can create and delete dynamic resources for external procedures explicitly (persistent procedures). The scope of a dynamic resource lasts from the time you create it to the time you delete it or when the Progress client session ends, which ever occurs first. When a procedure block completes execution and its context goes out of scope, this does not affect the scope of any dynamic resources that you have created in that context.
Progress allows you to define handles to access dynamic resources. These handles are variables that point to the resources you have created.