next up previous 264
Next: Reading Objects from a Channel
Up: Saving and Restoring Objects (Channels)
Previous: Creating a Channel


Writing Objects to a Channel

The process of saving Objects is very straightforward. You can simply write any Object to a Channel using the astWrite function, as follows:

int nobj;
AstObject *object;

...

nobj = astWrite( channel, object );

The effect of this will be to produce a textual description of the Object which will appear, by default, on your program's standard output stream. Any class of Object may be converted into text in this way.

astWrite returns a count of the number of Objects written. Usually, this will be one, unless the Object supplied cannot be represented. With a basic Channel all Objects can be represented, so a value of one will always be returned unless there has been an error. We will see later, however, that more specialised forms of Channel may impose restrictions on the kind of Object you can write ([*]). In such cases, astWrite may return zero to indicate that the Object was not acceptable.


next up previous 264
Next: Reading Objects from a Channel
Up: Saving and Restoring Objects (Channels)
Previous: Creating a Channel

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

Copyright (C) 2009 Science \& Technology Facilities Council