Player APIs (BrightScript & Ja...
...
Object Reference
BrightScript Core Objects
roByteArray
21min
this object contains functions for converting strings to or from a byte array, as well as to or from ascii hex or ascii base64 if you are converting a byte array to a string, and the byte array contains a zero, the string conversion will end at that point the byte array will automatically resize to become larger as needed if you wish to disable this behavior, use the setresize() method if an uninitialized index is read, invalid is returned since robytearray supports the ifarray interface, it can be accessed with the \[] array operator the byte array is always accessed as unsigned bytes while this interface is being used this object also supports the ifenum interface, and so can be used with a for each statement the javascript equivalent is blob() note that javascript now has typed arrays https //developer mozilla org/en us/docs/web/javascript/typed arrays (for example, uint8array https //developer mozilla org/en us/docs/web/javascript/reference/global objects/uint8array ) ifbytearray writefile(file path as string) as boolean writes the bytes contained in the byte array to the specified file this method returns true if successful writefile(file path as string, start index as integer, length as integer) as boolean writes a subset of the bytes contained in the byte array to the specified file this method writes length bytes, beginning at start index of the byte array readfile(file path as string) as boolean reads the specified file into the byte array this operation will discard any data currently contained in the byte array readfile(file path as string, start index as integer, length as integer) as boolean reads a section of the specified file into the byte array this method reads length bytes, beginning at start index of the file this operation will discard any data currently contained in the byte array appendfile(file path as string) as boolean appends the contents of the byte array to the specified file setresize(minimum allocation size as integer, autoresize as boolean) expands the size of the byte array to the minimum allocation size if it is less than the minimum allocation size this method also accepts a boolean parameter that specifies whether the byte array should be resized automatically or not tohexstring() as string returns a hexadecimal string representation of the contents of the byte array each byte is represented as two hex digits fromhexstring(hex string as string) writes the contents of the passed hexadecimal string to the byte array the passed string must contain an even number of hex digits this operation will discard any data currently contained in the byte array tobase64string() as string returns the contents of the byte array as a base64 formatted string frombase64string(base 64 string as string) writes the contents of a valid base64 formatted string to the byte array this operation will discard any data currently contained in the byte array toasciistring() as string returns the contents of the byte array as an ascii formatted string fromasciistring(ascii string as string) writes the contents of a valid ascii formatted string to the byte array this operation will discard any data currently contained in the byte array getsignedbyte(index as integer) as integer returns the signed byte at the specified zero based index in the byte array to read an unsigned byte within a byte array, use the ifarrayget getentry() method or the \[] array operator getsignedlong(index as integer) as integer retrieves the integer located at the specified long word index of the byte array note that this method cannot accept a byte index as its parameter islittleendiancpu() as boolean returns true if the cpu architecture is little endian ifarray peek() as dynamic returns the last (highest index) array entry without removing it pop() as dynamic returns the last (highest index) entry and removes it from the array push(entry as dynamic) adds a new highest index entry to the end of the array shift() as dynamic removes index zero from the array and shifts all other entries down by one unit unshift(entry as dynamic) adds a new index zero to the array and shifts all other entries up by one unit delete(index as integer) as boolean deletes the indicated array entry and shifts all above entries down by one unit count() as integer returns the index of the highest entry in the array plus one (i e the length of the array) clear() deletes every entry in the array append(array as roarray) appends one roarray to another if the passed roarray contains entries that were never set to a value, they are not appended the two appended objects must be of the same type ifenum reset() resets the position to the first element of enumeration next() as dynamic returns a typed value at the current position and increment position isnext() as boolean returns true if there is a next element isempty() as boolean returns true if there is not an exact statement ifarrayget getentry(index as integer) as dynamic returns an array entry of a given index entries start at zero if this method attempts to fetch an entry that has not been set, it will return invalid ifarrayset setentry(index as integer, entry as dynamic) sets an entry of a given index to the passed type value