beautypg.com

Xylem System 5000 BASIC Manual User Manual

Page 51

background image

Basic Commands and Functions

49

A parameter to the DATETIME function returning a string representation of the current time,

formatted as “HH:MM:SS”.

var$ = DATETIME(TIME$) REM stores “05:32:37”

TIME$

Used with the FOR statement to specify the range of the loop.

FOR a = 1 TO 10

PRINT “ “, a;

REM prints “ 1 2 3 4 5 6 7 8 9 10”

NEXT a

TO

Splits apart a string into an array of strings. The first parameter provides the string to split apart.

The second parameter provides the array which the new substrings will fill. The optional third

parameter provides the delimiters or characters that determine where to split the primary string.

If more than one delimiter is specified, splitting will occur at each character given (e.g. if a comma

and hyphen are given “,-”, content will be split on any commas or hyphens found as in the example

below). If no delimiter is specified, whitespace will be used as the delimiter (e.g. spaces and tabs).

Empty elements in the array are not created if two delimiters are next to each other (see element

5 below, regarding the sequence “Analog2,-Analog4”). The SPLIT function, on the other hand,

does 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$ = “Analog1,Analog2,Analog3-Analog2,-Analog4”

ARRAY arr$(1)

result = TOKEN(var$, arr$(), “,-”) REM splitting on commas and dashes

FOR i = 1 TO result REM result = 5

REM prints “1:Analog1 2:Analog2 3:Analog3 4:Analog2 5:Analog4”

PRINT i, “:”, arr$(i), “ “;

NEXT i

TOKEN (string, array, string)

Returns the given string with all whitespace removed from both the left and right side.

PRINT TRIM$(“ Hello World “) REM prints “Hello World”

TRIM$ (string)

A read-only constant containing the number 1.

var = 1

IF (var = TRUE) PRINT “passed” REM prints “passed”

TRUE