Top  Previous  Next


The QMReadBlk() function reads a specified number of bytes from a sequential file. It is analogous to the QMBasic READBLK statement.


The function arguments are:


FileNois the file number returned by a previous QMOpenSeq() call.


Bytesis the number of bytes to be read.


ActualBytesis an integer variable to receive the actual byte count which may be less than Bytes if the end of the data is reached. Note that this argument is not present in all variants of the QMClient API.


The QMReadBlk() function requests the server to return the given number of bytes from the file opened as FileNo.


If successful, the function returns the data and the ActualBytes variable is set to the number of bytes read.


If the data cannot be read, typically because the end of the file has been reached, the function returns a null string and the ActualBytes variable is set to zero. The QMStatus() function can be used to retrieve the error number.


Note that when using the QMClient API in its wide character (Unicode) mode, QMReadBlk is a byte level operation and returns a string in which each character will represent one byte from the file and hence is always in the range char(0) to char(255).


The example program fragments below open a sequential item named STOCK in the IMPORT file, read100 bytes of data and then closes the file. A real program should test the error status from the read to determine if the action was successful.







hmtoggle_plus1QMBasic Class Module







See also:

QMOpenSeq(), QMReadSeq(), QMSeek(), QMWeofSeq(), QMWriteBlk(), QMWriteSeq()