...
Insert excerpt | ||||||
---|---|---|---|---|---|---|
|
Int32
, Float
, and String
have object and interface equivalents. These are useful in the following situations:- An object is needed instead of a typed value . For example, roList (e.g. the roList object maintains a list of objects). When a function that expects a BrightScript object as a parameter is passed an integer, float, or string, BrightScript automatically creates the equivalent object.
- 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, an roTouchEvent roVideoEvent can be used as an integer whose with a value is the userid of the roTouchEventrepresenting the event ID.
...
Integer Operations
If "o" is of type roInt, then these statements will have the following effects:
print o
: Prints the value ofo.GetInt()
i%=o
: Assigns the integeri%
the value ofo.GetInt().
k=o
: Presumablyk
is automatically typed, so it becomes another reference to the roInto.
o=5
: This is NOT the same aso.SetInt(5)
. Instead it releaseso
, changes the type ofo
to roINT32 (o
is automatically typed), and assigns it to 5.
...
- .
ifInt
roInt contains the ifInt interface, which provides the following:
GetInt() As Integer
Returns the integer value of the object.
SetInt(value As Integer) As Void
Sets the integer value of the object.
ifIntOps
roInt also contains the ifIntOps interface, which provides the following:
...
roFloat contains the ifFloat interface, which provides the following:
GetFloat() As Float
Returns the float value of the object.
SetFloat(value As Float) As Void
Sets the float value of the object.
ifString
roString contains the ifString interface, which provides the following:
GetString() As String
Returns the string value of the object.
SetString(value As String) As Void
Sets the string value of the object.
ifStringOps
roString also contains the the ifStringOps interface, which provides the following:
...
SetString(str As String, str_len As Integer)
Sets a the string value of the object using the specified string and string-length values. This is similar to the roString.SetStringSetSeting()
method, which does not accept a parameter for string length.
AppendString(str As String, str_len As Integer)
Appends to a the string value of the object using the specified string and string-length values. This method modifies itself—this can cause unexpected results when you pass an intrinsic string type, rather than a string object.
...
An integer value of 5 is converted to type roInt automatically type roInt automatically because the AddTail()
method expects a BrightScript object as its parameter:
...