Compound Statements (Blocks)

<< Click to Display Table of Contents >>

Home  mIoTa BASIC > mIoTa BASIC Language Reference > Statements >

Compound Statements (Blocks)

A compound statement, or block, is a list of statements enclosed by the keywords BEGIN and END.

 

begin

 statement_1

 statement_2

 statement_n

end;

 

Syntactically, a block is considered to be a single statement which is allowed to be used when BASIC syntax requires a single statement. Blocks can be nested up to the limits of memory.

 

For example ..

 

if a > 5 then   // if 'a' is greater than 5 then ...

begin           

 a = 5;         // set variable 'a' equal to 5

 b = b + 1;     // and add 1 to variable 'b'

end;

 

or ..

 

case U0         // check the contents of user variable U0

 

 is 5 then      // if U0 is 5 then

   begin      

     U1 = 19;   // set U1 to 19 

     U2 = 's';  // and U2 to 's' 

   end;

 

 is 7 then      // but if U0 is 7 then

   begin

     U1 = 6;    // set U1 to 6 

     U2 = 'd'   // and set U2 to 'd'

   end;

 

caseend;