Sophie

Sophie

distrib > Mandriva > 2010.0 > i586 > by-pkgid > 2fc07611b08d4a735fd34d5eb60d8e16 > files > 2199

ciao-1.10p8-3mdv2010.0.i586.rpm

<HTML>
<HEAD>
<!-- Created by texi2html 1.56k + clip patches and <A href="http://www.clip.dia.fi.upm.es/Software">lpdoc</A> from ciao.texi on 28 January 2007 -->

<LINK rel="stylesheet" href="ciao.css" type="text/css">
<TITLE>The Ciao Prolog System               - Basic input/output</TITLE>
</HEAD>
<BODY> 
Go to the <A HREF="ciao_1.html">first</A>, <A HREF="ciao_24.html">previous</A>, <A HREF="ciao_26.html">next</A>, <A HREF="ciao_241.html">last</A> section, <A HREF="ciao_toc.html">table of contents</A>.
<P><HR><P>


<H1><A NAME="SEC157" HREF="ciao_toc.html#TOC157">Basic input/output</A></H1>
<P>
<A NAME="IDX1723"></A>


<P>
<STRONG>Author(s):</STRONG> Daniel Cabeza, Mats Carlsson.


<P>
<STRONG>Version:</STRONG> 1.10#7 (2006/4/26, 19:22:13 CEST)


<P>
<STRONG>Version of last change:</STRONG> 1.9#285 (2004/2/13, 17:36:9 CET)


<P>
This module provides predicates for character input/output and for canonical term output. From the 
<A NAME="IDX1724"></A>
ISO-Prolog predicates for character input/output, only the <CODE>_code</CODE> versions are provided, the rest are given by 
<A NAME="IDX1725"></A>
<CODE>library(iso_byte_char)</CODE>, using these. Most predicates are provided in two versions: one that specifies the input or output stream as the first argument and a second which omits this argument and uses the current input or output stream.



<UL>
<LI><A HREF="ciao_25.html#SEC158">Usage and interface (io_basic)</A>
<LI><A HREF="ciao_25.html#SEC159">Documentation on exports (io_basic)</A>
</UL>



<H2><A NAME="SEC158" HREF="ciao_toc.html#TOC158">Usage and interface (<CODE>io_basic</CODE>)</A></H2>

<div class="cartouche">

<UL>

<LI><STRONG>Library usage:</STRONG>

These predicates are builtin in Ciao, so nothing special has to be done to use them.

<LI><STRONG>Exports:</STRONG>


<UL>

<LI><EM>Predicates:</EM>

<A NAME="IDX1726"></A>
<CODE>get_code/2</CODE>, 
<A NAME="IDX1727"></A>
<CODE>get_code/1</CODE>, 
<A NAME="IDX1728"></A>
<CODE>get1_code/2</CODE>, 
<A NAME="IDX1729"></A>
<CODE>get1_code/1</CODE>, 
<A NAME="IDX1730"></A>
<CODE>peek_code/2</CODE>, 
<A NAME="IDX1731"></A>
<CODE>peek_code/1</CODE>, 
<A NAME="IDX1732"></A>
<CODE>skip_code/2</CODE>, 
<A NAME="IDX1733"></A>
<CODE>skip_code/1</CODE>, 
<A NAME="IDX1734"></A>
<CODE>skip_line/1</CODE>, 
<A NAME="IDX1735"></A>
<CODE>skip_line/0</CODE>, 
<A NAME="IDX1736"></A>
<CODE>put_code/2</CODE>, 
<A NAME="IDX1737"></A>
<CODE>put_code/1</CODE>, 
<A NAME="IDX1738"></A>
<CODE>nl/1</CODE>, 
<A NAME="IDX1739"></A>
<CODE>nl/0</CODE>, 
<A NAME="IDX1740"></A>
<CODE>tab/2</CODE>, 
<A NAME="IDX1741"></A>
<CODE>tab/1</CODE>, 
<A NAME="IDX1742"></A>
<CODE>code_class/2</CODE>, 
<A NAME="IDX1743"></A>
<CODE>getct/2</CODE>, 
<A NAME="IDX1744"></A>
<CODE>getct1/2</CODE>, 
<A NAME="IDX1745"></A>
<CODE>display/2</CODE>, 
<A NAME="IDX1746"></A>
<CODE>display/1</CODE>, 
<A NAME="IDX1747"></A>
<CODE>displayq/2</CODE>, 
<A NAME="IDX1748"></A>
<CODE>displayq/1</CODE>.

