Contents Previous Next Subchapters

Grouping A Sequence Of Statements As A Block
Syntax begin statement list end
See Also if , for , while

Description
Groups a list of program statements so they function as one.

Tutorial
A block is a list of statements that function as a single unit. You can use a block anywhere that O-Matrix allows a statement.

If you enter
     if 2 > 1 then begin
          x = 1
          y = 2
          x + y
     end
O-Matrix will respond
     3
Entering
     x = -1
     if x < 0 then begin
          x
          "negative"
     end else begin
          x
          "positive"
     end
will result in
     -1
     negative


Blocks can be used to create an arbitrary number of branches, or multi-way if-then-else. For example, if in an editor window you enter.
     x = 0
     if x < 0 then begin
          "negative"
     end else if x > 0 then begin
          "positive"
     end else begin
          "zero"
     end
and select 'File | Run' from the menu, O-Matrix will respond
     zero