We saw above () how to display the
internal values of an Object, but what about accessing these values
from a program? Not all internal Object values are accessible in this
way, but many are. Those that are, are called attributes. A
description of all the attributes used by the AST library can be found
in
.
Attributes come in several data types (character string, integer, boolean and floating point) and there is a standard way of obtaining their values. As an example, consider obtaining the value of the Nin attribute for the ZoomMap created earlier. This could be done as follows:
INTEGER NIN ... NIN = AST_GETI( ZOOMMAP, 'Nin', STATUS )
Here, the integer function AST_GETI is used to extract the attribute value by giving it the ZoomMap pointer and the attribute name (attribute names are not case sensitive, but we have used consistent capitalisation in this document in order to identify them). Remember to use the AST_PAR include file to save having to declare AST_GETI as integer yourself.
If we had wanted the value of the Zoom attribute, we would probably have used AST_GETD instead, this being a double precision version of the same function, for example:
DOUBLE PRECISION ZOOM ... ZOOM = AST_GETD( ZOOMMAP, 'Zoom', STATUS )
However, we could equally well have read the Nin value as double precision, or the Zoom value as an integer, or whatever we wanted.
The data type you want returned is specified simply by replacing the
final character of the AST_GETx function name with C (character),
D (double precision), I (integer), L (logical) or R (real). If
possible, the value is converted to the type you want. If not, an
error message will result. In converting from integer to logical, zero
is regarded as .FALSE. and non-zero as .TRUE.. Note that all floating
point values are stored internally as double precision. Boolean values
are stored as integers, but only take the values 1 and 0 (for
true/false).
AST A Library for Handling World Coordinate Systems in Astronomy