Author(s): Daniel Cabeza, Mats Carlsson.
Version: 1.10#7 (2006/4/26, 19:22:13 CEST)
Version of last change: 1.9#285 (2004/2/13, 17:36:9 CET)
This module provides predicates for character input/output and for canonical term output. From the
ISO-Prolog predicates for character input/output, only the _code
versions are provided, the rest are given by
library(iso_byte_char)
, 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.
io_basic
)io_basic
)
get_code(Stream, Code)
Reads from Stream
the next character and unifies Code
with its character code. At end of stream, unifies Code
with the integer -1.
Usage: get_code(+stream, ?int)
* ISO *
basic_props:native/1
)
get_code(Code)
Behaves like current_input(S), get_code(S,Code)
.
Usage: get_code(?int)
* ISO *
basic_props:native/1
)
get1_code(Stream, Code)
Reads from Stream
the next non-layout character (see
code_class/2
) and unifies Code
with its character code. At end of stream, unifies Code
with the integer -1.
Usage: get1_code(+stream, ?int)
basic_props:native/1
)
get1_code(Code)
Behaves like current_input(S), get1_code(S,Code)
.
Usage: get1_code(?int)
basic_props:native/1
)
peek_code(Stream, Code)
Unifies Code
with the character code of the next character of Stream
, leaving the stream position unaltered. At end of stream, unifies Code
with the integer -1.
peek_code(Code)
Behaves like current_input(S), peek_code(S,Code)
.
skip_code(Stream, Code)
Skips just past the next character code Code
from Stream
.
skip_code(Code)
Behaves like current_input(S), skip_code(S,Code)
.
skip_line(Stream)
Skips from Stream
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.
skip_line(skip_line
Behaves like current_input(S), skip_line(S)
.
put_code(Stream, Code)
Outputs to Stream
the character corresponding to character code Code
.
Usage: put_code(+stream, +int)
* ISO *
basic_props:native/1
)
put_code(Code)
Behaves like current_output(S), put_code(S,Code)
.
Usage: put_code(+int)
* ISO *
basic_props:native/1
)
nl(Stream)
Outputs a newline character to Stream
. Equivalent to put_code(Stream, 0'\n)
.
Usage: nl(+stream)
* ISO *
basic_props:native/1
)
nl(nl
Behaves like current_output(S), nl(S)
.
Usage: * ISO *
basic_props:native/1
)
tab(Stream, Num)
Outputs Num
spaces to Stream
.
Usage: tab(+stream, +int)
basic_props:native/1
)
tab(Num)
Behaves like current_output(S), tab(S,Num)
.
Usage: tab(+int)
basic_props:native/1
)
code_class(Code, Class)
Unifies Class
with an integer corresponding to the lexical class of the character whose code is Code
, with the following correspondence:
0 - layout (includes space, newline, tab) 1 - small letter 2 - capital letter (including '_') 3 - digit 4 - graphic (includes #$&*+-./:<=>?@^\`~ ) 5 - punctuation (includes !;"'%(),[]{|} )
Note that in
ISO-Prolog the back quote `
is a punctuation character, whereas in Ciao it is a graphic character. Thus, if compatibility with
ISO-Prolog is desired, the programmer should not use this character in unquoted names.
getct(Code, Type)
Reads from the current input stream the next character, unifying Code
with its character code, and Type
with its lexical class. At end of stream, unifies both Code
and Type
with the integer -1. Equivalent to
get(Code), (Code = -1 -> Type = -1 ; code_class(Code,Type))
getct1(Code, Type)
Reads from the current input stream the next non-layout character, unifying Code
with its character code, and Type
with its lexical class (which will be nonzero). At end of stream, unifies both Code
and Type
with the integer -1. Equivalent to
get1(Code), (Code = -1 -> Type = -1 ; code_class(Code,Type))
display(Stream, Term)
Displays Term
onto Stream
. Lists are output using list notation, the other compound terms are output in functional notation. Similar to write_term(Stream, Term, [ignore_ops(ops)])
, except that curly bracketed notation is not used with {}/1
, and the write_strings
flag is not honored.
Usage: display(+stream, @term)
basic_props:native/1
)
display(Term)
Behaves like current_output(S), display(S,Term)
.
Usage: display(@term)
basic_props:native/1
)
displayq(Stream, Term)
Similar to display(Stream, Term)
, but atoms and functors that can't be read back by
read_term/3
are quoted. Thus, similar to write_term(Stream, Term, [quoted(true), ignore_ops(ops)])
, with the same exceptions as
display/2
.
displayq(Term)
Behaves like current_output(S), displayq(S,Term)
.
Go to the first, previous, next, last section, table of contents.