Reading Data

reclen = datasetGet (datasetHandle, buf, buflen)

The datasetGet function reads one record from the specified dataset

(datasetHandle) and puts the record into a buffer (buf) of length buflen. The datasetGet function extracts only the data entity from each record and does not transfer the BL and RL bytes for variable-length records to the buffer. Table 6-2shows the datasetGet arguments and return values.

Table 6-2 DatasetGet Function

Item

Value

Type

Description

 

 

 

 

Argument

datasetHandl

DATASET_HAND

The datasetHandle value returned by the datasetOpen

 

e

LE

function.

 

 

Buffer area for storing the read data.

 

buf

 

 

char *

Size of the buffer area. If the record is larger than buflen or equal to zero,

 

buflen

 

long

datasetGet returns an error and does not transfer any data to the buf.

 

 

 

 

 

 

 

Return value

reclen

long

Data entity size transferred to the buffer

 

-1

 

Error end

 

 

 

 

Figure 6-1shows the format requirements for variable-length records accessed by the datasetGet function. Each variable-length block must start with the two-byte BL field, and each variable-length record must start with the two- byte RL field. The datasetGet function automatically extracts the data entities without the BL and RL fields.

Block length

Record length

Data entity

 

 

 

Record length

Block Length

Record length

Data entity

 

 

Record length

Block length format:

2 bytes

2 bytes

 

 

Block length

0x0000

 

 

 

2 bytes

2 bytes

 

 

 

Record length format:

Record length

0x0000

 

 

 

Figure 6-1 Format Requirements for Reading Variable-Length Records

When the datasetGet function terminates successfully, it returns the length of the data entity read from the dataset. If the datasetGet function detects the end of dataset (EOF) or terminates unsuccessfully, it returns a value of -1. To get the error code information, execute the datasetGetLastError function (see section Acquiring Error Information). For example, when the datasetGet function detects EOF, datasetGetLastError will return DATASET_ERROR_END_OF_FILE.

Performing File Access Library (FAL) Operations

6-5

Hitachi USP V Cross-OS File Exchange User’s Guide

Page 159
Image 159
Hitachi MK-96RD647-01 manual Reading Data, DatasetGet Function, Reclen = datasetGet datasetHandle, buf, buflen