| System Functions |
|
| Format | KEY(chan[,fileopt])
|
|||||||||||||||||||
| Returns | Key of next record in file | |||||||||||||||||||
| Description | The
KEY( ) function returns the key of
either the next record in the file specified or, via the IND=
or RNO= options, the key of the record
at the index/record number specified. The result is based
on:
For more information, see File Handling in the ProvideX User's Guide. |
|||||||||||||||||||
| Generate Key option | The
new KEY function allows the user to get the internal
generated key value for a file when specifying a KEY=
option in the function. This feature is supported for
those files/tables that allow multi-segment alternate
keys such as standard PVX keyed files, EFF files,
Databases, and Memory tables. Internally when dealing with a mutliple segment alternate key the system generates a simple string consisting of the various field values used to reference the file. When accessing a file by a multi-segmented key, the programmer can specify each of the segment values to be provided in the KEY= clause of the I/O operation with each key segment separated by a colon. For example READ (1, KEY=A$:B$:C$) tells the system to use A$ as the value for the first field segment of the key, B$ for the second, and C$ the third. The KEY function allows you to specify a KEY= clause with the segments in order to return the generated key based on the segments you provided. For example, a multi-segment key with the following segments: the first is 10-characters long, the second is 5-characters long, and the third is 5-characters long. A KEY(fileno, KEY=A$:B$:C$) will return a string comprised of the individual key elements, each $00$ padded to the corresponding lengths of the multi-segment key. Therefore, A$ would be a length of 10, B$ would be a length of five, etc. The KNO= clause can be specified in order select the specific key you want generated. A typical example might be to set the BEGIN or END values in a SELECT directive as in:
A KEY function that specifies a KEY= clause does not affect the current status or position of the file.
|
|||||||||||||||||||
| Example | 0010
OPEN (13)"CUSTNO" 0020 LET K$=KEY(13,END=1000) 0030 READ (13,KEY=K$)R$ 0040 PRINT "Key: ",K$," Data: ",R$ 0050 GOTO 0020 1000 PRINT "End-of-file" 1010 END |
|||||||||||||||||||