System Functions
KEN( ) Return Key After Next
   
Format KEN(chan[,fileopt])
 
Where:
 
  chan Channel or logical file number of your given file.
   
  fileopt Supported file options (see also, File Options):
    END=stmtref End-of-File transfer
    ERR=stmtref Error transfer
KEY=string$ Record key
KNO=num | string$ File access key number (num) or name (string$).
   
  stmtref Program line number or statement label to which to transfer control.
   
Returns Key of the record that follows the next record in the file.
   
Description The KEN( ) function returns the key of the record which directly follows the next record in the file specified. The result is based on:
  • the current file access key or,
  • the access key specified using the KNO= option.

If the '+K' system parameter is not enabled, the 'Record Key' specified must exist on the file.

See the '+K' System Parameter for more details. This functionality is a +PxPlus Exclusive

For ODBC files, the KEN( ) function supports some debugging tools:

  • KEN (nn) Returns last generated SQL statement passed to the ODBC driver
  • KEN (nn, IND=1)Returns cursor name for database
  • KEN (nn, IND=2)Returns ODBC handles.

For more information, see File Handling in the ProvideX User's Guide

   
Example 0010 OPEN (13)"INVDET"
0020 K$=KEY(13,END=1000)
0030 REM Last record is total line - different format
0040 KN$=KEN(13,END=0080); IF KN$(1,6)<>K$(1,6) GOTO 0080
0050 READ (13)IOL=8010 ! Get record
0060 GOSUB 7000 ! Process invoice line
0070 GOTO 0020
0080 READ (13)IOL=8010 ! Get total line
0090 GOSUB 7500; GOTO 0020
1000 END
 
To return the current ODBC SQL statement being passed to the ODBC driver:
OPEN (1) "[odb]Database;customer;key=custid" READ (1,KEY="MIKE")
PRINT KEN(1)
    SELECT * FROM customer WHERE custid = 'MIKE'