ON THIS PAGE
The intrinsic types
String have object and interface equivalents. These are useful in the following situations:
If "o" is of type roInt, then these statements will have the following effects:
print o: Prints the value of
i%=o: Assigns the integer
i%the value of
kis automatically typed, so it becomes another reference to the roInt
o=5: This is NOT the same as
o.SetInt(5). Instead it releases
o, changes the type of
oto roINT32 (
ois automatically typed), and assigns it to 5.
roInt contains theifInt interface, which provides the following:
Returns the integer value of the object.
Sets the integer value of the object.
roInt also contains theifIntOps interface, which provides the following:
Returns the integer value as a string. A space is not appended to the front for positive numbers.
roFloat contains the ifFloat interface, which provides the following:
Returns the float value of the object.
Sets the float value of the object.
roString contains theifString interface, which provides the following:
Returns the string value of the object.
Sets the string value of the object.
roString also contains the ifStringOps interface, which provides the following:
Some global functions offer the same functionality as ifStringOps methods. The function indexes of ifStringOps methods start at zero, while those of global functions start at one.
Sets the string value of the object using the specified string and string-length values. This is similar to the
SetSeting() method, which does not accept a parameter for string length.
Appends to 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.
x="string" x.ifstringops.appendstring("ddd",3) print x 'will print 'string' y=box("string") y.ifstringops.appendstring("ddd",3) print y 'will print 'stringddd'
Returns the number of characters in a string.
Returns the string with certain characters replaced with HTML entity encoding sequences:
" (double quote)
' (single quote)
Splits a string into substrings using the specified delimiter character(s). The
delim parameter can contain one or more characters to treat as delimiters. If the string object contains multiple contiguous delimiters, they will be treated as a single delimiter. This method returns the substrings as an roList object; the delimiters are not returned with the substrings.
BrightScript> s = "one&&two" BrightScript> print s.Tokenize("&") one two
Returns the string with any leading and trailing whitespace characters (e.g. TAB, LF, CR, VT, FF, NO-BREAK SPACE) removed.
Returns the value of the string as an integer number.
Returns the value of the string as a floating point number.
Returns the first
n characters of the string.
Returns the last
n characters of the string.
Returns a subset of the string that begins at the zero-based
start_index and terminates at the end of the string.
Returns a subset of the string, beginning at the zero-based
start_index and consisting of
n characters. If the string contains fewer than
n characters after the specified
start_index, this method will return all characters after the
Returns the zero-based index of the first occurence of the substring in the string. If the substring does not occur in the string, this method returns -1.
Returns the zero-based index of the first occurence of the substring after the specified
start_index in the string. If the substring does not occur after the specified
start_index, this method returns -1.
BrightScript> o=CreateObject("roInt") BrightScript> o.SetInt(555) BrightScript> print o 555 BrightScript> print o.GetInt() 555 BrightScript> print o-55 500
An integer value of 5 is converted to type roInt automatically because the
AddTail() method expects a BrightScript object as its parameter:
BrightScript> list=CreateObject("roList") BrightScript> list.AddTail(5) BrightScript> print type(list.GetTail())
ListDir() method returns an roList object containing roString objects:
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