</UL>

</UL>

</div class="cartouche">



<H2><A NAME="SEC159" HREF="ciao_toc.html#TOC159">Documentation on exports (<CODE>io_basic</CODE>)</A></H2>
<P>
<A NAME="IDX1749"></A>
<A NAME="IDX1750"></A>
<DL>
<DT><span class="define">PREDICATE:</span> <B>get_code/2:</B>
<DD><A NAME="IDX1751"></A>


<P>
<CODE>get_code(Stream, Code)</CODE>


<P>
Reads from <CODE>Stream</CODE> the next character and unifies <CODE>Code</CODE> with its character code. At end of stream, unifies <CODE>Code</CODE> with the integer -1.


<P>
<STRONG>Usage:</STRONG> <CODE>get_code(+stream, ?int)</CODE>
<KBD> * ISO * </KBD>

<UL>
<LI><EM>The following properties hold globally:</EM>

This predicate is understood natively by CiaoPP.
 (<CODE>basic_props:native/1</CODE>)
</UL>

</DL>

<P>
<A NAME="IDX1752"></A>
<A NAME="IDX1753"></A>
<DL>
<DT><span class="define">PREDICATE:</span> <B>get_code/1:</B>
<DD><A NAME="IDX1754"></A>


<P>
<CODE>get_code(Code)</CODE>


<P>
Behaves like <CODE>current_input(S), get_code(S,Code)</CODE>.


<P>
<STRONG>Usage:</STRONG> <CODE>get_code(?int)</CODE>
<KBD> * ISO * </KBD>

<UL>
<LI><EM>The following properties hold globally:</EM>

This predicate is understood natively by CiaoPP.
 (<CODE>basic_props:native/1</CODE>)
</UL>

</DL>

<P>
<A NAME="IDX1755"></A>
<A NAME="IDX1756"></A>
<DL>
<DT><span class="define">PREDICATE:</span> <B>get1_code/2:</B>
<DD><A NAME="IDX1757"></A>


<P>
<CODE>get1_code(Stream, Code)</CODE>


<P>
Reads from <CODE>Stream</CODE> the next non-layout character (see 
<A NAME="IDX1758"></A>
<CODE>code_class/2</CODE>) and unifies <CODE>Code</CODE> with its character code. At end of stream, unifies <CODE>Code</CODE> with the integer -1.


<P>
<STRONG>Usage:</STRONG> <CODE>get1_code(+stream, ?int)</CODE>

<UL>
<LI><EM>The following properties hold globally:</EM>

This predicate is understood natively by CiaoPP.
 (<CODE>basic_props:native/1</CODE>)
</UL>

</DL>

<P>
<A NAME="IDX1759"></A>
<A NAME="IDX1760"></A>
<DL>
<DT><span class="define">PREDICATE:</span> <B>get1_code/1:</B>
<DD><A NAME="IDX1761"></A>


<P>
<CODE>get1_code(Code)</CODE>


<P>
Behaves like <CODE>current_input(S), get1_code(S,Code)</CODE>.


<P>
<STRONG>Usage:</STRONG> <CODE>get1_code(?int)</CODE>

<UL>
<LI><EM>The following properties hold globally:</EM>

This predicate is understood natively by CiaoPP.
 (<CODE>basic_props:native/1</CODE>)
</UL>

</DL>

<P>
<A NAME="IDX1762"></A>
<A NAME="IDX1763"></A>
<DL>
<DT><span class="define">PREDICATE:</span> <B>peek_code/2:</B>
<DD><A NAME="IDX1764"></A>


<P>
<CODE>peek_code(Stream, Code)</CODE>


