3 <TITLE>How do I use push_output?</TITLE>
7 <P><B>Links</B>: <A HREF=popoutput.html>Next</A> <A HREF=output.html>Previous</A> <A HREF=sgmlspl.html>Up</A> <A HREF=sgmlspl.html>Top</A></P>
9 <H1>How do I use <TT>push_output</TT>?</H1>
12 <TT>push_output(<IT>type</IT>[,<IT>data</IT>])</TT>
13 takes two arguments: the <IT>type</IT>, which is always
14 required, and the <IT>data</IT>, which is needed for
15 certain types of output. Table 3 lists the different types which you
16 can push onto the output stack.</P>
19 <H3>Table 3: Types for <TT>push_output</TT></H3>
24 <DD><TT>'handle'</TT></DD>
27 <DT><B>Description</B></DT>
28 <DD>Send all output to the supplied filehandle.</DD>
36 <DD><TT>'file'</TT></DD>
39 <DT><B>Description</B></DT>
40 <DD>Open the supplied file for writing, erasing its current
41 contents (if any), and send all output to it.</DD>
49 <DD><TT>'append'</TT></DD>
52 <DT><B>Description</B></DT>
53 <DD>Open the supplied file for writing and append all output to its
54 current contents.</DD>
62 <DD><TT>'pipe'</TT></DD>
64 <DD>a shell command</DD>
65 <DT><B>Description</B></DT>
66 <DD>Pipe all output to the supplied shell command.</DD>
74 <DD><TT>'string'</TT></DD>
76 <DD>a string [optional]</DD>
77 <DT><B>Description</B></DT>
78 <DD>Append all output to the supplied string, which will be
79 returned by <TT>pop_output</TT>.</DD>
87 <DD><TT>'nul'</TT></DD>
90 <DT><B>Description</B></DT>
91 <DD>Ignore all output.</DD>
97 <P>Because the output is stack-based, you do not lose the previous
98 output destination when you push a new one. This is especially
99 convenient for dealing with data in tree-structures, like <A HREF="http://www.sil.org/sgml/sgml.html"><B>SGML</B></A> data
100 -- for example, you can capture the contents of sub-elements as
101 strings, ignore certain types of elements, and split the output from
102 one <A HREF="http://www.sil.org/sgml/sgml.html"><B>SGML</B></A> parse into a series of sub-files. Here are some examples:</P>
105 <PRE>push_output('string'); # append output to an empty string
106 push_output('file','/tmp/foo'); # send output to this file
107 push_output('pipe','mail webmaster'); # mail output to 'webmaster' (!!)
108 push_output('nul'); # just ignore all output</PRE>
111 <P><B>Links</B>: <A HREF=popoutput.html>Next</A> <A HREF=output.html>Previous</A> <A HREF=sgmlspl.html>Up</A> <A HREF=sgmlspl.html>Top</A></P>
114 <ADDRESS>David Megginson <A HREF="mailto:dmeggins@aix1.uottawa.ca"><dmeggins@aix1.uottawa.ca></A></ADDRESS>