One of the most important properties of HDS is that its data files are self-describing. This means that each object carries with it information describing all its attributes (not just its value), and these attributes can be obtained by means of enquiry routines. An example will illustrate:
Here, DAT_INDEX is used to get locators to objects about which (in principle) we know nothing. This is just like listing the files in a directory, except that the order in which the components are stored in an HDS structure is arbitrary (so they won't necessarily be accessed in alphabetical order).
PARAMETER (MAXCMP=10) CHARACTER*(DAT__SZNAM) NAME(MAXCMP) CHARACTER*(DAT__SZTYP) TYPE(MAXCMP) INTEGER NCOMP, I LOGICAL PRIM(MAXCMP) * Enquire the names and types of up to MAXCMP components... * First get the total number of components. CALL DAT_NCOMP(NLOC, NCOMP, STATUS) * Now index through the structure's components, obtaining locators and the * required information. DO 1 I = 1, MIN(NCOMP,MAXCMP) * Get a locator to the I'th component. CALL DAT_INDEX(NLOC, I, LOC, STATUS) * Obtain its name and type. CALL DAT_NAME(LOC, NAME(I), STATUS) CALL DAT_TYPE(LOC, TYPE(I), STATUS) * Is it primitive? CALL DAT_PRIM(LOC, PRIM(I), STATUS) CALL DAT_ANNUL(LOC, STATUS) 1 CONTINUE
ADAM The Starlink Software Environment