Previous Topic

Next Topic

SetRecord

Resets the current ISAM record.

Short Name

SETCURI()

Type

ISAM function

Declaration

COUNT SetRecord(COUNT datno, LONG recbyt, pVOID recptr, VRLEN datlen); 

Description

c-tree Plus maintains the record number of the current ISAM record for each data file, as well as an image of the key buffer. There may be times when you want to reset the current ISAM record. For instance, if you want to return to a particular point in the file and index in order to continue a sequential scan of the file. By calling SetRecord(), you can set the current record offset of file datno to the value in recbyt.

recptr points to a record image. If datlen is zero, recptr should point to a complete fixed-length record, or the fixed portion of a variable-length record. Otherwise, datlen indicates the size of the information pointed to by recptr.

If recptr is NULL, only the record position is updated. This is useful when SetRecord() is used to prepare for ReReadRecord(), or ReReadVRecord(), to reread the current ISAM record.

Return

Value

Symbolic Constant

Explanation

22

FNUM_ERR

File number is out of range.

26

FACS_ERR

File number is not assigned to a file in use.

47

FINT_ERR

c-tree Plus has not been initialized.

48

FMOD_ERR

datno is not assigned to a data file.

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

Example

COUNT     datno, keyno;
LONG      custno, recpos;
TEXT      savbuf[128], buffer[128];

printf("\nEnter customer number: ");
scanf("%ld",&custno);
if (FirstInSet(keyno, &custno, savbuf, 4))
    printf("\nCould not read customer record");
else{
    recpos = CurrentFileOffset(datno);
    process_more_records_in(buffer);
    /* restore original record as current ISAM */
    SetRecord(datno,recpos,savbuf,128L);
}

Limitations

The recbyt parameter in this function is a 4-byte value capable of addressing at most 4 gigabytes. If your application supports HUGE files (greater than 4 gigabytes), you must use the ctSetHgh() and ctGetHgh() functions to set or get the high order 4 bytes of the file offset.

See also

ReReadRecord(), ReReadVRecord(), ctSetHgh(), ctGetHgh(), CurrentISAMKey(), TransformKey()