next up previous 264
Next: Transforming Coordinates
Up: An AST Object Primer
Previous: Setting Attribute Values


Testing, Clearing and Defaulting Attributes

You can use the AST_GETx family of routines ([*]) to get a value for any Object attribute at any time, regardless of whether a value has previously been set for it. If no value has been set, the AST library will generate a suitable default value.

Often, the default value of an attribute will not simply be trivial (zero or blank) but may involve considerable processing to calculate. Wherever possible, defaults are designed to be real-life, sensible values that convey information about the state of the Object. In particular, they may often be based on the values of other attributes, so their values may change in response to changes in these other attributes. The ZoomMap class that we have studied so far is a little too simple to show this behaviour, but we will meet it later on.

An attribute that returns a default value in this way is said to be un-set. Conversely, once an explicit value has been assigned to an attribute, it becomes set and will always return precisely that value, never a default.

The distinction between set and un-set attributes is important and affects the behaviour of several key routines in the AST library. You can test if an attribute is set using the logical function AST_TEST, as in:

      IF ( AST_TEST( ZOOMMAP, 'Report', STATUS ) ) THEN
         <the Report attribute is set>
      END IF

(as usual, remember to include the AST_PAR file to declare the function as LOGICAL, or make this declaration yourself).

Once an attribute is set, you can return it to its un-set state using AST_CLEAR. The effect is as if it had never been set in the first place. For example:

      CALL AST_CLEAR( ZOOMMAP, 'Report', STATUS )

would ensure that the default value of the Report attribute is used subsequently.



next up previous 264
Next: Transforming Coordinates
Up: An AST Object Primer
Previous: Setting Attribute Values

AST A Library for Handling World Coordinate Systems in Astronomy
Starlink User Note 210
R.F. Warren-Smith & D.S. Berry
24th May 2011
E-mail:ussc@star.rl.ac.uk

Copyright (C) 2009 Science \& Technology Facilities Council