ReadRecord (Dataset function)

From m204wiki
Jump to navigation Jump to search

Read a record from this dataset (Dataset class)


Syntax

%string = dataset:ReadRecord

Syntax terms

%string A string or longstring variable to receive the block of data.
dataset A reference to an instance of a Dataset object.

Usage notes

  • The Dataset object must be an input object, that is, its Output property must be False to use the ReadRecord method. Using ReadRecord against an output dataset results in request cancellation.
  • The Dataset object must be in the Open state to use the ReadRecord method. Using ReadRecord against a dataset in the Closed or AfterEnd state results in request cancellation.
  • If a ReadRecord method is used after a ReadBlock method, the first record in the block after the block returned by the ReadBlock is returned.
  • For F or FB files, the string returned by ReadRecord has a length that is exactly equal to the RecordLength.
  • For V or VB files, the string returned by ReadRecord has a length less than the RecordLength property value. It does not contain the record's RDW, that is, it only contains the data portion of the record. As such, a program that uses ReadRecord can generally be used without modification (except for, perhaps, record padding issues) for different RecordFormats.
  • When a ReadRecord reaches the end of a file, it returns a null string and switches the dataset to the AfterEnd state. After this, a ReadRecord or ReadBlock results in request cancellation. For V or VB datasets, it is possible for ReadRecord to return a null record when it is not at the end of file. Because of this, it is probably best to check the Dataset's State property rather than using the size of the returned record to determine if the end of file has been reached.

Example

For a simple example, see "Dataset example".

See also