78
Programming with TIDE
©2000-2008 Tibbo Technology Inc.
4.2.9.1
Objects, Events and Platform Functions
Each
provides the following types of custom language constructs:
Objects
These provide a way to access the various facilities and subsystems of the host
platform. For example, in a platform which supports networking, we would have a
socket object that handles TCP/IP communication.
Each object has properties, methods and events:
A property of an object allows you to read or change an internal variable for this
object. For example, a serial port object may have a baudrate property. Change
the value of this property, and the actual physical baudrate changes. There are
also read-only properties which only provide information.
ser.baudrate =
3
' set the baudrate
x = ser.numofports
' find out how many serial ports the device has.
A method of an object is a way to make the object perform a certain action. It is
basically a procedure. It can optionally take arguments or return values. Our ser
object could have getdata and setdata methods, for instance.
s = ser.getdata(
50
)
' gets up to 50 bytes of data into variable s.
ser.setdata(s)
' prepares up to 50 bytes of data for sending.
ser.send
' no arguments, returns nothing. Sends data.
of an object is something that 'happens' to this object in reality.
When TiOS registers an event, an event handler for it is automatically called, if it
exists in your source code. Event handlers are simply subs with no arguments.
sub
on ser_data_arrival
' ... do something! ... <-- will be called when data arrives into the
serial port.
end
sub
Platform Functions
Many functions commonly available in other BASIC versions are implemented in
Tibbo Basic on the platform level and not on the "pure" language level; these
include also seemingly universal functions, such as string processing, or various
date and time functions. This is done so because not every platform would actually
need these functions, universal as they may seem. Some platforms may have very
limited resources, and not every platform needs to know what the time is, or how
to parse strings.
Language Reference
The text below provides a complete rundown of all built-in language
,
and
. If you can't find something here, that means it is
platform-specific, and you would find it in your
documentation.
133
8
79
96
99
133