Previous Topic

Next Topic

VDataLength

Get length of variable-length data record.

Short Name

GTVLEN()

Type

Low-level variable-length data file function

Declaration

VRLEN VDataLength(COUNT datno, LONG recbyt) 

Description

VDataLength() returns the total length of the variable-length data record beginning at byte offset recbyt in file datno.

Return

If no error occurs, VDataLength() returns the total record length for the specified offset. When VDataLength() returns a zero, check uerr_cod. If uerr_cod is zero, the record length is zero. Otherwise, an error occurred as follows:

Value

Symbolic Constant

Explanation

0

NO_ERROR

Successful operation.

29

ZREC_ERR

Data file routine called with recbyt = 0.

48

FMOD_ERR

A function has been called for the wrong type of file: e.g., a variable-length function is called for a fixed-length data file.

149

VRLN_ERR

Variable-length passed to AddVRecord() is less than minimum record length established at file creation.

154

VRCL_ERR

Attempt to read (R) a zero length record from a variable-length data file.

158

VFLG_ERR

ReReadVRecord() record not marked active.

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

Example

LONG      pntr;
VRLEN     vreclen;
COUNT     datno,keyno;
TEXT      key_buffer[64];

if ((pntr = FirstKey(keyno,key_buffer)) != 0L) {
    vreclen = VDataLength(datno,pntr);
    if (uerr_cod == 0) {
        if (vreclen)
            printf(
            "\nFirst variable record by key requires %d bytes",
            vreclen);
        else
            printf("\nRecord length is zero.");
    }
    else
        printf("\nError %d getting length.", uerr_cod);
}

See also

VRecordLength()