Keyboard
Programming Manual
35
SATO Europe
EOP
Description
End of program. This keyword must be placed at the end of a program file if the
DOWNLOAD keyword is used in the program.
Syntax
EOP
Remarks
N/A
Example
Program file:
DOWNLOAD “DEMO.BAS”
CLS
PRINT “This is a test”
EOP
Programming Manual
Keyboard
SATO Europe
36
OPEN
Description
To establish file handles for file access. Up to 15 files can be accessed in one
program.
Syntax
OPEN “filename” FOR mode AS #FileHandle.
Remarks
Filename is the name of the file.
Mode specifies the file operation mode. It can be:
INPUT: Position to the beginning of the file and this file is “read only”. If the
file does not exist, the “File not found” error is displayed on LCD
display.
OUTPUT: Position to the beginning of the file, and this file is “write only”. If the
file does not exist, a new file is created.
APPEND: Append characters to the end of file.
FileHandle is a constant number or expression result, between 0 and 14.
Remember to close the file handle when the file is no longer used.
Example
OPEN “DATA1” FOR INPUT AS #1
OPEN “DATA2” FOR OUTPUT AS #2
Keyboard
Programming Manual
37
SATO Europe
CLOSE
Description
To clear file handles.
Syntax
CLOSE #FileHandle
Remarks
FileHandle must be a constant number, with which the file is opened.
Example
CLOSE #1
Programming Manual Keyboard
SATO Europe
38
KILL
Description
To delete file(s) in keyboard memory (SRAM only).
Syntax
KILL “filename”
KILL “*.*”
KILL “*”
Remarks
Filename can be any file in the memory.
Wild card (*) supports all files.
The file must be closed before deleting.
Example
KILL “DEMO.BAS”
Note: KILL cannot be used to delete files in Flash memory. For this you must use the
K012
Extended
File
Manager
utility
from
the
keyboard.
Keyboard
Programming Manual
39
SATO Europe
SEEK
Description
Reposition a file pointer in a specified file buffer.
Syntax
SEEK #FileHandle, offset.
Remarks
Offset is the number from the beginning of file to the new position.
Example
OPEN “DATA” FOR INPUT AS #1
SEEK #1,12
Programming Manual Keyboard
SATO Europe
40
READ
Description
Read data from a data file and assign them to variables.
Syntax
READ #FileHandle; list of variables.
Remarks
FileHandle specifies the file to read data from.
The variables store the data read from the FileHandle.
Example
OPEN “DATA” FOR INPUT AS #1
READ #1;A;A$
Keyboard
Programming Manual
41
SATO Europe
WRITE
Description
Write data to an opened file.
Syntax
WRITE #FileHandle; list of expressions.
Remarks
FileHandle specifies the file to write data to.
The variables are used to write data to opened data file.
Example
OPEN “DATA2” FOR OUTPUT AS #1
WRITE #1; “DATA”
Programming Manual Keyboard
SATO Europe
42
GOSUB…RETURN
Description
To branch to and return from a subroutine.
Syntax
GOSUB label
Statement block1
Label:
Statement block2
RETURN
Remarks
Label is a tag to mark a specified position in the program. The available maximum
label name is 20 characters. A return statement will cause the program return to the
statement following the GOSUB statement.
The total number of GOSUB…RETURN statements cannot exceed 40 in one
program.
Example
PRINT “MAIN ROUTINE”
GOSUB SUB1
PRINT “MAIN ROUTINE”
END
SUB1:
PRINT “SUBROUTINE”
RETURN
The execution result should be as follows:
OK
MAIN ROUTINE
SUBROUTINE
MAIN ROUTINE