I imagine two virtual variables : “FRead” “FWrite” used as in these examples :
Code: Select all
“FWrite”
ASTO 01
“MyFile1.txt”
ASTO IND 01 ; this creates the file MyFile1.txt for writing (append mode)
“HR”
ASTO IND 01 ; write a line with text “HR”
TIME
STO IND 01 ; write current hour
5
STO IND 01 ; write the value 5 using current format
“.EOF.”
STO IND 01 ; this closes the file
“FRead”
ASTO 02
“MyFile1.txt”
ASTO IND 02 ; open MyFile1.txt for reading from the beginning
ARCL IND 02 ; read the first line (as text) -> “HR”
RCL IND 02 ; read the second line (recorded hour)
RCL IND 02 ; read next value (5)
“.EOF.”
STO IND 02 ; closes the reading process
- The virtual variables initially contain -1 (meaning that no file is opened)
- When a file is opened (ASTO IND… with a file name) the virtual variable contains the position of the reading/writing indexes
- Writing the keyword “.EOF.” closes the file (and the value becomes -1 again)
- As a file is not attached to any user program, before any attempt to open a file, the best should be to test the internal value (-1 : no file open) and/or close a previously opened file with “.EOF.”
FWrite virtual variable:
- Once opened, the writing index is positioned at the end of the file (append)
- STO IND… or ASTO IND… is used to record a new line of numerical value or text.
- RCL IND… returns the current line index
FRead virtual variable:
- Once opened, the reading index is positioned at the beginning of the file (0)
- RCL IND… or ARCL IND… read a line of a numerical value (or text value). The cursor is incremented.
- STO IND… change the position of the reading index (direct access for reading)
Michel