Types – BrightSign HD2000 BrightScript Reference Guide User Manual

Page 6

Advertising
background image

6

super_man$

Types

All variables and values have a “type”. The type of a variable is stored along with its value. The following
types are used by Roku BrightScript:

• rotINT32– 32 bit signed number

• rotFLOAT – 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.

• rotSTRING. – a sequence of ASCII characters. Currently strings are ASCII, not UTF-8.

• rotOBJECT– See the Roku Object section. 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.

• rotINTERFACE- See the Roku Object Section.

• typeOmatic – This means that the type is determined at evaluation time. For example “1” is an int,

“2.3” is a float, “hello” is a string, etc. A variable that does not end in a type specifier character is
typeOmatic. It will take on the type of the expression assigned to it, and may change its type. For
example: a=4 creates a as int, then a = “hello”, changes a to a string. NOTE: Arrays that are
typeOmatic can not change their type once assigned an initial type. All array elements must be of
the same type.


Variables without declaration characters are assumed to be typeOmatic; this assumption can be changed with
DEFine statements.

Here are some examples of types. ? is a short cut for the “print” statement. The “type()” function returns a
string that identifies the type of the expression passed in.


Roku> script
BrightScript Micro Debugger.
Enter any BrightScript statement, debug commands, or HELP.

BrightScript> ?type(1)
rotINT32

BrightScript> ?type(1.0)
rotFLOAT

BrightScript> ?type("hello")
rotSTRING

BrightScript> ?type(CreateObject("roList"))
roList

BrightScript> ?type(1%)
rotINT32

BrightScript> b!=1
BrightScript> ?type(b!)
rotFLOAT

BrightScript> c$="hello"
BrightScript> ?type(c$)
rotSTRING

BrightScript> d="hello again"
BrightScript> ?type(d)
rotSTRING

BrightScript> d=1
BrightScript> ?type(d)
rotINT32

BrightScript> d=1.0

Advertising
This manual is related to the following products: