ReadRecord (Dataset function): Difference between revisions

From m204wiki
Jump to navigation Jump to search
m (1 revision)
mNo edit summary
Line 1: Line 1:
{{Template:Dataset:ReadRecord subtitle}}
{{Template:Dataset:ReadRecord subtitle}}


This function reads a record of data from an input <var>Dataset</var>.
==Syntax==
==Syntax==
{{Template:Dataset:ReadRecord syntax}}
{{Template:Dataset:ReadRecord syntax}}
Line 7: Line 6:
<table class="syntaxTable">
<table class="syntaxTable">
<tr><th>%string</th>
<tr><th>%string</th>
<td>A string or longstring variable to receive the block of data.
<td>A string or [[Longstrings|longstring]] variable to receive the block of data.
</td></tr>
</td></tr>
<tr><th>%dataset</th>
<tr><th>dataset</th>
<td>A reference to an instance of a <var>Dataset</var> object.
<td>A reference to an instance of a <var>Dataset</var> object.
   
   
Line 26: Line 25:
is exactly equal to the <var>RecordLength</var>.
is exactly equal to the <var>RecordLength</var>.
<li>For V or VB files, the string returned by <var>ReadRecord</var> has a length less
<li>For V or VB files, the string returned by <var>ReadRecord</var> has a length less
than the <var>[[RecordLength property|RecordLength]]</var> property.
than the <var>[[RecordLength (Dataset property)|RecordLength]]</var> property.
It does '''not''' contain the record's RDW, that is, it only contains the
It does '''not''' contain the record's RDW, that is, it only contains the
data portion of the record.
data portion of the record.

Revision as of 22:14, 20 May 2011

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. 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.

See also