6 WRITING AND READING OBJECTS

Having created our structure we now want to put some values into it. This can be done by using the DAT_PUT and ?? routines. For example, to fill the main data array in the above example with values we might do the following:

        ...
        BYTE IMVALS( 512, 1024 )
        CHARACTER * ( DAT__SZLOC ) LOC
  
  *  Put data from array IMVALS to the object DATA_ARRAY.
        CALL DAT_FIND( NLOC, ’DATA_ARRAY’, LOC, STATUS )
        CALL DAT_PUT( LOC, ’_UBYTE’, 2, DIMS, IMVALS, STATUS )
        CALL DAT_ANNUL( LOC, STATUS )
  
  *  Put data from character constant to the object LABEL.
        CALL DAT_FIND( NLOC, ’LABEL’, LOC, STATUS )
        CALL DAT_PUTC( LOC, 0, 0, ’This is the data label’, STATUS )
        CALL DAT_ANNUL( LOC, STATUS )
        ...

Because this sort of activity occurs quite often, “packaged” access routines have been developed and are available to the programmer (see Appendix A). A complementary set of routines also exists for getting data from objects back into program arrays or variables; these are the DAT_GET routines. Again, packaged versions exist and are often handy in reducing the number of subroutine calls required.