Because a FitsChan contains an ordered sequence of header cards, a mechanism is needed for addressing them. This allows you to specify where new cards are to be added, for example, or which card is to be deleted.
This role is filled by the FitsChan's integer Card attribute, which gives the index of the current card in the FitsChan. You can nominate any card you like to be current, simply by setting a new value for the Card attribute, for example:
INTEGER ICARD
...
CALL AST_SETI( FITSCHAN, 'Card', ICARD, STATUS )
where ICARD contains the index of the card on which you wish to operate next. Some functions will update the Card attribute as a means of advancing through the sequence of cards, when reading them for example, or to indicate which card matches a search criterion.
The default value for Card is one, which is the index of the first card. This means that you can ``rewind'' a FitsChan to access its first card by clearing the Card attribute:
CALL AST_CLEAR( FITSCHAN, 'Card', STATUS )
The total number of cards in a FitsChan is given by the integer Ncard attribute. This is a read-only attribute whose value is automatically updated as you add or remove cards. It means you can address all the cards in sequence using a loop such as the following:
DO 1 ICARD = 1, AST_GETI( FITSCHAN, 'Ncard', STATUS )
CALL AST_SETI( FITSCHAN, 'Card', ICARD, STATUS )
<access the current card>
1 CONTINUE
However, it is usually possible to write slightly tidier loops based
on the AST_FINDFITS function described later
( and
).
If you set the Card attribute to a value larger than Ncard, the FitsChan is regarded as being positioned at its end-of-file. In this case there is no current card and an attempt to obtain a value for the Card attribute will always return the value Ncard + 1. When a FitsChan is empty, it is always at the end-of-file.
AST A Library for Handling World Coordinate Systems in Astronomy