Home      Downloads             Documentation      FAQ     

Documentation>ETP-Basic reference>Conditions

 

Conditions

To execute a sequence of instructions under some conditions, you can use conditions (surprising...). This is the same syntax as other Basic-like languages.

If condition1 Then
instructions1
EndIf

First, condition1 is evaluated at the run-time, and if condition1 is true, instructions1 will be executed. If condition is false, the program continue its execution after the EndIf.

You can also use keywords as Else and ElseIf.

If a condition after If is false, the jump won't be on EndIf, but on Else or ElseIf.

If condition1 Then
instructions1
Else
instructions2
EndIf

Here, if condition1 is true, instructions1 will be executed, otherwies it will be instruction2.

If the execution of instruction2 has also got a condition condition2, you can use ElseIf like that :

If condition1 Then
instructions1
...
ElseIf condition2 Then
instructions2
...
EndIf

If condition1 and condition2 are false, neither instructions1 or instruction2 will be executed.



You can set a sequence of ElseIf and eventually end with a Else to have the case if all the other conditions are false.

If condition1 Then
instructions1
...
ElseIf condition2 Then
instructions2
...
ElseIf condition3 Then
instructions3
ElseIf condition4 Then
instructions4
Else
instructions5
EndIf



Here, instructions5 will only be executed if all the conditions before are false.



Expression of conditions

A condition is an expression which returns TRUE or FALSE.

A condition can be done with the following operators :

= Is equal to
<> Is not equal to
< Less than
> Greater than
=< or <= Less or equal to
>= or => Greater or equal to

You can use the following logic operators :
  • AND
  • OR
  • NOT
So you can get one condition in one boolean expression.

The And operator has priority on Or. Brackets are used as usual You can use them for priorities :

a=b And c=d Or e=f

is different of

a=b And (c=d Or e=f)

The two elements to compare must be of the same type. A variable to be compared must be declared (implicitly or not).



If you have defined a type of variable and you want to compare variable of this type, the only operators are equal "=" and non-equality "<>". Two variables with a user-defined type (it means defined by you) are equal only if all the fields of the variables are equal.

 

Documentation>ETP-Basic reference>Conditions

     
    About ETP Contact Us