beautypg.com

Dot” operator, Array/function call operator – BrightSign BrightScript 2 Reference Guide User Manual

Page 12

background image

12

When AND and OR are used for logical operations, only the necessary amount of the
expression is executed. For example:


print true or invalid

The above statement will print “true”, where as:


print false or invalid

Will cause a runtime error because “invalid” is not a valid expression.

“dot” Operator

The “.” Operator can be used on any Roku Object or any AssociativeArray. It also has
special meaning when used on roXMLElement or roXMLList. When used on a Roku
Object, it refers to an interface or a member function. For example:

i=CreateObject(“roInt”)
i.ifInt.SetInt(5)
i.SetInt(5)


“ifInt” is the interface, and “SetInt” is the member function. Every member function of a
Roku Object is part of an interface. However, specifying the interface with the dot
operator is optional. If it is left out, as in the last line of the example above, each
interface in the object is searched for the member function. If there is a conflict (a
member function with the same name appearing in two interfaces), then the interface
should be specified.

When the “.” Operator is used on an Associative Array, it is the same as calling the
Lookup() or AddReplace() member of the AssociativeArray Object.

aa=CreateObject(“roAssociativeArray”)
aa.newkey=”the value”
print aa.newkey


The “.” Operator‟s parameters are set at compile time – they are not dynamic (unlike the
Lookup() or AddReplace() functons).

See the section on XML support for details on using the dot operator on xml objects.

Array/Function Call Operator

The “[ ]” operator is used to access an Array (any Roku Object that has an “ifArray”
interface, such as roArray). It can also be used to access an AssociativeArray.

The function call operator “( )” can be used to call a function. When used on a Function
literal (or variable containing a function reference), it calls the Function.