create-index Command
The create-index BASIC program creates a new B-tree index in the specified file using the a (algebraic) processing code expression provided and ensures the a0 index case-sensitivity matches the item-ID case sensitivity.
|
NOTE—
|
For the a0 index only, the c option must be used if the file was created with the s option. If the file was not created with the s option, the c option may not be used when creating the a0 index for that file.
|
Syntax
create-index file.reference a.code {(options)}
create-index file.reference attribute defining item {(options)}
create-index file.reference * {(options)}
Parameter(s)
|
a.code
|
Specifies the a processing code to be used in forming the keys to the index. The processing code must include an attribute number immediately after the a. The first attribute number in the processing code is the master attribute. This attribute determines the number of values that an index key generates.
|
|
specifier
|
*
|
Designates all indexes. This may be used as an alternate to a series of create-index commands by placing the i processing codes directly into the correlative position of file-defining item (D-pointer), and then using the asterisk with the create-index command.
|
|
options
|
c
|
Specifies the keys are case sensitive. Default is case insensitive. If the * specifier is used, the index(es) will remain case insensitive.
|
|
f
|
For Windows only: Creates floating-point indexes (where the keys are floating-point numbers, such as '1.234E123'. 2. Index keys may be normalized (plus signs and non-significant digits are removed, and decimal points are moved). For example, '+00123e12' is entered in the index as '123e12'.
TIP—If the keys do not have exponents (for example, '123.456', use numeric indexes instead.
|
|
l
|
Locks the file on which it is currently working to facilitate parallel access by other users. The l option forces a create-index to lock the entire file during index creation.
|
|
n
|
For Windows only: Creates numeric indexes. Numeric indexes are sorted according to their numerical value, (for example, '10.5' is greater than '9.34'). The Windows locale settings are used when identifying the decimal and thousands separators.
• When a key is stored into the index, it is normalized to reduce its size. Leading and trailing spaces and zeroes, thousands delimiters and the '+' sign are removed (e.g. ' +01,234.10' is stored as '1234.1'; ' -00123.00' is stored as '-123'). Therefore, on a simple index like 'A1', the data in the file may be different from the index.
• When searching for the first entry in the index, use the smallest expected negative number as the first search key. The empty string "" is considered to be 0. For example:
s=-9999
i=''
key('n',r,s,i) then...
finds -9000, but does not find -10000.
• Inserting non-numeric keys in the index produces unpredictable results.
• Once a numeric index has been created, it cannot be changed. The index must be deleted and recreated. There is no method for determining whether an existing index is numeric or not.
• Because the locale is used to determine the thousands and decimal separators, it is recommended to use correlatives (not delimiters) for formatting. This insures correct format when accessing the index from locations with different locales.
|
|
s
|
Suppresses the display of the running count of items.
|
|
WARNING—
|
It is not valid to create an index with a translate to the same file.
|
An a processing code, attribute defining item or an asterisk must be specified.
Once an index has been created, any changes made to the file through any process that updates the file are automatically reflected in the index.
An existing index can be overwritten using the o option.
The pointer to the index is placed in the correlative attribute of the file-defining item (attribute 8) as an i processing code.
VME indexes
The number following i indicates the root FID of the index in the VME. This should never be manually altered.
VME index keys have a maximum length of 249.
FSI indexes
The number following i indicates the number of the index in the FSI. This should never be manually altered.
FSI index keys have no maximum length.
Simulating Numeric Indexes from the VME
Numeric indexes can only be created on D3 NT FSI files but to simulate a numeric index from the VME, you can mask the attribute number as shown below in the create-index command. Note that a simulated numeric index is right-justified in a padded field of zeros (0).
create-index filename ax(mr%y)
where:
|
filename
|
File upon which the index is to be created.
|
|
x
|
Attribute number to be indexed.
|
|
y
|
Maximum number of digits in the numeric values.
|
Example(s)
create-index entity a1
Creates an index on the contents of attribute 1.
create-index invoices a3(taccount,customer.file,;x;;1)
Creates an index on the results returned from attribute 3 of invoices, translated to customer.file, and returning attribute 1 from the item, if found.
create-index sales a1:3
Creates an index on attribute 1 concatenated with attribute 3.
The example below illustrates how a series of indexes can be built.
1. Index references are placed in the correlative attribute (8) of the (entity) files D-pointer. For example:
correlative Ia1
Ia23
2. The command is issued.
create-index entity *
Afterwards, the correlative attribute contains the root FID for each of the indexes.
See Also
a (Algebraic) Processing Code
B-Tree
begin work Statement
clear-index Command
Cruising
delete-index Command
i (Local Index) Processing Code
indexer Command
nframe-index Command
root Statement
verify-index Command