Try OpenEdge Now
skip to main content
Developing WebSpeed Applications
SpeedScript : Elements of SpeedScript syntax : Blocks
 

Blocks

In SpeedScript, 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. sample2 shows a typical layout of blocks in a procedure:

sample2

REPEAT WHILE TRUE: /* BEGIN Iterative Block */
  RUN max-customers.
END. /* END Iterative Block */
PROCEDURE max-customers: /* BEGIN Internal Procedure Block */
  FOR EACH Customer USE-INDEX Name NO-LOCK: /* BEGIN Iterative Block */
    IF Customer.Balance GT 20000 THEN DO: /* BEGIN Non-iterative Block */
      {&DISPLAY} Customer.Name Customer.Balance.
    END. /* END Non-iterative Block */
  END. /* END Iterative Block */
END PROCEDURE. /* END Internal Procedure Block */
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 WebSpeed can compile separately. Web objects are always external procedures. Most of the samples in this section are not external procedures because their execution depends on the context of an enclosing Web object. An external procedure block is also the only type of block that requires no special syntax to define it. WebSpeed 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 sample3, are typically terminated with a colon, although you can use a period. Generally, you must terminate the block begun with a header statement with an END statement.