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

Page 38

Advertising
background image

36

Opens a file, serial (COM) port, network (Ethernet) port, or connects to a listening serial or

network port.

Files may be opened for either READING, WRITING, or APPENDING. A file opened with WRITING

mode will create a new file if the file doesn’t exist, or erase the contents of an existing file. To

prevent overwriting of an existing file, use the APPENDING option for write operations. Another

optional syntax may be used to determine if a file exists, as shown below in the file example.

Serial ports are opened with the following defaults: baud rate = 9600, data bits = 8, parity = none,

stop bits = 1, flow control = none, transmit char delay = 0, transmit line delay = 0. If other port

settings are desired, they must be specified prior to opening the port using the SETPORT

command, as shown below in the serial port example.

Ethernet ports are specified with either an IP address or hostname followed by a colon and port

number. To enable an Ethernet port to act as a Server (respond to incoming communication), a

port should be set up within the Listening Ports Setup using the touch screen interface.

Listening ports are configured within the Listening Ports Setup menus of the System 5000TM.

When communication occurs on a listening port, a Basic program can be initiated and retrieve/

respond to requests on that port. To enable that communication, the OPEN command should be

issued with “LISTENER” as its parameter. Subsequent PRINT and INPUT calls will then be directed to

and from the attached listening port. See the below example for further details. Note that ethernet

(e.g. TCP or UDP) and serial port configuration (e.g. baud rate) are configured within the Listening

Ports Setup menu. The “ETHERNET” parameter has been deprecated and is now synonymous with

“LISTENER”. Listening ports do not need to be closed using the CLOSE command.

All files and ports (except listening ports) will be automatically closed when a program ends.

File:

OPEN “SiteID.csv” FOR APPENDING AS #1

CLOSE #1

ENDIF

REM Check if file exists, if it doesn’t an OPEN #1 FOR READING will fail

LABEL print3

PRINT “ *”, a;

PRINT “*”;

LABEL print2

PRINT “ (“, a;

PRINT “)”;

LABEL print1

PRINT “ “, a;

OPEN

BASIC COMMANDS & FUNCTIONS

Advertising