Topic : The GFA-Basic Compendium Author : GFA Systemtechnik GmbH Version : GFABasic.HYP v2.98 (12/31/2023) Subject : Documentation/Programming Nodes : 899 Index Size : 28056 HCP-Version : 3 Compiled on : Atari @charset : atarist @lang : @default : Document not found @help : Help @options : +g -i -s +z @width : 75 @hostname : STRNGSRV @hostname : CAB @hostname : HIGHWIRE @hostname : THING View Ref-FileLOF(#n) LOC(#n) EOF(#n) CLOSE [#n] TOUCH [#]n n: iexp The numerical expression n refers to the channel number previously specified with OPEN. LOF() (length of file) returns the length of a file in bytes. LOC() (location) returns the current position of the data pointer measured in bytes from the beginning of the file. (where LOC() returns zero). See also SEEK. EOF() (end of file) determines whether the data pointer points to the end of a file (or the whole file has been read). If the data pointer does point to the end of the file, TRUE (-1) is returned, otherwise FALSE (0). CLOSE closes a data channel to a file or peripheral device previously opened with OPEN. The numerical expression n contains the number of the channel to be closed. If the channel number is omitted, all open files are closed. TOUCH updates the date and time stamps of a file, giving it the current system date and time. Examples: OPEN "o",#1,"TEST.TXT" FOR i%=1 to 20 PRINT #1,STR$(i%) NEXT i% CLOSE #1 FILES "TEST.TXT" DELAY 20 ! Wait 20 seconds OPEN "u",#1,"TEST.TXT" TOUCH #1 CLOSE #1 FILES "TEST.TXT" --> In the example the file TEST.TXT is opened, written to, and closed. Then the file information is displayed, including the time and date. Twenty seconds later the file is opened again, the date and time updated, then closed. The file information is displayed again. OPEN "i",#1,"TEST.TXT" PRINT "file length: ";LOF(#1) PRINT PRINT "data","position of the data pointer" DO UNTIL EOF(#1) INPUT #1,a$ PRINT "";a$,LOC(#1) LOOP CLOSE #1 --> The example opens the file from the previous example for reading. First the length of the file is displayed by means of LOF(). Then the contents of the file are displayed along with the associated data pointer position until the termination condition of the loop is met when EOF() is TRUE. Memo: TOUCH does not issue an error if the #channel is wrong. TOUCH doesn't work in the editor or compiled, just does nothing. CLOSE #n does not issue an error if the #channel is wrong. EOF(), LOC(), and LOF() don't issue errors if the #channel is wrong. Note: EOF() often fails on emulators using the HostFS! Failures have been seen with ARAnyM and Hatari. Solution: Use a disk image. Fclose()+, Fdatime()+