The BSKEY structure is a structure to define an individual key field.
typedef struct { unsigned long key_position; unsigned long key_length; unsigned char key_type; unsigned char key_order; unsigned char key_option; unsigned char key_option2; BSPTR_VOID subfield_addr; } BSKEY;
BSKEY structure member
In the following, it explains about the member of the BSKEY structure.
key_position
This specifies the position of the key field.
To specify the binary files and text file fixed fields, specify the byte position where the head of the record was assumed to be 0. For the specification of the text file floating field, text file CSV format, and text file TSV format, specify the field number counted from 0.
key_length
This specifies the length of the key field in the number of bytes.
For the text file floating field specification, text file CSV format, and text file TSV format, process with the length specified here when the actual fields are longer than the specified field length. When the actual fields are shorter than the specified field length, the actual field length is processed.
To specify an unsigned binary number (BSKEY_BIT) for a data format (key_type), specify mask value for this member. The logical products of the field value and mask value are considered to be the key value.
Note
The length of the key field does not contain double quotation marks (") that enclose the field for text file CSV format and text file TSV format. When two consecutive double quotation marks ("") are included in the field, they are interpreted as one double quotation mark (").
Example: Key field and length in text file CSV format.
Key field Characters effective as key field Length of key field ABC ABC 3bytes "ABC" ABC 3bytes "A""B""C" A"B"C 5bytes "A,B,C" A,B,C 5bytes
key_type
This specifies the data format of the key field.
For more information, refer to the Data formats that can be specified in the key field.
key_order
This specifies sorting order of the key field.
Specify either of the following.
Define value | Meaning |
---|---|
BS_ASCND | This shows ascending order is set. (Default value) |
BS_REVRS | This shows descending order is set. |
key_option
This specifies operation of the key field.
It is effective only for the text file. Specify the following according to the necessity. When selecting two or more values specify the logical sum.
Define value | Meaning |
---|---|
BSOPT_BLANK | Blanks and tabs in the head of the key field are disregarded. |
BSOPT_DICTIONARY | Only the blank and the alphanumeric character are compared. |
BSOPT_IGNORE | Control character codes are disregarded. |
BSOPT_JUMBO | Lowercase letters are compared as uppercase letters. |
BSOPT_NUMERIC | Character strings of the numbers that contains signs are compared with arithmetic value. The result is not guaranteed when characters other than the numbers exist in the character string. When the data format is ASCII code, EBCDIC code or Unicode, it can be specified. It is in the exclusive relationship with BSOPT_CHARNUM and BSOPT2_WCHR of key_option2. |
BSOPT_CHARNUM | Connected data of alphabet and numbers (for instance, data123 ) are evaluated and sorted separately for the alphabet and the numerical value. After only alphabets are targeted for the comparison and compared, character strings exclusively with numbers are compared with arithmetic value. Data is evaluated from the left of the specified field, and the data that appeared after effective data is disregarded. It can be specified when the data format is ASCII code, EBCDIC code or Unicode. It is in the exclusive relationship with BSOPT_NUMERIC and BSOPT2_WCHR of key_option2. |
Note
If modify collation sequence (BSKEY_COL) is specified as the data format of the key field, key_option cannot be specified.
When Character form two digit years is specified for a data format of the key field, the specification of the key option is ignored.
key_option2
This specifies operation of the key field.
This member is in the exclusive relationship with BSOPT_NUMERIC of key_option and BSOPT_CHARNUM of key_option. Specify the following according to the necessity.
Define value | Meaning |
---|---|
BSOPT2_WCHR | Even if there are consecutive multi-byte characters, each character is compared. |
Note
If modify collation sequence (BSKEY_COL) is specified as the data format of the key field, key_option2 cannot be specified.
When character form two digit years, packed decimal form two digit years, external decimal form two digit years and decimal form two digit years are specified for a data form of the key field, the specification of the key option2 is ignored.
subfield_addr
This specifies the modify collation sequence function.
When using the modify collation sequence function, specify the address of the BSCOL structure that defined the modify collation sequence. The modify collation sequence function can be used when BSKEY_COL is specified for key_type of BSKEY structure.
Information
For the binary file variable-length record form or the text file, when the record where the key field does not exist is input, the value of the part where the key field does not exist is processed as 0.
Example 1) binary file variable-length record form or the text file fixed field:
key field:6.4asca 0123456789 : Record where key field exists 012345 : Record where key field doesn't exist
Example 2) the text file floating field, the text file CSV format or the text file TSV format:
key field:2.1asca fld0,fld1,fld2,fld3 : Record where key field exists fld0,fld1 : Record where key field doesn't exist fld0,fld1,,fld3 : Record where key field doesn't exist