Start Back Next End
  
ZBasic Language Reference
31
ZBasic Microcontrollers
2.4.5 Comparison Operators
The comparison operators are listed in the table below along with the permitted operand types.  The
result type is Boolean.
Comparison Operators
Function
Type
Operator
Permitted Operand Types
Equality
Binary
=
any
Inequality
Binary
<>
any 
Greater Than
Binary
>
String or any numeric
Greater Than or Equal To
Binary
>=
String or any numeric
Less Than
Binary
<
String or any numeric
Less Than or Equal To
Binary
<=
String or any numeric
2.4.6 Miscellaneous Operators
The remaining operators to be described are the string concatenation operator (&) and the address
operator (@).  For the string contenation operator, both operands must be type String and the result will
be type String.  Note that the + operator may also be used for concatenating strings.  The sole
difference between using & and using + is that the former supports automatic value-to-string conversion
while the latter does not.
The address operator is used to obtain the address of a variable, array element or procedure; it is an
alternate means of referring to the DataAddress and CodeAddress properties.  In use, the address
operator is placed immediately before the variable or procedure name as illustrated below.
Dim myVar as Byte
Dim addr as UnsignedInteger
addr = @myVar ' same as myVar.DataAddress
2.4.7 No "Short Circuit" Evaluation
It is important to note that in ZBasic, as in most Basic dialects, every term in an expression is always
evaluated irrespective of the intermediate results.  This is a technical detail that is significant only when
an expression contains function invocations and the act of invoking one or more of the functions involved
has “side effects” like modifying a global variable, modifying a parameter passed by reference, or
changing the state of the hardware.   Consider the evaluation of the conditional expression in the If
statement below when the value of the variable a is, say, 10.
If (a > 3) Or (foo() > 10) Then
    [other statements]
End If
When the expression on the left side of the Or operator is evaluated the result will be True.  Because of
this fact we know that the resulting value of the entire conditional expression will also be True – nothing
on the right hand side can possibly affect the outcome.  Nonetheless, the expression on the right hand
side of the Or operation will still be evaluated and thus the function foo() will be invoked.  Some other
computer languages, notably C/C++ and Java, implement the concept of “short circuit evaluation”.  In
those languages, the evaluation of an expression stops as soon as the result is known.  If that were the
case here, the right hand side of the Or expression would not be evaluated and, hence, the function
foo() would not be invoked.  To reiterate, ZBasic does not implement short circuit evaluation.
2.5 Statements
Previous page Top Next page