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 138
9.2.25 FOR NEXT STEP
Syntax
FOR a% = E1 TO E2 STEP E3
NEXT a%
• a% is an integer variable used as a counter.
• E1, E2, E3 are integer values/variables
Purpose:
The instructions between the lines containing the FOR and the NEXT are executed until a% = E2.
The loop is always executed at least 1 time, even if E1 is greater than E2.
During first loop execution, a% equals E1. FOR and NEXT cannot be on the same line of program.
Do not exit the FOR/NEXT loop by a GOTO statement because, in this case, after a certain number of executions,
the memory of the eWON is full.
Example:
9.2.26 GET
The GET command works completely differently if the file is opened in Binary mode or in Text mode.
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.26.1 /usr Syntax [function] – Binary mode
GET E1, E2/S1
• E1 is the file number (1-8)
• E2 is the number of bytes to read from the file
Or
S1 if S1 is used, the function returns file specific information.
Purpose:
Returns a string of char with the data read. Moves the file read pointer to the character following the last character read (or to end of file).
• Get 1, 1 will return max 1 char
• Get 1, 5000 will return max 5000 char
• Get 1 without param is equivalent to Get 1,2048
Example:
FOR a%=10 TO 20 STEP 2
PRINT a%
NEXT a%
S1 value Returned information
"SIZE" File total size
OPEN "file:/usr/myfile.bin" FOR BINARY INPUT AS 1
A$ = GET 1,10 REM read 10 bytes
PRINT A$
CLOSE 1