Product Documentation

FairCom ISAM for C

Previous Topic

Next Topic

SetVariableBytes

Change the values used for key padding and as a field delimiter in key construction.

Short Name

SETVARBYTS()

Type

Low-Level file resource function

Declaration

LONG SetVariableBytes(FILNO filno, pUTEXT resptr)

Description

In V12 the file number typedef was formally changed from COUNT, a two-byte value to FILNO, a four-byte value. Refer to this link for compatibility details. Four Byte File Numbering

When called for a data file, SetVariableBytes() changes the value used to pad varying length key segments as well as the byte value used to delimit varying length string fields that are not length count delimited. When called for an index file, SetVariableBytes() changes the padding byte used during trailing padding key compression. The default values are blanks for padding and NULL for the field delimiter.

filno must be opened with an ctEXCLUSIVE file mode for it to be successful. resptr points to a 2-byte array containing the values for padding (first byte) and the field delimiter (second byte). This information will be stored in the file as a resource, therefore resources must be enabled for the file.

For a related set of data and index files, SetVariableBytes() should be called for the data and index files immediately after successful creation.

Note: When using ISAM functions, be sure to specify appropriate value in the pvbyte element of the IIDX structure in addition to calling this function.

Return

Value

Symbolic Constant

Explanation

0

NO_ERROR

No error occurred.

63

LERR_ERR

The file must be opened ctEXCLUSIVE.

401

RNON_ERR

Resources are not enabled.

See c-tree Error Codes for a complete listing of valid c-tree error values.

Example

FILNO filnum;

UTEXT thebytes[2];


if (OpenDataFile(filnum,"test.dat", ctEXCLUSIVE | ctPERMANENT))

printf("\nCannot open file (%d)",uerr_cod);

else {

thebytes[0] = 00; /*set padding byte */

thebytes[1] = 32; /*set delimiter byte */

if (SetVariableBytes(filnum,thebytes)

printf("\nByte error %d",uerr_cod);

}

TOCIndex