<P>
Unifies <CODE>Code</CODE> with the character code of the next character of <CODE>Stream</CODE>, leaving the stream position unaltered. At end of stream, unifies <CODE>Code</CODE> with the integer -1.


</DL>

<P>
<A NAME="IDX1765"></A>
<A NAME="IDX1766"></A>
<DL>
<DT><span class="define">PREDICATE:</span> <B>peek_code/1:</B>
<DD><A NAME="IDX1767"></A>


<P>
<CODE>peek_code(Code)</CODE>


<P>
Behaves like <CODE>current_input(S), peek_code(S,Code)</CODE>.


</DL>

<P>
<A NAME="IDX1768"></A>
<A NAME="IDX1769"></A>
<DL>
<DT><span class="define">PREDICATE:</span> <B>skip_code/2:</B>
<DD><A NAME="IDX1770"></A>


<P>
<CODE>skip_code(Stream, Code)</CODE>


<P>
Skips just past the next character code <CODE>Code</CODE> from <CODE>Stream</CODE>.


</DL>

<P>
<A NAME="IDX1771"></A>
<A NAME="IDX1772"></A>
<DL>
<DT><span class="define">PREDICATE:</span> <B>skip_code/1:</B>
<DD><A NAME="IDX1773"></A>


<P>
<CODE>skip_code(Code)</CODE>


<P>
Behaves like <CODE>current_input(S), skip_code(S,Code)</CODE>.


</DL>

<P>
<A NAME="IDX1774"></A>
<A NAME="IDX1775"></A>
<DL>
<DT><span class="define">PREDICATE:</span> <B>skip_line/1:</B>
<DD><A NAME="IDX1776"></A>


<P>
<CODE>skip_line(Stream)</CODE>


<P>
Skips from <CODE>Stream</CODE> the remaining input characters on the current line. If the end of the stream is reached, the stream will stay at its end. Portable among different operating systems.


</DL>

<P>
<A NAME="IDX1777"></A>
<A NAME="IDX1778"></A>
<DL>
<DT><span class="define">PREDICATE:</span> <B>skip_line/0:</B>
<DD><A NAME="IDX1779"></A>


