KPs: Difference between revisions
No edit summary |
|||
(3 intermediate revisions by 3 users not shown) | |||
Line 1: | Line 1: | ||
KPS(<file name> [,<[[numeric expression]]>]) | |||
The '''KPs''' [[internal function]] returns the byte position where the key for master file | The '''KPs''' [[internal function]] returns the byte position where the key for master file named starts. With an optional second parameter, KPS can also return the position of a section of a key when split keys are used. For example, in KPS(Afile,2), the starting position of the second section of the key is returned. | ||
====Comments and Examples==== | ====Comments and Examples==== | ||
Here is an example to illustrate the use of the optional second parameter for indexes with split keys. In line 1000, file #1 is opened with a key split into three parts. This line replaces the existing master file and the existing key file with newly created empty master and key files. | Here is an example to illustrate the use of the optional second parameter for indexes with split keys. In line 1000, file #1 is opened with a key split into three parts. This line replaces the existing master file and the existing key file with newly created empty master and key files. | ||
Line 22: | Line 23: | ||
The KPS function returns -1 when the file is not open or the master file has no key file. An invalid key field number will also return -1. For example, KPS(1,4) returns -1 because this file was opened with only three key fields. This result occurs whenever the specified field number is bigger than the number of fields used. | The KPS function returns -1 when the file is not open or the master file has no key file. An invalid key field number will also return -1. For example, KPS(1,4) returns -1 because this file was opened with only three key fields. This result occurs whenever the specified field number is bigger than the number of fields used. | ||
====Related Functions | ====Related Functions==== | ||
*[[EXISTS]] | *[[EXISTS]] | ||
*[[FILE$]] | *[[FILE$]] | ||
Line 28: | Line 30: | ||
*[[FREESP]] | *[[FREESP]] | ||
*[[KLN]] | *[[KLN]] | ||
*[[KREC]] | *[[KREC]] | ||
*[[LREC]] | *[[LREC]] | ||
*[[REC]] | *[[REC]] | ||
*[[RLN]] | *[[RLN]] | ||
<noinclude> | <noinclude> | ||
[[Category:Internal Functions]] | [[Category:Internal Functions]] | ||
</noinclude> | </noinclude> |
Latest revision as of 17:25, 22 May 2014
KPS(<file name> [,<numeric expression>])
The KPs internal function returns the byte position where the key for master file named starts. With an optional second parameter, KPS can also return the position of a section of a key when split keys are used. For example, in KPS(Afile,2), the starting position of the second section of the key is returned.
Comments and Examples
Here is an example to illustrate the use of the optional second parameter for indexes with split keys. In line 1000, file #1 is opened with a key split into three parts. This line replaces the existing master file and the existing key file with newly created empty master and key files.
1000 OPEN #1: "NAME=data,replace,recl=80,KFNAME=key,KPS=70/40/60,KLN=6/7/8", INTERNAL,OUTIN,KEYED
The optional second parameter of the KPS function specifies the key field number when there are split keys. Listed below are values that can be returned by the KPS function with the above OPEN statement for a key field composed of three separate fields:
KPS(1) = 70 KPS(1,1) = 70 KPS(1,0) = 70 KPS(1,2) = 40 KPS(1,4) = -1 KPS(1,3) = 60
KPS(1) returns 70 because it returns the starting position specified first for the key file. Notice that the system does not change the order of parameters; thus, even though position 40 is first physically, KPS returns these numbers according to the order in which they were specified.
The KPS function returns -1 when the file is not open or the master file has no key file. An invalid key field number will also return -1. For example, KPS(1,4) returns -1 because this file was opened with only three key fields. This result occurs whenever the specified field number is bigger than the number of fields used.