[Top] [Prev] [Next] [Bottom]

10.12 Reading Annotations Using the AN Interface

As is the case with writing annotations there is only one AN routine used for reading annotations. This routine is described below.

10.12.1 Reading an Annotation: ANreadann

The AN programming model for reading an annotation is similar to the model for writing one:

1. Open the HDF file.
2. Initialize the AN interface.
3. Read the annotation.
4. Terminate access to the annotation.
5. Terminate access to the AN interface.
6. Close the HDF file.
To read a file label, the calling program must contain the following AN routine calls:

C:		file_id = Hopen(filename, access. block_size);
		an_id = ANstart(file_id);
		status = ANreadann(ann_id, buf, HDstrlen(buf));
		status = ANendaccess(ann_id);
		status = ANend(an_id);
		status = Hclose(file_id);

FORTRAN:	file_id = hopen(filename, access, block_size)
		an_id = afstart(file_id)
		status = afreadann(ann_id, buf, buf_length)
		status = anendaccess(ann_id)
		status = afend(an_id)
		status = hclose(file_id)

ANreadann has three parameters: ann_id, buf and buf_length. The ann_id parameter is the identifier for the annotation to be read, the buf parameter is the buffer the annotation string will be read into and the buf_length parameter is the length of the buffer. As with ANwriteann, the HDstrlen function can be used to dynamically determine the length of the buffer. In either C or Fortran-77, specifying a buffer length value different from the actual length of the buffer will result in the annotation either being truncated or null-padded accordingly.

The parameters of the ANreadann routine is further defined in the following table.

TABLE 10M ANreadann Parameter List
Routine Name

(Fortran-77)

Parameter

Data Type

Description

C

Fortran-77

ANreadann

(afreadann)

ann_id

int32

integer

Identifier of the annotation to be read.

buf

char *

character* (*)

Buffer for the returned annotation.

buf_length

int32

integer

Size of the buffer in bytes.



[Top] [Prev] [Next] [Bottom]

hdfhelp@ncsa.uiuc.edu
HDF User's Guide - 06/04/97, NCSA HDF Development Group.