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

30
Used to take actions based on the evaluation of given conditional statements. True is determined
as anything non-zero; false is zero.
The short form of the IF statement does not include a THEN and must remain on one line.
Multi-line IF statements contain the THEN keyword as well as ENDIF to mark the ending of the
IF statement. IF statements may also contain the keywords ELSEIF to introduce alternative
conditional statements as well as the ELSE keyword to provide a default path if no other
conditions evaluate to true.
Single-line IF statement:
var = 250
IF (var >= 200) PRINT “Large number”
REM prints “Large number”
Multi-line IF statement:
var = 250
IF (var >= 500) THEN
PRINT “Very Large number”
ELSEIF (var >= 250) THEN
PRINT “Large number” REM prints “Large number”
ELSE
PRINT “Small number”
ENDIF
IF
BASIC COMMANDS & FUNCTIONS
Read from a file, serial (COM) port, or network (ethernet) connection that has been previously
opened with the OPEN command. When used with a serial or network port, an additional variable
may be specified to set an optional timeout in milliseconds for reading from the port (default is
100ms). When used with a file or serial port, an optional delimiter (stop character) may be specified
for retrieving data. The default delimiter for files is a space; the end of transmission EOT (0x04)
character is used for serial communication. Network communication uses the line feed (0x0A) as
its stop character. Note that files will not return the stop character whereas serial communication
returns all characters (including the delimiter). Entire lines of
files can be retrieved using the LINE INPUT command.
OPEN “COM1” AS #3
INPUT #3 250, a$
REM sets this timeout to 250ms rather than 100ms
INPUT #3 “,” 250, b$ REM retrieve until a comma or 250ms passes
CLOSE #3
OPEN “SiteID.csv” FOR READING AS #1
INPUT #1, b$ REM retrieves characters until a space is found
INPUT #1 “\t”, b$
REM retrieves characters until a tab is found
INPUT #1 “,”, b$
REM retrieves characters until a comma is found
CLOSE #1
INPUT