1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229
|
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN"
"http://www.w3.org/TR/REC-html40/loose.dtd">
<HTML>
<HEAD>
<META http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<META name="GENERATOR" content="hevea 1.08">
<LINK rel="stylesheet" type="text/css" href="gprolog.css">
<TITLE>
DEC-10 compatibility input/output
</TITLE>
</HEAD>
<BODY TEXT=black BGCOLOR=white>
<A HREF="gprolog038.html"><IMG SRC ="previous_motif.gif" ALT="Previous"></A>
<A HREF="gprolog023.html"><IMG SRC ="contents_motif.gif" ALT="Up"></A>
<A HREF="gprolog040.html"><IMG SRC ="next_motif.gif" ALT="Next"></A>
<HR>
<H3 CLASS="subsection"><A NAME="htoc171">7.16</A> DEC-10 compatibility input/output</H3><UL>
<LI><A HREF="gprolog039.html#toc134">Introduction</A>
<LI><A HREF="gprolog039.html#toc135"><TT>see/1</TT>,
<TT>tell/1</TT>,
<TT>append/1</TT></A>
<LI><A HREF="gprolog039.html#toc136"><TT>seeing/1</TT>,
<TT>telling/1</TT></A>
<LI><A HREF="gprolog039.html#toc137"><TT>seen/0</TT>,
<TT>told/0</TT></A>
<LI><A HREF="gprolog039.html#toc138"><TT>get0/1</TT>,
<TT>get/1</TT>,
<TT>skip/1</TT></A>
<LI><A HREF="gprolog039.html#toc139"><TT>put/1</TT>,
<TT>tab/1</TT></A>
</UL>
<A NAME="toc134"></A>
<H4 CLASS="subsubsection"><A NAME="htoc172">7.16.1</A> Introduction</H4>
The DEC-10 Prolog I/O predicates manipulate streams implicitly since they
only refer to current input/output streams (section <A HREF="gprolog033.html#Introduction:(Streams)">7.10.1</A>).
The current input and output streams are initially set to
<TT>user_input</TT> and <TT>user_output</TT> respectively. The predicate
<TT>see/1</TT>
(resp. <TT>tell/1</TT>, <TT>append/1</TT>) can be used for setting the
current input (resp. output) stream to newly opened streams for
particular files. The predicate <TT>seen/0</TT>
(resp. <TT>told/0</TT>) close the current input (resp. output) stream,
and resets it to the standard input (resp. output). The predicate
<TT>seeing/1</TT> (resp. <TT>telling/1</TT>) is used for retrieving
the file name associated with the current input (resp. output)
stream. The file name <TT>user</TT> stands for the standard input or
output, depending on context (<TT>user_input</TT> and
<TT>user_output</TT> can also be used). The DEC-10 Prolog I/O predicates
are only provided for compatibility, they are now obsolete and
their use is discouraged. The predicates for explicit stream manipulation
should be used instead (section <A HREF="gprolog033.html#Streams">7.10</A>).<BR>
<BR>
<A NAME="toc135"></A>
<H4 CLASS="subsubsection"><A NAME="htoc173">7.16.2</A> <TT>see/1</TT>,
<TT>tell/1</TT>,
<TT>append/1</TT></H4>
<B>Templates</B>
<DL CLASS="list" COMPACT="compact"><DT CLASS="dt-list"><DD CLASS="dd-list"><TT>
see(+source_sink)<BR>
see(+stream)<BR>
tell(+source_sink)<BR>
tell(+stream)<BR>
append(+source_sink)<BR>
append(+stream)</TT></DL>
<B>Description</B><BR>
<BR>
<TT>see(FileName)</TT> sets the current input stream to <TT>FileName</TT>.
If there is a stream opened by <TT>see/1</TT> associated with the same
<TT>FileName</TT> already, then it becomes the current input stream.
Otherwise, <TT>FileName</TT> is opened for reading and becomes the current
input stream.<BR>
<BR>
<TT>tell(FileName)</TT> sets the current output stream to <TT>FileName</TT>.
If there is a stream opened by <TT>tell/1</TT> associated with the same
<TT>FileName</TT> already, then it becomes the current output stream.
Otherwise, <TT>FileName</TT> is opened for writing and becomes the current
output stream.<BR>
<BR>
<TT>append(FileName)</TT> like <TT>tell/1</TT> but
<TT>FileName</TT> is opened for writing + append.<BR>
<BR>
A stream-term (obtained with any other built-in predicate) can also be
provided as <TT>FileName</TT> to these predicates.<BR>
<BR>
<B>Errors</B><BR>
<BR>
See errors associated with <TT>open/4</TT> (section <A HREF="gprolog033.html#open/4">7.10.6</A>).<BR>
<BR>
<B>Portability</B><BR>
<BR>
GNU Prolog predicates.<BR>
<BR>
<A NAME="toc136"></A>
<H4 CLASS="subsubsection"><A NAME="htoc174">7.16.3</A> <TT>seeing/1</TT>,
<TT>telling/1</TT></H4>
<B>Templates</B>
<DL CLASS="list" COMPACT="compact"><DT CLASS="dt-list"><DD CLASS="dd-list"><TT>
seeing(?source_sink)<BR>
telling(?source_sink)</TT></DL>
<B>Description</B><BR>
<BR>
<TT>seeing(FileName)</TT> succeeds if <TT>FileName</TT> unifies
with the name of the current input file, if it was opened by
<TT>see/1</TT>; else with the current input stream-term, if this is not
<TT>user_input</TT>, otherwise with
<TT>user</TT>. <BR>
<BR>
<TT>telling(FileName)</TT> succeeds if <TT>FileName</TT> unifies with the
name of the current output file, if it was opened by <TT>tell/1</TT> or
<TT>append/1</TT>; else with the current output stream-term, if this is not
<TT>user_output</TT>, otherwise with <TT>user</TT>. <BR>
<BR>
<B>Errors</B><BR>
<BR>
None.<BR>
<BR>
<B>Portability</B><BR>
<BR>
GNU Prolog predicates.<BR>
<BR>
<A NAME="toc137"></A>
<H4 CLASS="subsubsection"><A NAME="htoc175">7.16.4</A> <TT>seen/0</TT>,
<TT>told/0</TT></H4>
<B>Templates</B>
<DL CLASS="list" COMPACT="compact"><DT CLASS="dt-list"><DD CLASS="dd-list"><TT>
seen<BR>
told</TT></DL>
<B>Description</B><BR>
<BR>
<TT>seen</TT> closes the current input, and resets it to
<TT>user_input</TT>.<BR>
<BR>
<TT>told</TT> closes the current output, and resets it to
<TT>user_output</TT>.<BR>
<BR>
<B>Errors</B><BR>
<BR>
None.<BR>
<BR>
<B>Portability</B><BR>
<BR>
GNU Prolog predicates.<BR>
<BR>
<A NAME="toc138"></A>
<H4 CLASS="subsubsection"><A NAME="htoc176">7.16.5</A> <TT>get0/1</TT>,
<TT>get/1</TT>,
<TT>skip/1</TT></H4>
<B>Templates</B>
<DL CLASS="list" COMPACT="compact"><DT CLASS="dt-list"><DD CLASS="dd-list"><TT>
get0(?in_character_code)<BR>
get(?in_character_code)<BR>
skip(+character_code)</TT></DL>
<B>Description</B><BR>
<BR>
<TT>get0(Code)</TT> succeeds if <TT>Code</TT> unifies with the next
character code read from the current input stream. Thus it is equivalent to
<TT>get_code(Code)</TT> (section <A HREF="gprolog035.html#get-char/2">7.12.1</A>).<BR>
<BR>
<TT>get(Code)</TT> succeeds if <TT>Code</TT> unifies with the next character
code read from the current input stream that is not a layout character.<BR>
<BR>
<TT>skip(Code)</TT> skips just past the next character code <TT>Code</TT>
from the current input stream.<BR>
<BR>
<B>Errors</B><BR>
<BR>
See errors for <TT>get_code/2</TT> (section <A HREF="gprolog035.html#get-char/2">7.12.1</A>).<BR>
<BR>
<B>Portability</B><BR>
<BR>
GNU Prolog predicates.<BR>
<BR>
<A NAME="toc139"></A>
<H4 CLASS="subsubsection"><A NAME="htoc177">7.16.6</A> <TT>put/1</TT>,
<TT>tab/1</TT></H4>
<B>Templates</B>
<DL CLASS="list" COMPACT="compact"><DT CLASS="dt-list"><DD CLASS="dd-list"><TT>
put(+character_code)<BR>
tab(+evaluable)</TT></DL>
<B>Description</B><BR>
<BR>
<TT>put(Code)</TT> writes the character whose code is <TT>Code</TT> onto the
current output stream. It is equivalent to <TT>put_code(Code)</TT>
(section <A HREF="gprolog035.html#put-char/2">7.12.5</A>).<BR>
<BR>
<TT>tab(N)</TT> writes <TT>N</TT> spaces onto the current output
stream. <TT>N</TT> may be an arithmetic expression.<BR>
<BR>
<B>Errors</B><BR>
<BR>
See errors for <TT>put_code/2</TT> (section <A HREF="gprolog035.html#put-char/2">7.12.5</A>) and for arithmetic
expressions (section <A HREF="gprolog029.html#Evaluation-of-an-arithmetic-expression">7.6.1</A>).<BR>
<BR>
<B>Portability</B><BR>
<BR>
GNU Prolog predicates.<BR>
<BR>
<HR SIZE=2>
Copyright (C) 1999-2007 Daniel Diaz
<BR>
<BR>
Verbatim copying and distribution of this entire article is permitted in any
medium, provided this notice is preserved. <BR>
<BR>
<A HREF="index.html#copyright">More about the copyright</A>
<HR>
<A HREF="gprolog038.html"><IMG SRC ="previous_motif.gif" ALT="Previous"></A>
<A HREF="gprolog023.html"><IMG SRC ="contents_motif.gif" ALT="Up"></A>
<A HREF="gprolog040.html"><IMG SRC ="next_motif.gif" ALT="Next"></A>
</BODY>
</HTML>
|