Because a FitsChanFitsChan 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 CardCard 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:
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:
The total number of cards in a FitsChan is given by the integer NcardNcard 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:
However, it is usually possible to write slightly tidier loops based on the astFindFitsastFindFits function described later (§16.6 and §16.13).
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.