How do I use BOF function in QBASIC?

226 views Asked by At

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.

1

There are 1 answers

1
eoredson On

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