open(+論理名,+汎ストリーム(+物理名),[+オプション,...])...
Move to
Next Prev
Up Top
See also
バージョン3から4への移行
イントロダクション
abolish
abort
# append
arg
計算式(arithmetic)
アリティ(arity)
ASCII文字
assert
asserta_term, asserto_term, assertz_term
atom, atomic_length
\(バックスラッシュ)
#bagof, #setof
block, exit_block, cut_block
break
bye
call, execute
文字セット, char_code
#clause, #clause_term
clear_eol, clear_eos, clear_screen
close
コメント
compare
項の比較
値の比較
compiles
concat
連言(conjunction)
consult
コントロールスタック(control stack)
データの型変換(conversion)
copy_term
correct
cpu時間
#current_predicate, #current_atom, current_language
!(カット)
データベース(database)
debug, nodebug, debug_goal
debug_mode
decompcons
指令(directives)
選言(disjunction)
display
編集(edit)
終了(end)
end_of_file文字
equiv_char, image_length, byte_length
例外処理(exceptions)
error_protect, exception, exception_handler
exists
exit
expand_term, phrase(+ゴール,?リスト)
?- export, ?- common, ?- import, ?-hidden
事実(fact)
fail
filepos, files, flush, reset_streams
findall
float_format
# for
functor
gc
get, get0, get_until
getchar
getenv, get_home, get_last, move_cursor
get_global, # global_variable
ゴール(goal)
文法規則(grammar rules)
リストの先頭(head of list)
節のヘッド(head of clause)
help
ifprolog
ifsem
include
index
入力ストリーム(input stream)
インタプリタレベル(interpreter level)
is
length, #reverse
list_mode, listing
リスト(lists)
load, loaded
localtime
ループ(loops)
lower_upper, national_letters
make_atom, make_number
match, # match
# member
modify_mode
?- module, ?- module_body
name
nl
:- nonotify, nonotify
not
number
once
オペレータ(operator)
op, # current_op
outpos, outtab
出力ストリーム(output stream)
program_parameters, system_parameters, user_parameters
parse_atom
parse_position
predicate, predicate_mode
predicate_type
print
手続き(procedure)
program
# prolog_flag
prolog_library
prolog_system, prolog_version, proroot
put
put_byte, get_byte
raise_error
read, read_term
read_error, report_read_error
reconsult(+ファイル名)
# repeat
#retract
retractop
save_system, save_module
see, seeing, seen
set_global
set_home, setoutpos, setupterm
signal, signal_handler, alarm
skip
sort, keysort
spy
dbsize, ssize, gused, dbused, tused, lused
statistics
open, close, stream_control, #current_stream, link_stream
文字列(strings)
複合項(structures)
subatomic
sum, inc
symbol
計算式の構文(syntax of arithmetic expression)
構文チェッカー(syntax checker)
syntax_error
項の構文 (Syntax of terms)
system
system_date, system_time
system_predicate
tab
tell, telling, told
項(term)
X is time
trace, notrace, trace_mode, trace_goal
trace, tracing, traced
トレイル(trail)
true
tty_size
type_of, atom, nonvar, atomic, numeric, digit, realn, integer, struct, letter, var
未定義の述語(undefined_predicate)
?項1 = ?項2, +項1 \= +項2
?複合項 =.. -Univリスト, -複合項 =.. ?Univリスト
unload
unset_global
user
変数(variables)
write
IF Computer > IF/Prolog > Manuals > IF/Prolog V4.1 マニュアル > IF/Prolog V4.1 レファレンスマニュアル > open, close, stream_control, #current_stream, link_stream

open, close, stream_control, #current_stream, link_stream

MINERVA superseeded IF/Prolog. Please see http://www.ifcomputer.co.jp/MINERVA for details.

We discontinued to sell IF/Prolog Dec 31. 2003. Dedicated technical support for IF/Prolog ended Dec 31 2008. This site is maintained as a community service only.

open(+論理名,+汎ストリーム(+物理名),[+オプション,...]) close(+ストリーム) stream_control(+ストリーム,+制御) #current_stream(-論理名,+汎ストリーム(-物理名),-オプションリスト) link_stream(+論理名,+物理名)

IF/Prologバージョン4.0以上では、論理ストリームをサポートしています。デフォルトとして3クラスのストリームがサポートされています。その以外のクラスは、ユーザが定義をします。IF/PrologのすべてのI/O述語には、パラメータがN個とN+1個のものが用意されています。引数がN個の述語は、current_inputあるいはcurrent_outputを通して入出力を行います。パラメータがN+1個の述語は、他の論理ストリームを入出力に使用するためのパラメータを含んでいます。current_input(あるいはcurrent_output)は、述語see/seeing/seen(あるいはtell/telling/told)を使って変更することができます。

