beautypg.com

Expressions, variables, and types – BrightSign BrightScript 2 Reference Guide User Manual

Page 7

background image

7

Expressions, Variables, and Types

Identifiers

Identifiers (names of variables, functions, labels, or object member functions or interfaces
(appear after a “.”)) have the following rules.

must start with an alphabetic character (a – z)

may consist of alphabetic characters, numbers, or the symbol “_” (underscore)

are not case sensitive

may be of any length

may not use a “reserved word” as the name (see appendix for list of reserved
words).

if a variable: may end with an optional type designator character ($ for string, %

for integer, ! for float, # for double) (functions do not support this).


For example:

a
boy5
super_man$

Types

BrightScript uses dynamic typing. This means that every value also has a type
determined at run time. However, BrightScript also supports declared types. This
means that a variable can be made to always contain a value of a specific type. If a value
is assigned to a variable (which has a specific type), the type of the value assigned will be
converted to the variables type, if possible. If not possible, a runtime error will result.

The following

types are supported in BrightScript:

Boolean – either true or false

Integer– 32 bit signed integer number

Float – the smallest floating point number format supported by the hardware or

software

Double - the largest floating point number format supported by the hardware or

software. Note that although BrightScript supports Double, Roku Objects do not.

String. – a sequence of ASCII characters. Currently strings are ASCII, not UTF-

8.

Object – a reference to a Roku Object (native component). Note that if you use

the “type()” function, you will not get “rotOBJECT”. Instead you will get the
type of object. E.g.: “roList”, “roVideoPlayer”, etc. Also note that there is no
special type for “intrinsic” BrightScript objects. BrightScript objects are all built
on the Roku Object type “roAssociatiaveArray”.

Interface- An interface in a Roku Object. If a “dot operator” is used on an

interface type, the member must be static (since there is no object context).

Invalid – the type invalid has only one value – invalid. It is returned in various

cases, for example, when indexing an array that has never been set.