next up previous
Next: Modifying Past History
Up: THE HISTORY COMPONENT
Previous: Accessing History by Date and Time

Accessing Past History Text  

The history text is perhaps the item of most interest associated with a history record. No routine is provided for accessing this directly, but NDF_HOUT may be used to pass it to a service routine, which may then handle it in any way required. Most commonly, this will involve displaying the text, for which a default service routine NDF_HECHO is provided. NDF_HECHO is a very simple routine and is described in Appendix [*], but an outline of how it works is given here:

      SUBROUTINE NDF_HECHO( NLINES, TEXT, STATUS )
      INCLUDE 'SAE_PAR'

      INTEGER NLINES, STATUS, I
      CHARACTER TEXT( NLINES ) * ( * )

*  Check status.
      IF ( STATUS .NE. SAI__OK ) RETURN

*  Print out each line of text.
      DO 1 I = 1, NLINES
         CALL MSG_FMTC( 'TEXT', '3X,A', TEXT( I ) )
         CALL MSG_OUT( ' ', '^TEXT', STATUS )
 1    CONTINUE

      END

To invoke this as a service routine, it is passed as an argument to NDF_HOUT, as follows:

      EXTERNAL NDF_HECHO

      ...

      CALL NDF_HOUT( INDF, IREC, NDF_HECHO, STATUS )

Note that it must be declared in a Fortran EXTERNAL statement.

NDF_HECHO provides a template if you wish to write your own service routine. By doing so, it is possible to perform other types of processing on history text. For instance, the following skeleton routine sets a logical value indicating whether the text of a history record contains a given sub-string (stored in the variable KEY), thus allowing a simple keyword search through history records to be performed:

      SUBROUTINE SEARCH( NLINES, TEXT, STATUS )
      INCLUDE 'SAE_PAR'

      CHARACTER KEY * ( 30 ), TEXT( NLINES ) * ( * )
      INTEGER I, NLINES, STATUS
      LOGICAL FOUND

      COMMON /KEYBLK/ KEY
      COMMON /FNDBLK/ FOUND

*  Initialise and check status.
      FOUND = .FALSE.
      IF ( STATUS .NE. SAI__OK ) RETURN

*  Search each text line in the record for the keyword.
      DO 1 I = 1, NLINES
        IF ( INDEX( TEXT( I ), KEY ) .NE. 0 ) THEN

*  Note when found.
           FOUND = .TRUE.
           GO TO 2
        END IF
 1    CONTINUE
 2    CONTINUE

      END

Note that additional data must be passed to and from such a service routine through global variables held in common blocks.



next up previous
Next: Modifying Past History
Up: THE HISTORY COMPONENT
Previous: Accessing History by Date and Time


Starlink User Note 33
R.F. Warren-Smith
11th January 2000
E-mail:rfws@star.rl.ac.uk

Copyright © 2000 Council for the Central Laboratory of the Research Councils