ZBasic Language Reference
43
ZBasic Microcontrollers
Example
tick = Register.RTCTick ' the long way
With Register
<other-statements>
tick = .RTCTick ' the short way, implies Register.RTCTick
<other-statements>
End With
Note that the entire construct, from With to End With, is treated much like a compound statement in
that it cannot be split across other statement boundaries. It is important to note, however, that this is not
a true compound statement with block scoping. Variables and constants defined within a With block are
visible to statements that follow it.
In addition to Register, other useful <prefix> designations are Console, Debug, Option, Version
and Module. Also, the <prefix> may specify a portion of a structure member reference, allowing
shorthand access to structure members. See Section 3.25 for more information on using structures.
BasicX Compatibility Note
In BasicX compatibility mode, only With Register is supported.
2.6 Literals
Boolean, numeric and string constant values are often used in programming. These are called literals
because the represent the literal value of the number or string that you have in mind as opposed to a
variable whose value may change over time.
2.6.1 Boolean Literals
Boolean literals are the keywords true and false, in upper, lower or mixed case. These literals are of
type Boolean.
2.6.2 Numeric Literals - Integral Values
A decimal integral numeric literal consists of decimal digits optionally with a leading plus or minus sign to
indicate a positive or negative literal value.
Integral literals may be specified in hexadecimal (base 16) by beginning the literal with an ampersand and
the letter H (upper or lower case) followed by one or more hexadecimal digits (0-9, A-F, a-f). In BasicX
compatibility mode, a trailing ampersand is either allowed, required or disallowed depending on the
specific value and whether or not Strict mode is enabled. In native ZBasic mode the trailing ampersand is
always allowed, is never required and has no effect whatsoever on the resulting value.
Integral literals may also be specified in binary (base 2) by beginning the literal with an ampersand and
the letter B (upper or lower case) followed by one or more binary digits (0-1). To improve readability, you
may also include one or more underscores within the digit string provided that each underscore occurs
between two digits. For compatibility with other Basic dialects, an upper or lower case X may be used in
place of the radix indicator B. Binary literals are not supported in BasicX compatibility mode.
Examples of decimal, hexadecimal and binary integral literals:
124
+16
-357
|