通常のファイル入力/出力に加え、論理ストリームに対する入出力ができます。ストリームには、fileストリーム、stringストリーム、nullストリームの3種類があります。すべての入出力述語にはオプションのパラメータがあり、通常の入出力先であるcurrent_inputとcurrent_outputの代わりに使用するストリーム識別子を指定することができます。前節で述べたように、current_inputおよびcurrent_outputは、述語see/seeing/seen/あるいは/tell/telling/toldで変更できます。
次の例では、文字列にデータを送っています。
?- open(teststring, string(s), output ).
yes ?- write(teststring, 'This is a test n').
yes ?- stream_control(teststring, output(S)).
S = 'This is a test n' _ <-- ここで改行を押して下さい。
yes ?- _
ストリームの概念については、レファレンスマニュアルのストリームの項目を参照して下さい。
| 冒頭へ |
|