Assigning double-precision values, Arrays, Strings – BrightSign HD2000 BrightScript Reference Guide User Manual

Page 10

Advertising
background image

10

RUN
.6666666865348816

Assigning Double-Precision Values

Here are three ways to be sure double-precision values are stored without any trailing "garbage digits". The
first two (lines 10 and 20) are for entering constants; the third (line 30) is for converting from single precision
to double-precision values.
A#=0.1D0
B#=0.1000000
C#=VAL(STR$(0.1))

BrightScript Objects do not support double precision, and double precision runs slower than float (single
precision). “integer” math runs the fastest.

Arrays

An array is simply an ordered list of values. In Roku BrightScript these values may be of any type, depending
on how the array is defined or typed.
.
Arrays start at zero. For example, after DIM A(4), array A contains 5 elements: A(0), A(1), A(2), A(3), A(4).

The number of dimensions an array can have (and the size or depth of the array), is limited only by the
amount of memory available.

For example:
DIM TWO-D(100,100)
FOR I=0 TO 100:FOR J=0 TO 100
TWO-D(I,J) = 500
NEXT:NEXT

String arrays can be used. For example, C$(X) would automatically be interpreted as a string array. And if
you use DEFSTR A at the beginning of your program, any array whose name begins with A would also be a
string array.

Strings

String constants are contained in quotes. For Example: “This is a string!”

String variables end with $, or are defined with the DEFSTR statement. For example:
A$=”fred”

Strings may be compared for equality or alphabetic precedence. When they are checked for equality, every
character, including any leading or trailing blanks, must be the same or the test fails.


IF Z$="END" THEN end_now

Strings are compared character-for-character from left to right. Actually, the ASCII codes for the characters
are compared, and the character with the lower code number is considered to precede the other character.

For example, the constant "A!" precedes the constant "A#", because "!" (ASCII code: decimal 33) precedes
"#" (ASCII code: decimal 35). When strings of differing lengths are compared, the shorter string is precedent
if its characters are the same as those in the longer string. For example, "A" precedes "A ".

Advertising
This manual is related to the following products: