
21
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.
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
Yet Another Example. The function ListDir() returns an object roList of roString’s.
BrightScript> l=ListDir("/")
BrightScript> for i=1 to l.Count():print l.RemoveHead():next
test_movie_3.vob
test_movie_4.vob
test_movie_1.vob
test_movie_2.vob
Comentários a estes Manuais