@c io.texi
     
@c This file is part of the 3DLDF User and Reference Manual.
@c Copyright (C) 2003, 2004 Laurence D. Finston 
@c See the section "GNU Free Documentation License" in the file 
@c fdl.texi for copying conditions.

@c $Id: io.texi,v 1.3 2004/01/12 18:39:33 lfinsto1 Exp lfinsto1 $
  
@node Input and Output, Shape Reference, Color Reference, Top
@chapter Input and Output

@menu
* I/O Global Variables::        
* I/O Functions::               
@end menu
 
@node I/O Global Variables, I/O Functions, Input and Output, Input and Output
@section Global Variables

@deftypevar ifstream in_stream
Intended for inputting files of input code.  However, 3DLDF does not
currently have a routine for reading input code.
@code{in_stream} is currently attached to the file @file{ldfinput.ldf}
by @code{initialize_io()} (@pxref{I/O Functions}).
@code{in_stream} is read in character-by-character in @code{main()},
however this serves no useful purpose as yet.
@end deftypevar 


@deftypevar ofstream out_stream
Used for writing the file of MetaPost code, which is 3DLDF's output.
Currently attached to the file @file{subpersp.mp} by
@code{initialize_io()} (@pxref{I/O Functions}).
@end deftypevar 

@deftypevar ofstream tex_stream
@TeX{} code can be written to a file through @code{tex_stream}, if
desired.  3DLDF makes no use of it itself.  
Currently attached to @file{subpersp.tex} by 
@code{initialize_io()} (@pxref{I/O Functions}).
@end deftypevar 
  
@node I/O Functions,  , I/O Global Variables, Input and Output
@section I/O Functions

@deftypefun void initialize_io (string @var{in_stream_name}, string @var{out_stream_name}, string @var{tex_stream_name}, char* @var{program_name})
Opens files with names specified by the first three arguments, and
attaches them to the file streams @code{in_stream}, @code{out_stream}, and
@code{tex_stream}, respectively.  Comments are written at the beginning
of the files, containing their names, a datestamp, and the name of the
program used to generate them.
@end deftypefun 

@deftypefun void write_footers (void)
Writes code at the end of the files attached to @code{in_stream},
@code{out_stream}, and @code{tex_stream}, before the streams are
closed.  Currently, they write comments containing 
@c
@cindex local variable lists 
@c
local variable lists
for use in 
@c
@cindex Emacs 
@c
Emacs.
@end deftypefun 

@deftypefn {Inline function} void beginfig ({unsigned short} @var{i})
Writes ``@code{beginfig(@var{i})}'' to @code{out_stream}. 
@end deftypefn 

@deftypefn {Inline function} void endfig ([{unsigned short} @var{i} = 0])
Writes ``@code{endfig()}'' to @code{out_stream}.  The argument @var{i}
is ``syntactic sugar'';  it's ignored by @code{endfig()}, 
but may help the user keep track of what figure is being ended.
@end deftypefn 

