Roint, rofloat, rostring – BrightSign HD2000 Object Reference Manual User Manual
Page 26

roInt, roFloat, roString
The intrinsic types rotINT32, rotFLOAT, and rotSTRING have an object and interface equivalent. These
are useful in the following situations:
When an object is needed, instead of a typed value. For example, roList maintains a list of
objects.
If any object exposes the ifInt, ifFloat, or ifString interfaces, that object can be used in any
expression that expects a typed value. For example, in this way an roTouchEvent can be used as
an integer whose value is the userid of the roTouchEvent.
Notes:
If o is an roInt, then the following statements have the following effects
1. print o ‘ prints o.GetInt()
2. i%=o ‘ assigns the integer i% the value of o.GetInt()
3. k=o ‘presumably k is typeOmatic, so it becomes another reference to the roInt o
4. o=5
‘this is NOT the same as o.SetInt(5). Instead it releases o, and
‘changes the type of o to rotINT32 (o is typeOmatic). And assigns it to 5.
When a function that expects a Roku Object as a parameter is passed an int, float, or string,
BrightScript automatically creates the equivalent Roku object.
roInt contains one interface:
ifInt
rotINT32
GetInt()
rotVOID SetInt(rotINT32 value)
roFloat contains one interface:
ifFloat
rotFLOAT
GetFloat()
rotVOID SetFloat(rotFLOAT value)
roString contains one interface:
ifString
rotSTRING
GetString()
rotVOID SetString(rotSTRING value)
Example:
BrightScript> o=CreateObject("roInt")
BrightScript> o.SetInt(555)
BrightScript> print o
555
BrightScript> print o.GetInt()
555
BrightScript> print o-55
500
Example:
BrightScript> list=CreateObject("roList")
BrightScript> list.AddTail(5)
BrightScript> print type(list.GetTail())
Note that an integer value of "5" is converted to type "roInt" automatically,
because list.AddTail() expects an Roku Object as its parameter.
Yet Another Example. The function ListDir() returns an object roList of roString’s.
26