open/3は、入出力用に新しいストリームを開きます。「汎ストリーム」は、以下のいずれかになります。

file, string, null

「論理名」は必ず存在せねばならず、これは後でストリームが参照される時の名前になります。「物理名」は、その物理的な名前です(たとえばファイルシステム中のファイル名)。

「オプション」はストリームを開くモードを宣言し、以下のいずれかになります。

input ストリームは、読み込み用に開かれます output ストリームは、書き出し用に開かれます update ストリームは、読み込み/書き出し用に開かれます

以下は必要に応じて選択して下さい(つけなくてもかまいません)。

binary ストリームは、バイナリ・データを含みます text (デフォルト) ストリームは、テキスト・データを含みます append ストリームの末尾に出力を追加します truncate ストリームは、開かれた時に長さが0に切り捨てられます。

close/1は、論理ストリームである「ストリーム」を閉じます。同一の物理ストリームに対する最後の1個の論理ストリームが閉じられると、物理ストリームも閉じられます。

link_stream/2は、論理ストリーム名を物理ストリーム名にリンクします。ストリームである「物理名」は、予め開かれていなければなりません。

open(new_out, file('test.pro'), [output, truncate]), link_stream(debug_output, 'test.pro').

link_stream/2は、既存のストリーム名を書き変えるのに使うことができます。以下のコマンド列を実行すると、それ以後のstderrへの出力がなくなります。

open(black_hole, null(null), [output]). link_stream(stderr, null).

stream_control/2は、ストリームに制御情報を送ることができます。「制御」は、ストリームのデバイスクラスに依存します。以下の制御が、それぞれのストリームクラスに対して定義されています。

Class = file:

isatty ストリームが端末に接続されています。 setpos(P) seekpos(P,from_start)と同じです。 seekpos(Pos,Where) Whereは from_start, from_current, from_endのいずれかで、ファイルポインタを場所Posに移動させます。Posは整数で、ファイルの先頭/現在位置/終端のいずれかから計算されます。 rewind setpos(0)と同じです。 getpos(P) 現在のファイル位置を読み出します。 clearerror ファイルのエラーフラグをクリアします。 get_error(OnOff) エラーフラグを読み出します。 at_eof(YesNo) ファイルの終端にいるかどうかを知らせます。

isattyがtrueの場合には、さらに以下の制御が有効となります。

clear_eol 現在行の終わりまでクリアします。 clear_eos 画面の下端までクリアします。 size(Rows,Cols) 画面のサイズを読み出します。 move(Row,Col) カーソルを位置 Row/Colに移動させます。

Class = string:

getpos(P) 実際の文字列中の位置を読み出します。 input(String) 後で読み出されるべき文字列を定義します(読み込み用に開かれている場合) output(String) 以前に書き出された文字列を読み込みます(書き出し用に開かれている場合)。

?- open(s1, string(s), [output]).

yes ?- print(s1,'%s:%d\n',[hallo,10]).

yes ?- stream_control(s1, output(S)).

S = 'hallo:10\n'

yes

current_stream/3は、開かれているストリームすべてについての情報を返します。バックトラックを通じてすべてのストリームを調べることができます。

could_not_open_stream 「ストリーム」を開くことができなかった undefined_server 「汎ストリーム」のサーバが定義されていない stream_in_use 「ストリーム」がすでに使用されている too_many_streams ストリームの内部制限を越えている illegal_list 「オープンリスト」はリストでなければならない illegal_format フォーマットが正しいアトムでない atom_expected 「論理名」、「物理名」、「オープンリスト」はアトムでなければならない structure_expected 「汎ストリーム(-物理名)」は複合項でなければならない stream_not_open 「ストリーム」が開かれていない

read on...
IF/Prolog by Siemens
Language
English
Japanese
German
Server
USA
Japan
Site Access
Local Index
Local Contents
Site Contents
Site Index
Printer Friendly
For imode
For PDA
Search
document: http://www.ifcomputer.co.jp/IFProlog/Manuals/v4.1/reference/stream/home_en.html
published 2012/5/21 update 1995/11/6 (c) 1996-2009 IF Computer Japan
IF Computer 5-28-2 Sendagi, Bunkyo-ku Tel +81-3-5814-3352 start (AT) ifcomputer.com
Customer Support Tokyo 113-0022 Japan   http://www.ifcomputer.com
scroll to top managed with ubiCMS