Commands and functions – Xylem STORM 3 Basic Programming manual User Manual
Page 34

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 parameter
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(“A1,B2,C3,D4,A1,B2”, “B2”) REM sets var to 16
var = RINSTR(“A1,B2,C3,D4,A1,B2”, “B2”, 5) REM sets var to 4
32
COMMANDS AND FUNCTIONS
RINSTR (string, string, number)
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 sets x to a random number between 0 and 0.99999
y = RND(5) REM sets y to a random number between 0 and 4.99999
RND (number)
Returns the given string with all whitespace removed from only the right side.
var$ = RTRIM$(“ A1,B2,C3,D4 “) REM sets var$ to “ A1,B2,C3,D4”
RTRIM$ (string)
Sets the position from which the next INPUT statement will read from within an open file. The first
parameter is the open file, the second parameter tells where to set the next read position, and the
third is an optional setting of either “BEGINNING”, “CURRENT”, or “END”. “BEGINNING” sets the
count from the beginning of the file (and is the default if not specified), “CURRENT” counts from
the current read position from within the file, and “END” counts from the end of the file. The TELL
command retrieves the current read position of the given file.
REM Presuming SiteID.csv contains:
REM Digital1,Analog2,WindSpeed
REM 56.23,2.25,126.5
OPEN “SiteID.csv” FOR READING AS #1
SEEK #1, LEN(“Digital1”) + 1 REM sets our position to Analog2
INPUT #1 “,”, var$ REM sets var$ to Analog2
SEEK #1, -11, “END” REM sets our position to the Analog2 measurement
INPUT #1 “,”, var2$REM sets var2$ to 2.25
CLOSE #1
SEEK