2017-10-10 14:55:21 +00:00
|
|
|
The [[LOF]] function is used to find the length of an [[OPEN]] file in bytes.
|
2015-08-02 12:12:44 +00:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
{{PageSyntax}}
|
2017-10-10 14:55:21 +00:00
|
|
|
: ''totalBytes&'' = [[LOF]]([#]{{Parameter|fileNumber}})
|
2015-08-02 12:12:44 +00:00
|
|
|
|
|
|
|
|
2017-10-10 14:55:21 +00:00
|
|
|
{{PageDescription}}
|
|
|
|
* LOF returns the number of bytes in an [[OPEN]]ed designated {{Parameter|fileNumber}}. File is empty if it returns 0.
|
|
|
|
* {{Parameter|fileNumber}} is the number of the opened file. '''#''' is not required.
|
2015-08-02 12:12:44 +00:00
|
|
|
* 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.
|
2017-10-10 14:55:21 +00:00
|
|
|
* LOF in '''QB64''' can return up to 9 GB (9,223,372,036 bytes) file sizes.
|
2015-08-02 12:12:44 +00:00
|
|
|
|
|
|
|
|
2017-10-10 14:55:21 +00:00
|
|
|
{{PageExamples}}
|
2015-08-02 12:12:44 +00:00
|
|
|
''Example:'' Finding the number of records in a RANDOM file using a [[TYPE]] variable.
|
|
|
|
|
|
|
|
{{CodeStart}}
|
|
|
|
OPEN file$ FOR RANDOM AS #1 LEN = {{Cl|LEN}}(Type_variable)
|
|
|
|
NumRecords% = {{Cl|LOF}}(1) \ RecordLEN%
|
|
|
|
{{CodeEnd}}
|
|
|
|
|
|
|
|
|
2017-10-10 14:55:21 +00:00
|
|
|
{{PageSeeAlso}}
|
2015-08-02 12:12:44 +00:00
|
|
|
* [[LEN]], [[EOF]], [[BINARY]], [[RANDOM]], [[TYPE]]
|
|
|
|
|
|
|
|
|
2019-04-15 01:15:33 +00:00
|
|
|
{{PageNavigation}}
|