57
TIDE and Tibbo BASIC User Manual
©2000-2008 Tibbo Technology Inc.
enum
tiny
tinyfoo,
tinybar
end
enum
' this enum will be associated with a char type
enum
medium
mediumfoo =
254
mediumbar
end
enum
' this enum will be associated with a byte type
enum
impossible
baddy = -
1
cruise =
4294967295
end
enum
' this enum will raise a compile error, as no single variable
type can hold its values
enum
nofractions
thisisok =
4294967295
thisisnot = 125.25
end
enum
' compiler won't accept this! Integer values only, please!
Enumeration types are helpful when debugging your code
For each enumeration type variable, the
of the TIDE shows this
variable's current numerical value with a correct identifier associated with this
value. This usually proves to be very useful during debugging! After all, seeing
"dayofweek= 2- Monday" is much less cryptic than just "dayofweek= 2"!
4.2.4.8
Understanding the Scope of Variables
A scope is a section of code, from which you can 'see' a variable (i.e, assign it a
value, or read its value). For example:
sub
foobar(x
as
byte
)
dim
i, y
as
byte
y = x *
30
for
i =
1
to
y
dim
r
as
short
r = x +
5
next
i
r = x +
5
' this would produce a compiler error
end
sub
So, in the example above, x and y could be seen from anywhere within the sub
procedure called foobar. However, r could be seen only from within the for...
next statement. Thus, trying to assign r a value from outside the for... next
statement would result in a compiler error, because it actually doesn't exist outside
of that loop.
One identifier can refer to several different variables, depending on the scope in
this identifier is used:
33