beautypg.com

Example programs – Xylem STORM 3 Basic Programming manual User Manual

Page 44

background image

42

EXAMPLE PROGRAMS

REM Prints out the last line of the log file to the RS-232 Com port
REM When set up to run with the sensors, prints out their values every scan

LogFile$ = “SiteID.csv”

OPEN LogFile$ FOR READING AS #1
SEEK #1, 0, “END”
fileSize = TELL(#1)
filePosition = TELL(#1)

fileError = 0
foundEnd = 0
IF (filePosition < 150) THEN

REM The first search should begin at the start

SEEK #1, 0, “BEGINNING”

ELSE

REM Note that this is presuming that each log line is less than 150 characters long

SEEK #1, -150, “END”

END IF

WHILE (foundEnd == 0 and fileError == 0)

LINE INPUT #1, LastLogLine$

filePosition = TELL(#1)

IF (filePosition == fileSize) THEN

foundEnd = 1

END IF

WEND
CLOSE #1

SETPORT 9600, 8, none, 1, none, 50, 0
OPEN “RS-232 Com” AS #2
PRINT #2 LastLogLine$, “\r\n”
CLOSE #2

AutoPrint.bas

The following programs are provided for reference when creating and using the Basic interpreter.