Module stream

Predicates for input/output stream

Contents

Predicate


Top of this page Contents Index of this package LiLFeS Documents LiLFeS Home Page Tsujii laboratory

Predicate

open_null_stream/1

Formatopen_null_stream(-Handle)
Arguments
-Handlehandle_nullstream Stream handle
NoteThe reasons because the predicate can fail are.
  • Maximum number of open streams exceeded.
  • Can't create the stream handle.
Open an empty stream.
> :- open_null_stream(X).

open_socket_stream/3

Formatopen_socket_stream(+Host, +Port, -Handle)
Arguments
+Hoststring Host name
-Handlehandle_socketstream Stream socket
NoteThe predicate will fail in the next cases.
  • The port numbe can't be reached in the designated host.
  • Can't connect to the host's port.
  • Maximum number of open streams exceeded.
  • Cannot allocate stream Handle.
Open a socket stream.
> :- open_socket_stream("dallmayr", 12345, X).

open_pty_stream/3

Formatopen_pty_stream(+Name, +Args, -Handle)
Arguments
+Namestring Command name.
+Argslist of strings Arguments of the command
-Handlehandle_ptystream PTY stream.
Open a pseudo-terminal stream to communicate with an external command through standard I/O.

open_process_stream/4

Formatopen_process_stream(+Name, +Args, +Mode, -Handle)
Arguments
+Namestring Command name.
+Argslist of strings Arguments of the command.
+Modestring Open mode (i/o)
-Handlehandle_processstream process stream.
Open a stream to communicate with an external command via standard input or output.

open_file_stream/3

Formatopen_file_stream(+Name, +Mode, -Handle)
Arguments
+Namestring File name.
+Modestring Open mode of the file.
-Handlehandle_filestream File stream.
NoteBelow is the list of modes.
  • "r" : Open just for read. Will fail if file does not exists。
  • "w" : Opens just for write. The previous file is overwriten.
  • "a" : Open it in exclusive mode.
  • "r+" : Opens for read. Creates a new file if doesn't exists.
  • "w+" : Opens for write. Creates a new file if doesn't exists.
  • "a+" : Opens for read and write.Write from the end of the file.
The reasons because the predicate can fail are.
  • The open mode of the file name is not applicable.
  • For any reason the file can't be open.
  • Maximum number of open streams exceeded.
  • Can't create the stream handle.
Open a file stream.
 > :- open_file_stream("/etc/passwd", "r", X).

open_server_stream/2

Formatopen_server_stream(+Port,-Handle)
Arguments
+Portinteger :port number of server
-Handlehandle_serverstream :stream handle
NoteThis predicate fails on the following condition.
  • Cannot open port.
Open port for server.
> ?- open_server_stream(8500, X).

accept_connection/1

Formataccept_connection(+Handle)
Arguments
+Handlehandle_serverstream :stream handle
Accept connection to server stream Handle.
> ?- open_server_stream(8500, X), accept_connection(X).

close_connection/1

Formatclose_connection(+Handle)
Arguments
+Handlehandle_serverstream :stream handle
Close connection to server stream Handle.

write_string/2

Formatwrite_string(+Handle, +String)
Arguments
+Handlehandle_stream Stream handle
+Stringstring String
NoteThe reasons because the predicate can fail are.
  • The stream handle is invalid.
  • The second argument is not a string.
Write a string into a stream handle.
> :- open_file_stream("hoge", "w", X), write_string(X, "poge").

writeln_string/2

Formatwriteln_string(+Handle, +String)
Arguments
+Handlehandle_stream Stream handle
+Stringstring String
NoteThe reasons because the predicate can fail are.
  • The stream handle is invalid.
  • The second argument is not a string.
Write a string into a stream handle. Also write a new line character.
> :- open_file_stream("hoge", "w", X), writeln_string(X, "poge").

write_string_list/2

Formatwrite_string_list(+Handle, +List)
Arguments
+Handlehandle_stream Stream handle
+Listlist List of string or integers
NoteThe reasons because the predicate can fail are.
  • The stream handle is invalid.
  • The second argument is not a list of strings or integers.
Write a list of strings (or integers) into a stream handle.

writeln_string_list/2

Formatwriteln_string_list(+Handle, +List)
Arguments
+Handlehandle_stream Stream handle
+Listlist List of string or integers
NoteThe reasons because the predicate can fail are.
  • The stream handle is invalid.
  • The second argument is not a list of strings or integers.
Write a list of strings (or integers) into a stream handle. Also write a new line character.

read_string/3

Formatread_string(+Handle, +Len, -String)
Arguments
+Handlehandle_stream Stream handle
+Leninteger Length of the string
-Stringstring Readed string.
NoteThe reasons because the predicate can fail are.
  • The stream handle is invalid.
  • The second argument is not an integer.
  • The stream is closed.
Read a string from a handle.
> :- open_file_stream("/etc/passwd", "r", X), read_string(X, 10, Y).

readln_string/2

Formatreadln_string(+Handle, -String)
Arguments
+Handlehandle_stream Stream handle
-Stringstring Readed string.
NoteThe reasons because the predicate can fail are.
  • The stream handle is invalid.
  • The stream is closed.
Read a string from the stream. It stops when find a new line character.
> :- open_file_stream("/etc/passwd", "r", X), readln_string(X, Y).

write_stream/2

Formatwrite_stream(+Handle, +Data)
Arguments
+Handlehandle_stream Stream handle.
+Datalist of integers The data. A list of values in the range of 0 - 255.
NoteThe reasons because the predicate can fail are.
  • The stream handle is invalid.
Write the binary data into the stream.
> :- open_file_stream("/etc/passwd", "r", X), readln_string(X, Y).

read_stream/3

Formatread_stream(+Handle, +Len, -Data)
Arguments
+Handlehandle_stream Stream handle.
+Leninteger Length of the data.
-Datalist of integers Read data.
NoteThe reasons because the predicate can fail are.
  • The stream handle is invalid.
  • The second argument is not an integer.
  • The stream is closed.
Read the binary data from the stream.
> :- open_file_stream("/etc/passwd", "r", X), read_stream(X, 10, Y).

close/1

Formatclose(+Handle)
Arguments
+Handlehandle_stream Stream handle.
NoteThe reasons because the predicate can fail are.
  • The stream handle is invalid.
Close a stream .
> :- close(X).

flush_output/1

Formatflush_output(+Handle)
Arguments
+Handlehandle_stream Stream handle.
NoteThe reasons because the predicate can fail are.
  • The stream handle is invalid.
Flush the stream's buffer.
> :- flush_output(X).

eof_stream/1

Formateof_stream(+Handle)
Arguments
+Handlehandle_stream Stream handle.
NoteThe reasons because the predicate can fail are.
  • The stream handle is invalid.
Says if the end of the stream has been reached.
> ?- eof_stream(X).

stdin_stream/1

Formatstdin_stream(-Handle)
Arguments
-Handlehandle_stream Stream handle.
Return the handle of stdin.
> :- stdin_stream(X).

stdout_stream/1

Formatstdout_stream(-Handle)
Arguments
-Handlehandle_stream Stream handle.
Return the handle of stdout.
> :- stdout_stream(X).

stderr_stream/1

Formatstderr_stream(-Handle)
Arguments
-Handlehandle_stream Stream handle.
Return the handle of stderr.
> :- stderr_stream(X).

Top of this page Contents Index of this package LiLFeS Documents LiLFeS Home Page Tsujii laboratory

This document is automatically created by lildoc on Fri Sep 24 14:13:58 2004