beautypg.com

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

Page 30

background image

28

slot$ = “SLOT2”

GETVALUE DIFF34, var

REM stores a new quadrature counter measurement of

REM ports 3-4 from the daughterboard in the var

REM

variable

GETVALUE ANALOG1 slot$, s$

REM stores a new analog measurement of

REM channel 1 from Slot 2 in the s$ string

REM

variable

CLEARSDI() REM Clear any cached SDI values for this time period

GETVALUE SDI01, a1$

REM request a new measurement (address 0, param 1)

GETVALUE SDI02, a2$

REM retrieve the second parameter

CLEARSDI() REM Force our next request to be a new measurement

GETVALUE SDI01, b1$

REM request a new measurement (address 0, param 1)

Specifies a variable as being global and retrieves any previously stored value. A global variable

allows any Basic program access to retrieve, modify, or update the contents of the variable. Global

values are only retrieved if the variable is initialized with the GLOBAL keyword. Newly declared

global variables are initialized to 0 if they are a number or “” if they are a string. In similar fashion, to

delete a global variable, simply set its value to 0 if it is a number or “” if it is a string.

REM Maintain a running average of the Battery

GLOBAL Global_var

GETVALUE BATT, battVolt

REM If Global_var hasn’t been created, use our retrieved value

IF (Global_var == 0) Global_var = battVolt

Global_var = (Global_var + battVolt) / 2

GLOBAL

Branches to the specified label or line number within the program. Once a RETURN statement is

reached, execution is passed back to the statement immediately following GOSUB. Subroutines,

defined with the SUB command, provide a much more flexible method of executing and running

portions of code and should be used instead of GOSUB.

h = 3

w = 4

d = 5

GOSUB 100

GOSUB ComputeArea

PRINT “Area: “, area REM prints “Area: 12”

END

LABEL ComputeArea

area = h * w

RETURN

100

volume = h * w * d

PRINT “Volume: “, volume REM prints “Volume: 60”

RETURN

GOSUB

BASIC COMMANDS & FUNCTIONS