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 155
9.2.57.3 Different File/stream types
9.2.57.3.1 FILE open /usr
Syntax [command]
OPEN S1 FOR BINARY|TEXT INPUT|OUTPUT|APPEND AS E1
E1 is the file number. After the OPEN operation, the file is referenced by its file number and not by its file name.
There are 8 file numbers available. Once a file number is assigned to a file, it is allocated to that file, until the CLOSE command is issued.
S1 describes the access to a file that is located on eWON directories. S1 must respect the following syntax:
• "file:/directory/filename"
This allows to read or write files in the /usr and /sys directories. You will not be able to access the files in the root (virtual files like config.txt)
with this command.
• If S1 does not begin by "file:", "tcp", "com", or "exp", then the file will be considered as being part of the /usr directory.
This syntax was the old (ver 3) syntax and is kept for compatibility purpose.
9.2.57.3.2 TCP stream open Syntax [command]
OPEN S1 FOR BINARY INPUT|OUTPUT AS E1
Note:
This command works only with BINARY
S1 must respect the following syntax:
E1 is the file number. After the OPEN operation, the file is referenced by its file number and not by its file name.
There are 8 file numbers available. Once a file number is assigned to a file, it is allocated to that file, until the CLOSE command is issued.
"tcp:address:port"
Address can be a dotted IP address like 10.0.0.1 or a valid resolvable internet name like ftp.ewon.be
Port
must be a valid port number from 1 to 65535.
WARNING - scheduled action: when the OPEN command is used to open a TCP connection, the command returns before the
connection is actually opened. A scheduled action is posted because opening the socket may require a dial out or take up to more
than a minute, and the BASIC cannot be stopped during that time.
Example Comment
OPEN "file:/usr/test.dat" FOR BINARY INPUT AS 1
A$=GET 1,4
CLOSE 1
Opens file 1
Reads 4 bytes
OPEN "file:/sys/test.dat" FOR BINARY INPUT AS 1
A$=GET 1,4
CLOSE 1
Opens file 1
Reads 4 bytes
Example Comment
OPEN "test.dat" FOR BINARY INPUT AS 1
A$=GET 1,4
CLOSE 1
Open the /usr/test.dat file
Reads 4 bytes