INDEXING WITHIN A PROGRAM

Man Page Index


Once a index has been created and built using commands shown in the previous chapter, you can utilize it  with statements and functions within a jBC source.

 

INDICES - FIND INFORMATION ABOUT A FILE'S INDEXES

 

Syntax

INDICES(filevar { , index-name } )

 

Description

This function has a dual purpose. In its first invocation whereby a single parameter is passed, assumed to be a file descriptor, will return a dynamic array of all the index names associated with the file. In its second invocation two parameters are passed, the first being a file variable again and the second the name of an index. In this case the return value from the function will be a dynamic array containing information about the specified index. In the second invocation, the dynamic array has the following attributes:

 

Example

The following code example show how a file called "CUSTOMERS" can have some of the information about all of its indexes displayed.

filename = "CUSTOMERS"
OPEN filename TO filevar ELSE STOP 201,filename
index.list = INDICES(filevar)
index.count = DCOUNT(index.list, @AM)
IF NOT(index.count) THEN
    CRT filename:" has NO defined indexes"
    STOP
END
FOR index.next = 1 TO index.count
    index.name = index.list<index.next>
    index.data = INDICES(filevar,index.name)
    CRT
    CRT "Index name = ":index.name
    CRT "Definition = ":index.data<3>
    CRT "Lookup code = ":index.data<4>
    CRT "Create date = ":OCONV(INT(index.data<5>/86400)+732,"D")
    CRT "Create time = ":OCONV(MOD(index.data<5>,86400),"MTS")
NEXT index.next

Note: Attribute 12 returned with the INDICES function shows any option passed to create-index with the (Vnn) option and is therefore a count on the limit on the number of values extracted per attribute to create an index entry. By default this value is 0.


INDEXES