Control statement
Control statements will be used to change the program flow of the
HBasic program. A control statement may be a loop (while/loop/Until),
an if-statement or a select statement.
<Control
statement> ::=
<If-statement>
|
<While-statement>
|
<Until-statement> |
<do-statement>
|
<for-statement>
|
<select-statement>
<If-statement>::=
If
<condition>
Then
<statement-list >
Else
<statement-list>
Else If
<statement-list >
End If
<while-statement>
::=
While <condition> [
Do]
<statement-list>
Wend
<Until-statement>
::=
Until <condition> [
Do]
<statement-list>
End Until
<For-statement>
::=
For
loopvar =
<expression>
To
<expression>
[
Step
<expression> ]
<statement-list>
Next loopvar
<Do-statement>
::=
<Do-header>
<statement-list>
<End-do-statement>
<Do-header>
=
Do |
Do While
<condition> |
Do
Until <condition>
<End-do-statement>
::=
Loop
|
Loop While
<condition> |
Loop Until
<condition>
<select-statement>
::=
Select Case <expression>
<case-list>
End Case
<Case
list> ::= {
<Case
statement> }
<Case
statement> ::=
Case <Expression>
<statement-list> |
Case Else <statement-list>
where "Case Else" should occure only
once in the <case list> and should be the last statement in the
list.
<condition>
::=
<expression>
|
<Boolean-constant>
|
<expression>
AND <expression>
|
<expression>
OR <expression>
|
NOT <expression>
|
<expression>
XOR <expression>
|
<expression>
<bool-operator>
<expression>
<Boolean-constant> ::=
TRUE |
FALSE
<bool-operator> ::=
< |
> |
= |
<> |
<= |
>=
Exit-statement
<Exit-statement>
::=
Exit
( <number> )
The Exit statement may be used to terminate the program execution
immediatly and return to the calling program. I have implemented the
Exit statement to abort a running program if an error occured that
cannot be solved by the program itself.