-1

I came to know that there is a BOF function available to use in QBASIC. It is called the Beginning Of File. But, I didn't find any examples over its use. Please help.

Hello World
  • 103
  • 1
  • 2
  • 6
  • 2
    How did you come to know about it? That source should also have provided enough information to show how it is used. – Raymond Chen Dec 28 '16 at 15:41
  • There is no BOF function in QB because the beginning of file is either 1 or 0 if the file does not exist or has been opened for the first time. – eoredson Dec 30 '16 at 02:39
  • 1
    [There is no built-in BOF function](https://gamma.zem.fi/~fis/qb.html#LTk5OTc=) because it's generally not needed and because you can just use `IF SEEK(file) = 1` to tell if you're at the beginning of the file. – Chai T. Rex Dec 31 '16 at 00:44
  • You didn't specify if BOF returns the beginning of a file or if the file is at BOF. – eoredson Dec 31 '16 at 23:18

1 Answers1

-1

Here is an example for a possible BOF function:

' example BOF function in QB
'   returns beginning of file
PRINT "Enter filename";: INPUT F$
Handle = FREEFILE
OPEN F$ FOR BINARY AS #Handle
PRINT "BOF="; BOF(Handle)
END

' function to get BOF
FUNCTION BOF (H)
IF LOF(H) > 0 THEN
    BOF = 1
ELSE
    BOF = 0
END IF
END FUNCTION

Sample to determine if file is at BOF:

' example BOF function in QB
'   returns true if at beginning of file.
PRINT "Enter filename";: INPUT F$
Handle = FREEFILE
OPEN F$ FOR BINARY AS #Handle
IF BOF(Handle) THEN
    PRINT "File is at BOF"
END IF
END

' function to get BOF
FUNCTION BOF (H)
IF LOC(H) <= 1 THEN
    BOF = -1
ELSE
    BOF = 0
END IF
END FUNCTION
eoredson
  • 1,167
  • 2
  • 14
  • 29