Adding and Dropping Keys
Btrieve provides two operations for adding and dropping keys in your files: Create Index (31) and Drop Index (32). The Create Index operation is useful for adding keys to a file after the file has been created. The Drop Index operation is useful for removing keys whose index pages have become damaged. After dropping a key, you can re-add it, which causes the MicroKernel to rebuild the index.
When you drop a key, the MicroKernel renumbers all higher-numbered keys, unless you specify otherwise. The MicroKernel renumbers the keys by decrementing all higher-numbered keys by 1. For example, suppose you have a file with key numbers 1, 4, and 7. If you drop key 4, the MicroKernel renumbers the keys as 1 and 6.
If you do not want the MicroKernel to automatically renumber keys, add a bias of 0x80 to the value you supply for the Key Number parameter. This allows you to leave gaps in the key numbering; consequently, you can drop a damaged key and then rebuild it without affecting the numbering of other keys in the file. You rebuild the index using the Create Index operation (31), which allows you to specify a key number.
*Note: If you dropped a key without renumbering and a user then cloned the affected file without assigning specific key numbers, the cloned file would have different key numbers than the original.