EOF: Difference between revisions

From QB64 Phoenix Edition Wiki
Jump to navigation Jump to search
(Created page with "The EOF function indicates that the end of a file has been reached. {{PageSyntax}} : {{Parameter|endReached%%}} = EOF([#]{{Parameter|fileNumber&}}) {{PageDescription}} * {{Parameter|fileNumber&}} is the number of the file being read. '''#''' is not required. * Returns 0 until the end of a file. This avoids a file read error. * Returns -1 (true) at the end of the file. <!-- confusing statement; further details are required: * CHR$(26) can be used to denote th...")
 
(Add information on HTTP handles)
Line 1: Line 1:
The [[EOF]] function indicates that the end of a file has been reached.
The [[EOF]] function indicates that the end of a file or HTTP response has been reached.




{{PageSyntax}}
{{PageSyntax}}
: {{Parameter|endReached%%}} =  EOF([#]{{Parameter|fileNumber&}})
: {{Parameter|endReached%%}} =  EOF([#]{{Parameter|fileNumber&}})
: {{Parameter|endReached%%}} =  EOF([#]{{Parameter|httpHandle&}})




{{PageDescription}}
{{PageDescription}}
* {{Parameter|fileNumber&}} is the number of the file being read. '''#''' is not required.
* {{Parameter|fileNumber&}} or {{Parameter|httpHandle&}} is the number of the file or HTTP connected being read. '''#''' is not required.
** {{Parameter|fileNumber&}} is a file opened using [[OPEN]].
** {{Parameter|httpHandle&}} is a HTTP connection opened using [[_OPENCLIENT]].
* Returns 0 until the end of a file. This avoids a file read error.
* Returns 0 until the end of a file. This avoids a file read error.
* Returns -1 (true) at the end of the file.
* Returns -1 (true) at the end of the file.
<!-- confusing statement; further details are required: * [[CHR$]](26) can be used to denote the end of a file. -->
<!-- confusing statement; further details are required: * [[CHR$]](26) can be used to denote the end of a file. -->
* '''Note that [[GET]] can return invalid data at the end of a file.''' Read [[EOF]] after a GET operation to see if the end of the file has been reached and discard last read.
* '''Note that [[GET]] can return invalid data at the end of a file.''' Read [[EOF]] after a GET operation to see if the end of the file has been reached and discard last read.
** This is not a problem when using [[EOF]] with HTTP connections with a variable length string, the string will always only contain valid data or be empty.





Revision as of 07:47, 6 January 2023

The EOF function indicates that the end of a file or HTTP response has been reached.


Syntax

endReached%% = EOF([#]fileNumber&)
endReached%% = EOF([#]httpHandle&)


Description

  • fileNumber& or httpHandle& is the number of the file or HTTP connected being read. # is not required.
    • fileNumber& is a file opened using OPEN.
    • httpHandle& is a HTTP connection opened using _OPENCLIENT.
  • Returns 0 until the end of a file. This avoids a file read error.
  • Returns -1 (true) at the end of the file.
  • Note that GET can return invalid data at the end of a file. Read EOF after a GET operation to see if the end of the file has been reached and discard last read.
    • This is not a problem when using EOF with HTTP connections with a variable length string, the string will always only contain valid data or be empty.


See also



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