Statements and Expressions

Parent Previous Next

Statements and Expressions.

Code is written in code blocks. A code block uses curly brackets { } to mark the start and end.


 {

   //A code block

 }


Code is divided into statements.


A statement is either a simple statement or a predefined control statement.


Control statements belongs to a group of predefined structures recognized by the compiler.

These are:  If Then Else , Case Of , For Loop , Repeat Until , While Loop , Try Catch.


Control statements all contains one or more code blocks themselves.


Simple statements must end with a semicolon. Control statements must also end with a semicolon - unless they end with a right curly bracket } as presented here:


 Function Foo()

 {

   Integer i := Foo2(); //Simple statements here and

   Foo3();              //here ends with a semicolon.


   If i == 10 Then { Return 0; } //Control statement ends with }

 }


Statements may use this := assignment, or these  +=    -=    *=    /=  self-assignments.


Please notice that the symbol  (the single equality/assignment symbol used in other languages) is not part of the SCRAMBLECODE language.


Expressions.

A statement will contain an expression.


An expression may be dividable into sub-expressions in very complex constructions.


When dividing an expression into the smallest non-dividable sub-expressions, brackets, parentheses and operators play a key role. This table lists the available operators and their precedence with the highest ranking operators at the top. Operators on the same line have the same ranking.


Category

Operators

Primary

x.y   foo(x)   arr[x]

Unary

+   -

Multiplicative

*   /

mod  div

Additive

+   -

Relational

<   >    <=   >=

Equality

==   <>

Binary

notb

andb

xorb

orb

Logical

not

and

xor

or