beautypg.com

Xylem STORM 3 Basic Programming manual User Manual

Page 37

background image

35

Commands and Functions

Returns the string equivalent of the given number. An optional second parameter string may be

specified to declare the format to be used. Formats are specified using the hash character (“#”). If

not enough hashes are specified, the format will be returned. See VAL( ) for converting a string to a

number.

var$= STR$(18.265)

REM sets var$ to 18.265

var$ = STR$(18.265, “#.#####”)

REM sets var$ to #.#####

var$ = STR$(18.265, “##.####”)

REM sets var$ to18.2650

var$ = STR$(18.265, “#######”)

REM sets var$ to 18

Empty elements in the array are created if two delimiters are next to each other. The TOKEN

function, on the other hand, does not add empty elements if two or more delimiters are in

sequence.

The array will be automatically sized (larger or smaller) based on the number of strings that are

produced by the split. The number of strings produced will also be returned by the function.


var$ = “A1,B2,C3,D4,-A1,-B2”

ARRAY arr$(1)

array_num = SPLIT(var$, arr$(), “,-”) REM split on commas, returns 8

REM array arr$ now contains [A1][B2][C3][D4][][A1][][B2]

Returns the squared value of the given number. The caret (“^”) may also be used to raise a number

to a power, such as 2.

var = SQR(5) REM sets var to 25

var = 4^2

REM sets var to 16

SQR (number)

Returns the square root value of the given number. The caret (“^”) may also be used to raise a

number to a power, having the same effect by using a fraction such as 1/2.

var = SQRT(25) REM stores 5 in the var variable

var = 16^(1/2) REM sets var to 4

SQRT (number)

Specifies an optional increment in a FOR loop. Positive or negative numbers may be used.

FOR a = 10 TO 1 STEP -2

var = a REM sets var to 10 8 6 4 2

NEXT a

STEP

STR$ (number, string)