40
Programming with TIDE
©2000-2008 Tibbo Technology Inc.
platform. If your Tibbo Basic program runs on a refrigerator, you would probably
have an event handler for the door opening.
sub
on_door_open
light = 1
' turn on the light when someone opens the door to your
fridge.
end
sub
Just like any other sub, events can have arguments (input parameters):
sub
on_door_state(state
as
byte
)
' turn the light on and off as the fridge door gets opened and closed
if
state=0
then
light=0
else
light=1
end
if
end
sub
Event handles are always subs and never functions (i.e. they never return any
value as there is nobody to return it to)!
Code Basics
There are several important things you should know about writing in Tibbo Basic:
You Can Put Comments in Your Code
The apostrophe character marks the beginning of a comment. Anything following
this character until the end of a line is considered to be a comment, and will not be
processed by the
.
x =
1
+
1
' I am a comment!
' x = y/0 <--- this line would not cause an error, because it won't even
execute! It is commented.
The only exception to this is that when including an apostrophe within a string
(between double quotes) it is not counted as a comment. See:
s =
"That's a string!"
' Notice that the word that's contains an
apostrophe.
Comments cannot span multiple lines. A line break terminates a comment. If you
want to make a multi-line comment, each line of your comment must begin with
an apostrophe.
Tibbo Basic Doesn't Care About Spaces!
See:
131