Interfaces, Statement and interface integration – BrightSign BrightScript 3.0 Reference Manual User Manual
Page 22

17
Interfaces
Interfaces in BrightScript operate similarly to Java or Microsoft COM: An interface is a known set of member functions that
implement a set of logic. In some ways, an interface is similar to a virtual base class in C++; any script or program that is
compatible with C can use an object interface without regards to the type of object it belongs to: For example, the
roSerialPort object, which controls the standard serial interface (RS-232), implements three interfaces: ifSerialControl,
ifStreamReceive, and ifStreamSend. Since the
print statement sends its output to any object that has an ifStreamSend
interface, it works with the roSerialPort object, as well as any other object with the ifStreamSend interface.
Statement and Interface Integration
Some BrightScript statements have integrated functionality with interfaces. This section describes how to use statements
with interfaces.
PRINT
Using the
PRINT statement in the following format will print into an object that has an ifStreamSend interface, including
the roTextField and roSerialPort objects:
print #object, "string"
If the expression being printed evaluates to an object with an ifEnum interface, the
PRINT statement will print every item
that can be enumerated.
In addition to printing the values of intrinsic types, the
PRINT statement can also be used to print any object that exposes
one of the following interfaces: ifString, ifInt, ifFloat.
WAIT
The
WAIT statement can work in conjunction with any object that has an ifMessagePort interface.