Input, Input$, InputB, InputB$ Functions

Syntax

Input(number, [#]filenumber)


number

Use: Required

Data Type: Numeric

Specifies the number of characters to return.


filenumber

Use: Required

Data Type: Integer

Any valid file number.

Return Value

A string (in the case of Input$ and InputB$) or a variant string (if Input or InputB) containing numbercharacters.

Description

Accesses data from within a file opened in input or binary mode.

Rules at a Glance

  • Input should be used only once with files opened in input or binary mode.

  • The function begins reading characters from the current position of the file pointer.

  • Input returns all characters it reads, regardless of their type, returning the raw data of the file. This includes spaces, carriage returns, linefeeds, commas, end-of-file markers, unprintable characters, etc.

  • Once the function finishes reading number characters, it also advances the file pointer number characters.

  • The InputB and InputB$ function variants of the Input function are used to read binary data from a file. In this case, number refers to the number of bytes to read, as opposed to the number of characters.

Programming Tips and Gotchas

  • Input reads data written to a file using either the Print# or Put statements.

  • Input always attempts to read precisely number characters from the file. If there aren't number characters from the position of the file pointer to the end of the file, Input attempts to read beyond the end of the file, thereby generating runtime error 62, "Input past end of file." To prevent this, you should use the LOF function after opening the file to insure that you don't attempt to read past the end-of-file marker.

See Also

Input# Statement, LOF Function, Open Statement, Print# Statement, Put Statement, Write# Statement
..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
18.222.204.162