- Aug 9, 2022
- 23
- 3
- 3
- Customer Identifier
- E114627
Background
Clipper programmers have traditionally used the File() function for verifying whether a given index exists. When running under the ISAM emulation of the PGDBE, however, this approach can no longer be used because ISAM-emulated indexes are not maintained as separate files.Checking for the existence of an ISAM-emulated index
The easiest way to check for the existence of an index is by just trying to open it. The following code illustrates this approach.
Code:
USE customer
IF .NOT. IndexExists("custa.ntx")
OrdCreate( "custa.ntx", "custno" )
ENDIF
...
// Check whether an index exists by attempting to open it. A suitable table must be open in the current
// work area
FUNCTION IndexExists( cIndex )
LOCAL bOld
bOld := ErrorBlock( {|e| Break(e)} )
BEGIN SEQUENCE
OrdListAdd( cIndex )
RECOVER
ErrorBlock( bOld )
RETURN .F.
END SEQUENCE
ErrorBlock( bOld )
OrdListClear()
RETURN .T.
Last edited: