Previous Topic

Next Topic

ReadData

Read fixed-length data record.

Short Name

REDREC()

Type

Low-level data file function

Declaration

COUNT ReadData(COUNT datno, LONG recbyt, pVOID recptr)

Description

ReadData() reads the data record at byte position recbyt for data file datno into the buffer area pointed to by recptr. If datno refers to a variable-length file, ReadData() reads only the fixed-length portion into the buffer. Use ReReadVRecord() to read an entire variable-length record.

Return

Value

Symbolic Constant

Explanation

0

NO_ERROR

Successful read.

29

ZREC_ERR

Attempt to read at byte offset zero.

30

LEOF_ERR

recbyt exceeds the logical end of file maintained in the data file header.

33

DNUL_ERR

recptr is NULL.

35

SEEK_ERR

lseek() failed while preparing for read.

36

READ_ERR

Operating system could not execute read.

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

Example

COUNT     datno,keyno;
TEXT      recptr[1024];
LONG      part_number;

scanf("%ld",&part_number);
if (ReadData(datno, GetKey(keyno, &part_number), recptr))
    printf("\nCould not retrieve record for part #%ld", part_number);

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

ctSetHgh(), ctGetHgh(), ReReadVRecord(), ReadIsamData(), WriteData()