$Currec: Difference between revisions

From m204wiki
Jump to navigation Jump to search
(Automatically generated page update)
 
No edit summary
Line 9: Line 9:
</li>
</li>
</ul>
</ul>
<b>Example</b>
<b>Examples</b>
<p>This request prints the record number of a new record:</p>
<p>This request prints the record number of a new record:</p>
<p class="code">BEGIN
<p class="code">BEGIN
Line 20: Line 20:
END   
END   
</p>
</p>
Also, the FOR RECORD NUMBER statement accepts an expression after it, for example:
<p class="code">
IN FILE CLAIMS STORE RECORD
  ...
END STORE
IN FILE CLAIMS FRN $CURREC
  ...
END FOR</p>
[[Category:SOUL $functions]]
[[Category:SOUL $functions]]

Revision as of 18:46, 5 August 2013

The $CURREC function returns an integer equal to the internal number of the current record.

At the beginning of a request, $CURREC is set to minus one, an invalid record number. The STORE RECORD statement sets $CURREC to the record number of the new record.

At the beginning of each pass through a FOR EACH RECORD loop, $CURREC is set to the record number of the record to be processed in that pass. When the FOR loop is exited, because all records have been processed or because a LOOP END or JUMP statement has been encountered, $CURREC is restored to its value prior to the FOR statement. $CURREC takes no arguments.

You should be aware of these facts when using $CURREC:

  • In a record loop on the records of a SORT statement, $CURREC is set to the record number of the record from which the temporary sort copy was made.
  • Record numbers are not unique within a file group. The number returned by $CURREC is valid only in reference to the file from which the record came.

Examples

This request prints the record number of a new record:

BEGIN GET.RECS: FIND ALL RECORDS END FIND FOR 5 RECORDS IN GET.RECS PRINT 'THE INTERNAL RECORD NO IS ' - WITH $CURREC END FOR END

Also, the FOR RECORD NUMBER statement accepts an expression after it, for example:

IN FILE CLAIMS STORE RECORD ... END STORE IN FILE CLAIMS FRN $CURREC ... END FOR