77
<name>print(Term) -></name>
78
<name>print(Term, Column, LineLength, Depth) -> chars()</name>
81
<name name="print" arity="1"/>
82
<name name="print" arity="4"/>
79
83
<fsummary>Pretty print a term</fsummary>
82
<v>Column = LineLenght = Depth = int()</v>
85
85
<p>Also returns a list of characters which represents
86
<c>Term</c>, but breaks representations which are longer than
86
<c><anno>Term</anno></c>, but breaks representations which are longer than
87
87
one line into many lines and indents each line sensibly. It
88
88
also tries to detect and output lists of printable characters
89
as strings. <c>Column</c> is the starting column (1),
90
<c>LineLength</c> the maximum line length (80), and
91
<c>Depth</c> (-1) the maximum print depth.</p>
89
as strings. <c><anno>Column</anno></c> is the starting column (1),
90
<c><anno>LineLength</anno></c> the maximum line length (80), and
91
<c><anno>Depth</anno></c> (-1) the maximum print depth.</p>
95
<name>fwrite(Format, Data) -></name>
96
<name>format(Format, Data) -> chars() | UnicodeList</name>
95
<name name="fwrite" arity="2"/>
96
<name name="format" arity="2"/>
97
97
<fsummary>Write formatted output</fsummary>
99
<v>Format = atom() | string() | binary()</v>
100
<v>Data = [term()]</v>
101
<v>UnicodeList = [Unicode]</v>
102
<v>Unicode = int() representing valid unicode codepoint</v>
105
<p>Returns a character list which represents <c>Data</c>
106
formatted in accordance with <c>Format</c>. See
99
<p>Returns a character list which represents <c><anno>Data</anno></c>
100
formatted in accordance with <c><anno>Format</anno></c>. See
107
101
<seealso marker="io#fwrite/1">io:fwrite/1,2,3</seealso> for a detailed
108
102
description of the available formatting options. A fault is
109
103
generated if there is an error in the format string or
122
<name>fread(Format, String) -> Result</name>
116
<name name="fread" arity="2"/>
123
117
<fsummary>Read formatted input</fsummary>
125
<v>Format = String = string()</v>
126
<v>Result = {ok, InputList, LeftOverChars} | {more, RestFormat, Nchars, InputStack} | {error, What}</v>
127
<v> InputList = chars()</v>
128
<v> LeftOverChars = string()</v>
129
<v> RestFormat = string()</v>
130
<v> Nchars = int()</v>
131
<v> InputStack = chars()</v>
132
<v> What = term()</v>
135
<p>Tries to read <c>String</c> in accordance with the control
136
sequences in <c>Format</c>. See
119
<p>Tries to read <c><anno>String</anno></c> in accordance with the control
120
sequences in <c><anno>Format</anno></c>. See
137
121
<seealso marker="io#fread/3">io:fread/3</seealso> for a detailed
138
122
description of the available formatting options. It is
139
assumed that <c>String</c> contains whole lines. It returns:</p>
123
assumed that <c><anno>String</anno></c> contains whole lines. It returns:</p>
141
<tag><c>{ok, InputList, LeftOverChars}</c></tag>
125
<tag><c>{ok, <anno>InputList</anno>, <anno>LeftOverChars</anno>}</c></tag>
143
<p>The string was read. <c>InputList</c> is the list of
127
<p>The string was read. <c><anno>InputList</anno></c> is the list of
144
128
successfully matched and read items, and
145
<c>LeftOverChars</c> are the input characters not used.</p>
129
<c><anno>LeftOverChars</anno></c> are the input characters not used.</p>
147
<tag><c>{more, RestFormat, Nchars, InputStack}</c></tag>
131
<tag><c>{more, <anno>RestFormat</anno>, <anno>Nchars</anno>, <anno>InputStack</anno>}</c></tag>
149
133
<p>The string was read, but more input is needed in order
150
to complete the original format string. <c>RestFormat</c>
151
is the remaining format string, <c>NChars</c> the number
152
of characters scanned, and <c>InputStack</c> is the
134
to complete the original format string. <c><anno>RestFormat</anno></c>
135
is the remaining format string, <c><anno>Nchars</anno></c> the number
136
of characters scanned, and <c><anno>InputStack</anno></c> is the
153
137
reversed list of inputs matched up to that point.</p>
155
<tag><c>{error, What}</c></tag>
139
<tag><c>{error, <anno>What</anno>}</c></tag>
157
<p>The read operation failed and the parameter <c>What</c>
141
<p>The read operation failed and the parameter <c><anno>What</anno></c>
158
142
gives a hint about the error.</p>
168
<name>fread(Continuation, String, Format) -> Return</name>
152
<name name="fread" arity="3"/>
169
153
<fsummary>Re-entrant formatted reader</fsummary>
171
<v>Continuation = see below</v>
172
<v>String = Format = string()</v>
173
<v>Return = {done, Result, LeftOverChars} | {more, Continuation}</v>
174
<v> Result = {ok, InputList} | eof | {error, What}</v>
175
<v> InputList = chars()</v>
176
<v> What = term()()</v>
177
<v> LeftOverChars = string()</v>
180
155
<p>This is the re-entrant formatted reader. The continuation of
181
156
the first call to the functions must be <c>[]</c>. Refer to
184
159
re-entrant input scheme works.</p>
185
160
<p>The function returns:</p>
187
<tag><c>{done, Result, LeftOverChars}</c></tag>
162
<tag><c>{done, <anno>Result</anno>, <anno>LeftOverChars</anno>}</c></tag>
189
164
<p>The input is complete. The result is one of the
192
<tag><c>{ok, InputList}</c></tag>
167
<tag><c>{ok, <anno>InputList</anno>}</c></tag>
194
<p>The string was read. <c>InputList</c> is the list of
169
<p>The string was read. <c><anno>InputList</anno></c> is the list of
195
170
successfully matched and read items, and
196
<c>LeftOverChars</c> are the remaining characters.</p>
171
<c><anno>LeftOverChars</anno></c> are the remaining characters.</p>
198
173
<tag><c>eof</c></tag>
200
175
<p>End of file has been encountered.
201
<c>LeftOverChars</c> are the input characters not
176
<c><anno>LeftOverChars</anno></c> are the input characters not
204
<tag><c>{error, What}</c></tag>
179
<tag><c>{error, <anno>What</anno>}</c></tag>
206
<p>An error occurred and the parameter <c>What</c> gives
181
<p>An error occurred and the parameter <c><anno>What</anno></c> gives
207
182
a hint about the error.</p>
211
<tag><c>{more, Continuation}</c></tag>
186
<tag><c>{more, <anno>Continuation</anno>}</c></tag>
213
188
<p>More data is required to build a term.
214
<c>Continuation</c> must be passed to <c>fread/3</c>,
189
<c><anno>Continuation</anno></c> must be passed to <c>fread/3</c>,
215
190
when more data becomes available.</p>
221
<name>write_atom(Atom) -> chars()</name>
196
<name name="write_atom" arity="1"/>
222
197
<fsummary>Write an atom</fsummary>
227
199
<p>Returns the list of characters needed to print the atom
200
<c><anno>Atom</anno></c>.</p>
232
<name>write_string(String) -> chars()</name>
204
<name name="write_string" arity="1"/>
233
205
<fsummary>Write a string</fsummary>
235
<v>String = string()</v>
238
<p>Returns the list of characters needed to print <c>String</c>
207
<p>Returns the list of characters needed to print <c><anno>String</anno></c>
243
<name>write_char(Integer) -> chars()</name>
212
<name name="write_char" arity="1"/>
244
213
<fsummary>Write a character</fsummary>
246
<v>Integer = int()</v>
249
215
<p>Returns the list of characters needed to print a character
250
216
constant in the ISO-latin-1 character set.</p>
254
<name>indentation(String, StartIndent) -> int()</name>
220
<name name="indentation" arity="2"/>
255
221
<fsummary>Indentation after printing string</fsummary>
257
<v>String = string()</v>
258
<v>StartIndent = int()</v>
261
<p>Returns the indentation if <c>String</c> has been printed,
262
starting at <c>StartIndent</c>.</p>
223
<p>Returns the indentation if <c><anno>String</anno></c> has been printed,
224
starting at <c><anno>StartIndent</anno></c>.</p>
266
<name>char_list(Term) -> bool()</name>
228
<name name="char_list" arity="1"/>
267
229
<fsummary>Test for a list of characters</fsummary>
272
<p>Returns <c>true</c> if <c>Term</c> is a flat list of
231
<p>Returns <c>true</c> if <c><anno>Term</anno></c> is a flat list of
273
232
characters in the ISO-latin-1 range, otherwise it returns <c>false</c>.</p>
277
<name>deep_char_list(Term) -> bool()</name>
236
<name name="deep_char_list" arity="1"/>
278
237
<fsummary>Test for a deep list of characters</fsummary>
283
<p>Returns <c>true</c> if <c>Term</c> is a, possibly deep, list
239
<p>Returns <c>true</c> if <c><anno>Term</anno></c> is a, possibly deep, list
284
240
of characters in the ISO-latin-1 range, otherwise it returns <c>false</c>.</p>
288
<name>printable_list(Term) -> bool()</name>
244
<name name="printable_list" arity="1"/>
289
245
<fsummary>Test for a list of printable ISO-latin-1 characters</fsummary>
294
<p>Returns <c>true</c> if <c>Term</c> is a flat list of
247
<p>Returns <c>true</c> if <c><anno>Term</anno></c> is a flat list of
295
248
printable ISO-latin-1 characters, otherwise it returns <c>false</c>.</p>