Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

Insert excerpt
BrightScript Version Navigation Menu
BrightScript Version Navigation Menu
nopaneltrue
The intrinsic types 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 of o.GetInt()
  • i%=o: Assigns the integer i% the value of o.GetInt().
  • k=o: Presumably k is automatically typed, so it becomes another reference to the roInt  o.
  • o=5: This is NOT the same as o.SetInt(5). Instead it releases o, changes the type of o 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:

...