File: io_lib.html

package info (click to toggle)
erlang-doc-html 1%3A8.0-1
  • links: PTS
  • area: main
  • in suites: woody
  • size: 18,028 kB
  • ctags: 7,419
  • sloc: perl: 1,841; ansic: 323; erlang: 155
file content (188 lines) | stat: -rw-r--r-- 7,211 bytes parent folder | download
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
<HTML>
<HEAD>
<!-- refpage -->
<TITLE>io_lib</TITLE>
</HEAD>
<BODY BGCOLOR="#FFFFFF">
<CENTER>


<A HREF="http://www.erlang.se"><IMG BORDER=0 ALT="[Erlang Systems]" SRC="min_head.gif"></A>
<H1>io_lib</H1>
</CENTER>
<H3>MODULE</H3>
<UL>
io_lib</UL>
<H3>MODULE SUMMARY</H3>
<UL>
IO Library Functions</UL>
<H3>DESCRIPTION</H3>
<UL>
<P>This module contains functions for converting to and from strings (lists of characters). They are used for implementing the functions in the <CODE>io</CODE> module. There is
no guarantee that the character lists returned from some of the functions are flat, they can be deep lists. <CODE>lists:flatten/1</CODE> is used for generating flat lists.
</UL>
<H3>EXPORTS</H3>
<P><A NAME="nl%0"><STRONG><CODE>nl()</CODE></STRONG></A><BR>
<UL>
<P>Returns a character list which represents a new line character.
</UL>
<P><A NAME="write%1"><STRONG><CODE>write(Term)</CODE></STRONG></A><BR>
<A NAME="write%2"><STRONG><CODE>write(Term, Depth)</CODE></STRONG></A><BR>
<UL>
<P>Returns a character list which represents <CODE>Term</CODE>. The
<CODE>Depth</CODE> (-1) argument controls the depth of the
structures written. When the specified depth is reached,
everything below this level is replaced by &#34;...&#34;. For
example:<PRE>&#62; lists:flatten(io_lib:write({1,[2],[3],[4,5],6,7,8,9})).        
&#34;{1,[2],[3],[4,5],6,7,8,9}&#34;
&#62; lists:flatten(io_lib:write({1,[2],[3],[4,5],6,7,8,9}, 5)).
&#34;{1,[2],[3],[4|...],6|...}&#34;</PRE></UL>
<P><A NAME="print%1"><STRONG><CODE>print(Term)</CODE></STRONG></A><BR>
<A NAME="print%4"><STRONG><CODE>print(Term, Column, LineLength, Depth)</CODE></STRONG></A><BR>
<UL>
<P>Also returns a list of characters which represents <CODE>Term</CODE>,
but breaks representations which are longer than one line into many
lines and indents each line sensibly. It also tries to
detect and output lists of printable characters 
as strings. <CODE>Column</CODE> is the starting column
(1), <CODE>LineLength</CODE> the maximum line length (80), and
<CODE>Depth</CODE> the maximum print depth.
</UL>
<P><A NAME="fwrite%2"><STRONG><CODE>fwrite(Format, Data)</CODE></STRONG></A><BR>
<A NAME="format%2"><STRONG><CODE>format(Format, Data)</CODE></STRONG></A><BR>
<UL>
<P>Returns a character list which represents <CODE>Data</CODE> formatted
in accordance with <CODE>Format</CODE>. Refer to <A HREF="io.html">io</A> for a detailed description
of the available formatting options. A fault is generated if there is an error in the format string or argument list.
</UL>
<P><A NAME="fread%2"><STRONG><CODE>fread(Format, String)</CODE></STRONG></A><BR>
<UL>
<P>Tries to read <CODE>String</CODE> in accordance with the control
sequences in <CODE>Format</CODE>. Refer to <A HREF="io.html">io</A> for a detailed description of the
available formatting options. It is assumed that
<CODE>String</CODE> contains whole lines. It returns:
<P><DL>
<DT><CODE>{ok, InputList, LeftOverChars}</CODE></DT>
<DD> The string was read. <CODE>InputList</CODE> is the list
of successfully matched and read items, and
<CODE>LeftOverChars</CODE> are the input characters not used.
<BR>
</DD>
<DT><CODE>{more, RestFormat, Nchars, InputStack}</CODE></DT>
<DD> The string was read, but more input is needed in
order to complete the original format
string. <CODE>RestFormat</CODE> is the remaining format string,
<CODE>NChars</CODE> the number of characters scanned, and
<CODE>InputStack</CODE> is the reversed list of inputs matched
up to that point.
<BR>
</DD>
<DT><CODE>{error,What}</CODE></DT>
<DD> An error occurred which can be formatted with the call
<CODE>format_error/1</CODE>.
<BR>
</DD>
</DL>
<P>Example:<PRE>&#62; io_lib:fread(&#34;~f~f~f&#34;, &#34;15.6 17.3e-6 24.5&#34;).
{ok, [15.6000, 1.73000e-5, 24.5000], []}</PRE></UL>
<P><A NAME="fread%3"><STRONG><CODE>fread(Continuation, CharList, Format)</CODE></STRONG></A><BR>
<UL>
<P>This is the re-entrant formatted reader. It returns:
<P><DL>
<DT><CODE>{done, Result, LeftOverChars}</CODE></DT>
<DD> The input is complete. The result is one of the following:
<BR>
<DL>
<DT><CODE>{ok, InputList}</CODE></DT>
<DD> The string was read. <CODE>InputList</CODE> is the
list of successfully matched and read items, and
<CODE>LeftOverChars</CODE> are the remaining characters.
<BR>
</DD>
<DT><CODE>eof</CODE></DT>
<DD> End of file has been encountered.
<CODE>LeftOverChars</CODE> are the input characters not
used.
<BR>
</DD>
<DT><CODE>{error,What}</CODE></DT>
<DD> An error occurred, which can be formatted with the
call <CODE>format_error/1</CODE>.
<BR>
</DD>
</DL>

