Introduction

Language Structure

IB Statements

File System

Comet 32 Runtime

Index

KEYSTAT function

Syntax: KEYSTAT(LUN) Key-Index[,EXCP=statement-label]
Discussion: The KEYSTAT function returns the Key information for a designated Keyed File.

The LUN is the Logical Unit Number on which the file is open. The LUN may be a numeric constant or numeric variable.

The Key-Index is a numeric index indicating which key for which information is requested. The Key-Index may be a numeric constant or numeric variable.

Key-Index must be a number from 0 to 99 indicating the key field index. An index of zero refers to the primary key, a key number of one refers to the first sub key etc.

The data returned by the KeyStat Function is:

Position  Length    Description/Values
===================================================================
1	   5	    Key length
6	   5	    Key Position
11	  64	    Key Name

The key Name returned is in internal format: All alpha characters are converted to upper case and internal spaces removed.

Example :

close(98) & open(98) Filename$, key="first"
.
.
for i = 0 to 99
   KeyStatus$ = KeyStat(98) i,excp=done
   keyLen = num(sub(KeyStatus$,1,5),err)
   keypos = num(sub(KeyStatus$,6,5),err)
   keyname$ = sub(KeyStatus$,11,64)
   print keyname$;keyLen;Keypos
next i
.
.
.
done:
.
.

For a discussion about using sub keys in programs go here: Keyed files