Xylem STORM 3 Basic Programming manual User Manual
Page 9

Basic Programming
7
Files stored on the Storm’s local file system can be accessed for reading, writing, and appending of
data. The OPEN command allows files to be opened and assigned a number for use throughout
the program. Using the INPUT and PRINT commands with the file’s assigned number allows Basic
to read and write to the opened file. Other commands such as EOF, LINE INPUT, SEEK, and TELL
allow for further traversal and manipulation of data files.
The Storm’s RS-232 Comand RS-485 ports can be opened, closed, read from, and written to with
OPEN, CLOSE, INPUT, and PRINT commands as well.
More information and examples relating to both file and serial I/O can be found under each of the
respective commands.
File and Serial I/O
Special escape sequences are available for use within Basic. Non-printable characters such as a
tab or newline can be created by a using a backslash (“\”) followed by a single letter or hex value
sequence as detailed below.
Escape Sequences and Hex Values
Additional printable and non-
printable characters from the
ASCII chart can be accessed
by specifying a hexadecimal
value, using the escape
sequence \xXX, where XX is
the hexadecimal value for
the desired symbol in the
ASCII chart. For example,
from the table above, the
carriage return character (\r)
would be represented by the
hexadecimal escape sequence
\x0D.
Basic provides a number of commands that allow for string manipulation and processing.
Functions that return string variables contain a trailing “$” whereas functions returning number
variables do not have a “$”. Functions such as LEFT$, MID$, and RIGHT$ can be used for extracting
parts of a string. Separating a string into usable sections can be done with TOKEN and SPLIT.
Converting strings to numbers and numbers to strings can be quickly accomplished with the STR$
and VAL functions. The “+” operator may also be used to concatenate strings. There are many
other string functions available including ASC, CHR$, HEX$, INSTR, LEN, LOWER$, MID$, UPPER$
that may be used to manipulate strings and their contents.
String Processing
Escape
Sequences
ASCII Value
Hex Value
Description
\b
8
08
backspace
\t
9
09
horizontal tab
\n
10
0A
newline
\v
11
0B
vertical tab
\f
12
0C
form feed
\r
13
0D
carriage return
\”
34
22
double quote
\’
39
27
single quote
\\
92
5C
backslash
\xXX
N/A
N/A
hex value