</DD>
<DT><CODE>{more, Continuation}</CODE></DT>
<DD> More data is required to build a term. <CODE>Continuation</CODE> must be passed to <CODE>&#60;c&#62;fread/3</CODE>, when more data becomes available.<BR>
</DD>
</DL>
</UL>
<P><A NAME="write_atom%1"><STRONG><CODE>write_atom(Atom)</CODE></STRONG></A><BR>
<UL>
<P>Returns the list of characters needed to print the atom
<CODE>Atom</CODE>.
</UL>
<P><A NAME="write_string%1"><STRONG><CODE>write_string(String)</CODE></STRONG></A><BR>
<UL>
<P>Returns the list of characters needed to print
<CODE>String</CODE> as a string.
</UL>
<P><A NAME="write_char%1"><STRONG><CODE>write_char(Integer)</CODE></STRONG></A><BR>
<UL>
<P>Returns the list of characters needed to print a character
constant.
</UL>
<P><A NAME="indentation%2"><STRONG><CODE>indentation(String, StartIndent)</CODE></STRONG></A><BR>
<UL>
<P>Returns the indentation if <CODE>String</CODE> has been printed,
starting at <CODE>Indentation</CODE>.
</UL>
<P><A NAME="char_list%1"><STRONG><CODE>char_list(CharList) -&#62; bool()</CODE></STRONG></A><BR>
<UL>
<P>Returns <CODE>true</CODE> if CharList is a list of characters,
otherwise it returns <CODE>false</CODE>.
</UL>
<P><A NAME="deep_char_list%1"><STRONG><CODE>deep_char_list(CharList)</CODE></STRONG></A><BR>
<UL>
<P>Returns <CODE>true</CODE> if CharList is a deep list of
characters, otherwise it returns <CODE>false</CODE>.
</UL>
<P><A NAME="printable_list%1"><STRONG><CODE>printable_list(CharList)</CODE></STRONG></A><BR>
<UL>
<P>Returns <CODE>true</CODE> if CharList is a list of printable
characters, otherwise it returns <CODE>false</CODE>.
</UL>
<H3>Notes</H3>
<UL>
<P>The module <CODE>io_lib</CODE> also uses the extra modules
<CODE>io_lib_format</CODE>, <CODE>io_lib_fread</CODE>, and
<CODE>io_lib_pretty</CODE>. All external interfaces exist in
<CODE>io_lib</CODE>.

<P><STRONG>Users are strongly advised not to access the
other modules directly.</STRONG>
<P><TABLE CELLPADDING=4>
<TR>
      <TD VALIGN=TOP><IMG ALT="Note!" SRC="note.gif"></TD>
      <TD>
<P>Any undocumented functions in <CODE>io_lib</CODE> should not be used.
</TD>
</TR>
      </TABLE>
<P>The continuation of the first call to the re-entrant input functions must be <CODE>[]</CODE>. Refer to Armstrong, Virding, Williams, 'Concurrent Programming in Erlang', Chapter 13 for a complete description of how the re-entrant input scheme works
</UL>
<H3>AUTHORS</H3>
<UL>
Robert Virding - support@erlang.ericsson.se<BR>
</UL>
<CENTER>
<HR>
<FONT SIZE=-1>stdlib 1.10<BR>
Copyright &copy; 1991-2001
<A HREF="http://www.erlang.se">Ericsson Utvecklings AB</A><BR>
<!--#include virtual="/ssi/otp_footer.html"-->
</FONT>
</CENTER>
</BODY>
</HTML>