User Guide

Performing File Access Library (FAL) Operations 6-5
Hitachi USP V Cross-OS File Exchange User’s Guide
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-2 shows the datasetGet arguments and return values.
Table 6-2 DatasetGet Function
Item Value Type Description
Argument
datasetHandl
e
buf
buflen
DATASET_HAND
LE
char *
long
The datasetHandle value returned by the datasetOpen
function.
Buffer area for storing the read data.
Size of the buffer area. If the record is larger than buflen or equal to zero,
datasetGet returns an error and does not transfer any data to the buf.
Return value reclen
-1
long Data entity size transferred to the buffer
Error end
Figure 6-1 shows 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 Data entity
Record length Record length
Block Length
2 bytes 2 bytes
Block length format: 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.