<P>
<CODE>skip_line(skip_line</CODE>


<P>
Behaves like <CODE>current_input(S), skip_line(S)</CODE>.


</DL>

<P>
<A NAME="IDX1780"></A>
<A NAME="IDX1781"></A>
<DL>
<DT><span class="define">PREDICATE:</span> <B>put_code/2:</B>
<DD><A NAME="IDX1782"></A>


<P>
<CODE>put_code(Stream, Code)</CODE>


<P>
Outputs to <CODE>Stream</CODE> the character corresponding to character code <CODE>Code</CODE>.


<P>
<STRONG>Usage:</STRONG> <CODE>put_code(+stream, +int)</CODE>
<KBD> * ISO * </KBD>

<UL>
<LI><EM>The following properties hold globally:</EM>

This predicate is understood natively by CiaoPP.
 (<CODE>basic_props:native/1</CODE>)
</UL>

</DL>

<P>
<A NAME="IDX1783"></A>
<A NAME="IDX1784"></A>
<DL>
<DT><span class="define">PREDICATE:</span> <B>put_code/1:</B>
<DD><A NAME="IDX1785"></A>


<P>
<CODE>put_code(Code)</CODE>


<P>
Behaves like <CODE>current_output(S), put_code(S,Code)</CODE>.


<P>
<STRONG>Usage:</STRONG> <CODE>put_code(+int)</CODE>
<KBD> * ISO * </KBD>

<UL>
<LI><EM>The following properties hold globally:</EM>

This predicate is understood natively by CiaoPP.
 (<CODE>basic_props:native/1</CODE>)
</UL>

</DL>

<P>
<A NAME="IDX1786"></A>
<A NAME="IDX1787"></A>
<DL>
<DT><span class="define">PREDICATE:</span> <B>nl/1:</B>
<DD><A NAME="IDX1788"></A>


<P>
<CODE>nl(Stream)</CODE>


<P>
Outputs a newline character to <CODE>Stream</CODE>. Equivalent to <CODE>put_code(Stream, 0'\n)</CODE>.


<P>
<STRONG>Usage:</STRONG> <CODE>nl(+stream)</CODE>
<KBD> * ISO * </KBD>

<UL>
<LI><EM>The following properties hold globally:</EM>

This predicate is understood natively by CiaoPP.
 (<CODE>basic_props:native/1</CODE>)
</UL>

</DL>

<P>
<A NAME="IDX1789"></A>
<A NAME="IDX1790"></A>
<DL>
<DT><span class="define">PREDICATE:</span> <B>nl/0:</B>
<DD><A NAME="IDX1791"></A>


<P>
<CODE>nl(nl</CODE>


<P>
Behaves like <CODE>current_output(S), nl(S)</CODE>.


<P>
<STRONG>Usage:</STRONG> 
<KBD> * ISO * </KBD>

<UL>
<LI><EM>The following properties hold globally:</EM>

This predicate is understood natively by CiaoPP.
 (<CODE>basic_props:native/1</CODE>)
</UL>

</DL>

<P>
<A NAME="IDX1792"></A>
<A NAME="IDX1793"></A>
<DL>
<DT><span class="define">PREDICATE:</span> <B>tab/2:</B>
<DD><A NAME="IDX1794"></A>


<P>
<CODE>tab(Stream, Num)</CODE>


<P>
Outputs <CODE>Num</CODE> spaces to <CODE>Stream</CODE>.


<P>
<STRONG>Usage:</STRONG> <CODE>tab(+stream, +int)</CODE>

<UL>
<LI><EM>The following properties hold globally:</EM>

This predicate is understood natively by CiaoPP.
 (<CODE>basic_props:native/1</CODE>)
</UL>

</DL>

<P>
<A NAME="IDX1795"></A>
<A NAME="IDX1796"></A>
<DL>
<DT><span class="define">PREDICATE:</span> <B>tab/1:</B>
<DD><A NAME="IDX1797"></A>


<P>
<CODE>tab(Num)</CODE>


<P>
Behaves like <CODE>current_output(S), tab(S,Num)</CODE>.


<P>
<STRONG>Usage:</STRONG> <CODE>tab(+int)</CODE>

<UL>
<LI><EM>The following properties hold globally:</EM>

This predicate is understood natively by CiaoPP.
 (<CODE>basic_props:native/1</CODE>)
</UL>

</DL>

<P>
<A NAME="IDX1798"></A>
<A NAME="IDX1799"></A>
<DL>
<DT><span class="define">PREDICATE:</span> <B>code_class/2:</B>
<DD><A NAME="IDX1800"></A>


<P>
<CODE>code_class(Code, Class)</CODE>


<P>
Unifies <CODE>Class</CODE> with an integer corresponding to the lexical class of the character whose code is <CODE>Code</CODE>, with the following correspondence: 

<PRE>
    0 - layout (includes space, newline, tab)
    1 - small letter
    2 - capital letter (including '_')
    3 - digit
    4 - graphic (includes #$&#38;*+-./:&#60;=&#62;?@^\`~ )
    5 - punctuation (includes !;"'%(),[]{|} )
</PRE>

<P>
Note that in 
<A NAME="IDX1801"></A>
ISO-Prolog the back quote <CODE>`</CODE> is a punctuation character, whereas in Ciao it is a graphic character. Thus, if compatibility with 
<A NAME="IDX1802"></A>
ISO-Prolog is desired, the programmer should not use this character in unquoted names.


</DL>

<P>
<A NAME="IDX1803"></A>
<A NAME="IDX1804"></A>
<DL>
<DT><span class="define">PREDICATE:</span> <B>getct/2:</B>
<DD><A NAME="IDX1805"></A>


<P>
<CODE>getct(Code, Type)</CODE>


<P>
Reads from the current input stream the next character, unifying <CODE>Code</CODE> with its character code, and <CODE>Type</CODE> with its lexical class. At end of stream, unifies both <CODE>Code</CODE> and <CODE>Type</CODE> with the integer -1. Equivalent to 

<PRE>
   get(Code), (Code = -1 -&#62; Type = -1 ; code_class(Code,Type))
</PRE>

</DL>

<P>
<A NAME="IDX1806"></A>
<A NAME="IDX1807"></A>
<DL>
<DT><span class="define">PREDICATE:</span> <B>getct1/2:</B>
<DD><A NAME="IDX1808"></A>


<P>
<CODE>getct1(Code, Type)</CODE>


<P>
Reads from the current input stream the next non-layout character, unifying <CODE>Code</CODE> with its character code, and <CODE>Type</CODE> with its lexical class (which will be nonzero). At end of stream, unifies both <CODE>Code</CODE> and <CODE>Type</CODE> with the integer -1. Equivalent to 

<PRE>
   get1(Code), (Code = -1 -&#62; Type = -1 ; code_class(Code,Type))
</PRE>

</DL>

<P>
<A NAME="IDX1809"></A>
<A NAME="IDX1810"></A>
<DL>
<DT><span class="define">PREDICATE:</span> <B>display/2:</B>
<DD><A NAME="IDX1811"></A>


<P>
<CODE>display(Stream, Term)</CODE>


<P>
Displays <CODE>Term</CODE> onto <CODE>Stream</CODE>. Lists are output using list notation, the other compound terms are output in functional notation. Similar to <CODE>write_term(Stream, Term, [ignore_ops(ops)])</CODE>, except that curly bracketed notation is not used with <CODE>{}/1</CODE>, and the <CODE>write_strings</CODE> flag is not honored.


<P>
<STRONG>Usage:</STRONG> <CODE>display(+stream, @term)</CODE>

<UL>
<LI><EM>The following properties hold globally:</EM>

This predicate is understood natively by CiaoPP.
 (<CODE>basic_props:native/1</CODE>)
</UL>

</DL>

<P>
<A NAME="IDX1812"></A>
<A NAME="IDX1813"></A>
<DL>
<DT><span class="define">PREDICATE:</span> <B>display/1:</B>
<DD><A NAME="IDX1814"></A>


<P>
<CODE>display(Term)</CODE>


<P>
Behaves like <CODE>current_output(S), display(S,Term)</CODE>.


<P>
<STRONG>Usage:</STRONG> <CODE>display(@term)</CODE>

<UL>
<LI><EM>The following properties hold globally:</EM>

This predicate is understood natively by CiaoPP.
 (<CODE>basic_props:native/1</CODE>)
</UL>

</DL>

<P>
<A NAME="IDX1815"></A>
<A NAME="IDX1816"></A>
<DL>
<DT><span class="define">PREDICATE:</span> <B>displayq/2:</B>
<DD><A NAME="IDX1817"></A>


<P>
<CODE>displayq(Stream, Term)</CODE>


<P>
Similar to <CODE>display(Stream, Term)</CODE>, but atoms and functors that can't be read back by 
<A NAME="IDX1818"></A>
<CODE>read_term/3</CODE> are quoted. Thus, similar to <CODE>write_term(Stream, Term, [quoted(true), ignore_ops(ops)])</CODE>, with the same exceptions as 
<A NAME="IDX1819"></A>
<CODE>display/2</CODE>.


</DL>

<P>
<A NAME="IDX1820"></A>
<A NAME="IDX1821"></A>
<DL>
<DT><span class="define">PREDICATE:</span> <B>displayq/1:</B>
<DD><A NAME="IDX1822"></A>


<P>
<CODE>displayq(Term)</CODE>


<P>
Behaves like <CODE>current_output(S), displayq(S,Term)</CODE>.


</DL>

<P><HR><P>
Go to the <A HREF="ciao_1.html">first</A>, <A HREF="ciao_24.html">previous</A>, <A HREF="ciao_26.html">next</A>, <A HREF="ciao_241.html">last</A> section, <A HREF="ciao_toc.html">table of contents</A>.
</BODY>
</HTML>