LOF

From QB64 Phoenix Edition Wiki
Revision as of 15:54, 19 April 2022 by BigRon55 (talk | contribs) (Created page with "The LOF function is used to find the length of an OPEN file in bytes. {{PageSyntax}} : ''totalBytes&'' = LOF([#]{{Parameter|fileNumber}}) {{PageDescription}} * LOF returns the number of bytes in an OPENed designated {{Parameter|fileNumber}}. File is empty if it returns 0. * {{Parameter|fileNumber}} is the number of the opened file. '''#''' is not required. * Often used to determine the number of records in a RANDOM access file. * Can also be used...")
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to navigation Jump to search

The LOF function is used to find the length of an OPEN file in bytes.


Syntax

totalBytes& = LOF([#]fileNumber)


Description

  • LOF returns the number of bytes in an OPENed designated fileNumber. File is empty if it returns 0.
  • fileNumber is the number of the opened file. # is not required.
  • Often used to determine the number of records in a RANDOM access file.
  • Can also be used to avoid reading an empty file, which would create an error.
  • LOF in QB64 can return up to 9 GB (9,223,372,036 bytes) file sizes.


Examples

Example: Finding the number of records in a RANDOM file using a TYPE variable.

  OPEN file$ FOR RANDOM AS #1 LEN = LEN(Type_variable)
  NumRecords% = LOF(1) \ RecordLEN%


See also



Navigation:
Main Page with Articles and Tutorials
Keyword Reference - Alphabetical
Keyword Reference - By usage
Report a broken link