User guide
eWON 500-2001-4001-4002 User Guide - Programming the eWON
eWON 500®2001®4001®4002® Version 4_3_0 - User Guide - 10/5/05 - ©ACT'L sa - Page 160
9.2.62 PUT
The put command works completely differently if the file is opened in Binary mode or in Text mode.
The file must be opened for OUTPUT or for APPEND operation (APPEND for /usr files only).
• COM, TCP-UDP, /usr
The file syntax has been extended in version 3 of the eWON to allow access to the serial port and to TCP and UDP socket.
The command description describes operation for /usr (Text and Binary modes), COM (always binary) and TCP-UDP (always binary)
9.2.62.1 File Syntax[Command] – Binary mode
PUT E1, S1[;S2…]
• E1 is file number (1-8)
• S1 is the string of char to append to the file. The number of bytes written depends on the length of the string.
• S2…: (optional) additional data to write
Important: the delimiter between the file number and the first item is a ‘,’ but the separator between the first item and the optional
next item is a ‘;’. This is close to the PRINT syntax.
The length of a BASIC line limits the number of items.
Example:
9.2.62.2 File Syntax[Command] – Text mode
PUT E1, V1[;V2…][;]
• E1 is file number (1-8)
• V1 is an element of type STRING, INTEGER or FLOAT
• V2…optional: additional data to write (STRING, INTEGER or FLOAT)
The data are converted to text before being written to file. If data is of STRING type it is written between quotes ("), otherwise not.
A ‘;’ is inserted between each data written to the file.
If the PUT command line ends with a ‘;’, the sequence of data can continue on another BASIC line. If the PUT command line ends without the
‘;’ character, the line is considered as finished and a CRLF (CHR$(13)+CHR$(10)) is added at the end of the file.
Example:
Produces this file:
123;"ABC";"DEF"
345.7;"YYY";"ZZZ"
REM: there is a CRLF at the end of the last line, PUT 1,345.7;"YYY";"ZZZ"; would avoid that.
OPEN "/myfile.bin" FOR BINARY OUTPUT AS 1
PUT 1,"ABCDEF";"GHIJKLMN"
CLOSE 1
REM Now reopens and append
OPEN "/myfile.bin" FOR BINARY APPEND AS 1
PUT 1,"OPQRSTUVWXYZ"
CLOSE 1
OPEN "/myfile.txt" FOR TEXT OUTPUT AS 1
PUT 1,123;"ABC";
PUT 1,"DEF"
PUT 1,345.7;"YYY";"ZZZ"
CLOSE 1