11.07.2015 Views

BCL Programmers Manual V2.00 (PDF) - Barix

BCL Programmers Manual V2.00 (PDF) - Barix

BCL Programmers Manual V2.00 (PDF) - Barix

SHOW MORE
SHOW LESS

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

7 I/O stream functions7.1 Function overviewThe <strong>BCL</strong> language supports a variety of real world interfaces and protocols for input andoutput. The same function set is used throughout but the functionality differs slightlydepending on the protocol.7.1.1 Open and closeSimplified procedure for an I/O stream operation consists of three phases:1. Opening of the I/O stream using the OPEN function with the syntax: OPEN S$ AS Hwhere● E$ is a string expression which determines the protocol and sets appropriateparameters (for details see descriptions of individual protocols below)● H is the handle number (integer). For most protocols the numbers 0,..,15 areallowed. An exception is the TCP protocol where only numbers 0,..,5 areallowed. Handle numbers are common for all protocols and the same handlecannot be opened for two different streams at the same time.● Whether open is blocking or non-blocking depends on the particular protocol,see protocol specific sections below.1. Using the stream with WRITE, READ, SEEK etc. (list of available functions dependson particular protocol) Handle number of the stream is given to functions todetermine the stream. Multiple I/O commands can be used in this phase beforeclosing the stream.2. Closing the stream using CLOSE H command, where H is the handle number.After the CLOSE the handle is available again for use with any I/O stream.Not all peripherals/protocols mentioned in this chapter are supported on all <strong>BCL</strong> devices.Check the specific device documentation for more information about the protocolssupported.Besides OPEN, the following commands are common for all I/O operations:CLOSE HCloses the file or stream with handle H.7.1.1 WriteWRITE H, E$, E0Writes E0 bytes from E$ into the stream H.If E0 = 0, writes complete string (length determined by terminating 0 in string, text mode).To write a binary zero, use an empty string S$ and E0 = 1.Note: Unless explicitly set in the open statement (see non-blocking TCP below) the writecall is blocking and it does not return before the data is written to the output (or the outputbuffer).7.1.2 ReadREAD H, S$ [ ,E0 [ ,E$ ] ]Reads from the stream H into the string variable S$.The EOF condition can be checked using the LASTLEN(H) function (returns -1 on EOF).<strong>Barix</strong> AG | 29/106

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!