beautypg.com

Basic commands & functions – Xylem System 5000 BASIC Manual User Manual

Page 42

background image

40

Begins a conditional loop encompassed by REPEAT and UNTIL. The condition is given after the

UNTIL statement and while evaluated as TRUE, will continue to iterate through the loop. Once the

UNTIL condition is evaluated as FALSE, the loop exits.

REPEAT

var = var + 1

PRINT “ “, var * var; REM prints “ 1 4 9 16 25”

UNTIL (var = 5)

REPEAT

Returns control back to the calling line of a GOSUB call or a subroutine (SUB) call with an

optional value.

REM Calculate the Area of a Rectangle

heighth = 3

width = 4

Area = calc_area(heighth, width) REM stores 12 in Area

SUB calc_area(h, w)

A = h * w

RETURN A

END SUB

RETURN

Returns a string, starting from the right side, containing the given number of characters from the

given string.

var$ = “Analog Value: 12.5”

new_var$ = “A1:” + RIGHT$(var$, 4)

REM stores “A1:12.5” in new_var$

RIGHT$ (string, number)

Returns the position, starting at 1, of the first occurrence of the second given string within the

first given string beginning at the right. If the string is not found, zero is returned. The third

argument is an optional number, defaulting to the last element of the string, indicating the

starting position for the search. INSTR may be used to begin searching for a string from the left,

rather than the right.

var = RINSTR(“Analog 2: 3.5, Digital 4: 1”, “Digital”)

REM stores 16

var = RINSTR(“Analog 1: 1.25, Analog 2: 2.5”, “Analog”, 5)

REM stores 1

RINSTR (string, string, number)

BASIC COMMANDS & FUNCTIONS

Returns a random number. An optional number may be specified for the maximum range (from

zero to, but not including, the given number). If no number is given, the default is 1.

x = RND()

REM stores a random number between 0-0.99999 in x

y = RND(5) REM stores a random number between 0-4.99999 in y

RND (number)