Checks whether the data found in the index file (.NDX file) properly refers the data found in the data file (.FIC file). This function applies to the HFSQL data files (Classic or Client/Server) only.
The HFSQL Client/Server data file is automatically locked in write mode during the check.
Reminder: An index is corrupted when one of the referenced records is not the expected one. In this case, the data file must be re-indexed.
Note: From version 19, HFSQL is the new name of HyperFileSQL.
// Check the index
let IndexResult = HCheckIndex(CUSTOMER)
// Manage the result
Info ("The index is correct")
Info("The file must be optimized.")
Info("HFSQL error" + HError() + " during the test")
<Result> = HCheckIndex([<File name> [, <Key name>] [, <Progress bar>]])
Can correspond to:
- 0 if the check is correct.
- 1 if the index is corrupted: a re-index operation is required (HIndex)
- 2 if an HFSQL error occurred: the data file cannot be accessed, etc.
- 3 if the function is not supported by this type of data file (xBase, AS400, ...)
<File name>: Optional character string (with or without quotes)
Name of data file used. If this name is not specified, HCheckIndex handles the last data file used by the last function for HFSQL management (starting with the letter H).
<Key name>: Optional character string (with or without quotes)
Name of the key item to check. If this parameter is not specified, all the keys of the data file are checked.
<Progress bar>: Optional character string (with or without quotes)
- Name of window where the progress bar will be displayed,
- Name of the Progress Bar control to use.
This parameter is ignored.
When the function detects a problem in the index file, the H.Comment variable contains:
<Name of affected key> + TAB + <Record number causing problem> + CR +
<Name of affected key 2> + TAB + <Record number causing problem 2> ...
<Record number causing problem> is equal to -1 if no record was defined.
Note: The H.Comment variable is not filled if the index file is entirely corrupted.