next up previous
Next: Reading Native Objects From a FitsChan
Up: Storing AST Objects in FITS Headers (FitsChans)
Previous: The Native FitsChan Output Format

Adding Individual Cards to a FitsChan  

To insert individual cards into a FitsChan, prior to reading them back as Objects for example, you should use the astPutFits function. You can insert a card in front of the current one as follows:

astPutFits( fitschan, card, 0 );

where the third argument of zero indicates that the current card should not be overwritten. Note that facilities are not provided by AST for formatting the card contents.

After inserting a card, the FitsChan's Card attribute points at the original Card, or at the end-of-file if the FitsChan was originally empty. Entering a sequence of cards is therefore straightforward. If ``cards'' is an array of pointers to strings containing FITS header cards and ``ncards'' is the number of cards, then a loop such as the following will insert the cards in sequence into a FitsChan:

#define MAXCARD 100
char *cards[ MAXCARD ];
int ncard;

...

for ( icard = 0; icard < ncard; icard++ ) astPutFits( fitschan, cards[ icard ], 0 );

The string containing a card need not be null terminated if it is at least 80 characters long (we have not allocated space for the strings themselves in this brief example).

Note that astPutFits enforces the validity of a FitsChan by rejecting any cards which do not adhere to the FITS standard. If any such cards are detected, an error will result.



next up previous
Next: Reading Native Objects From a FitsChan
Up: Storing AST Objects in FITS Headers (FitsChans)
Previous: The Native FitsChan Output Format

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

Copyright (C) 2003 Central Laboratory of the Research Councils