=================================================================== RCS file: /home/cvs/OpenXM/src/asir-doc/parts/builtin/io.texi,v retrieving revision 1.5 retrieving revision 1.7 diff -u -p -r1.5 -r1.7 --- OpenXM/src/asir-doc/parts/builtin/io.texi 2000/11/13 00:16:36 1.5 +++ OpenXM/src/asir-doc/parts/builtin/io.texi 2001/04/23 05:45:37 1.7 @@ -1,4 +1,4 @@ -@comment $OpenXM: OpenXM/src/asir-doc/parts/builtin/io.texi,v 1.4 2000/04/28 08:12:01 noro Exp $ +@comment $OpenXM: OpenXM/src/asir-doc/parts/builtin/io.texi,v 1.6 2001/03/12 05:01:18 noro Exp $ \BJP @node 入出力,,, 組み込み函数 @section 入出力 @@ -16,7 +16,7 @@ * bsave bload:: * bload27:: * print:: -* open_file close_file get_line get_byte purge_stdin:: +* open_file close_file get_line get_byte put_byte purge_stdin:: @end menu \JP @node end quit,,, 入出力 @@ -532,18 +532,19 @@ convenient to minimize programming efforts. xyz123gahaha @end example -\JP @node open_file close_file get_line get_byte purge_stdin,,, 入出力 -\EG @node open_file close_file get_line get_byte purge_stdin,,, Inputs and Outputs -@subsection @code{open_file}, @code{close_file}, @code{get_line}, @code{get_byte}, @code{purge_stdin} +\JP @node open_file close_file get_line get_byte put_byte purge_stdin,,, 入出力 +\EG @node open_file close_file get_line get_byte put_byte purge_stdin,,, Inputs and Outputs +@subsection @code{open_file}, @code{close_file}, @code{get_line}, @code{get_byte}, @code{put_byte}, @code{purge_stdin} @findex open_file @findex close_file @findex get_line @findex get_byte +@findex put_byte @findex purge_stdin @table @t -@item open_file("@var{filename}") -\JP :: @var{filename} を読み出し用にオープンする. +@item open_file("@var{filename}"[,"@var{mode}"]) +\JP :: @var{filename} をオープンする. \EG :: Opens @var{filename} for reading. @item close_file(@var{num}) \JP :: 識別子 @var{num} のファイルをクローズする. @@ -554,18 +555,25 @@ xyz123gahaha @item get_byte(@var{num}) \JP :: 識別子 @var{num} のファイルから 1 バイト読む. \EG :: Reads a byte from the file indicated by a descriptor @var{num}. +@item put_byte(@var{num}) +\JP :: 識別子 @var{num} のファイルに 1 バイト書く. +\EG :: Writes a byte to the file indicated by a descriptor @var{num}. @item purge_stdin() +@item purge_stdin() \JP :: 標準入力のバッファをクリアする. \EG :: Clears the buffer for the standard input. @end table @table @var @item return -\JP @code{open_file()} : 整数 (識別子); @code{close_file()} : 1; @code{get_line()} : 文字列, @code{get_byte()} : 整数 -\EG @code{open_file()} : integer (fild id); @code{close_file()} : 1; @code{get_line()} : string, @code{get_byte()} : integer +\JP @code{open_file()} : 整数 (識別子); @code{close_file()} : 1; @code{get_line()} : 文字列; @code{get_byte()}, @code{put_byte()} : 整数 +\EG @code{open_file()} : integer (fild id); @code{close_file()} : 1; @code{get_line()} : string; @code{get_byte()}, @code{put_byte()} : integer @item filename \JP ファイル名 (パス名) \EG file (path) name +@item mode +\JP 文字列 +\EG string @item num \JP 非負整数 (ファイル識別子) \EG non-negative integer (file descriptor) @@ -573,13 +581,18 @@ xyz123gahaha @itemize @bullet \BJP -@item @code{open_file()} は読み出し用にファイルをオープンする. 成功した -場合, ファイル識別子として非負整数を返す. 失敗の場合エラーとなる. +@item @code{open_file()} はファイルをオープンする. @var{mode} 指定が +ない場合読み出し用, @var{mode} 指定がある場合には, C の標準入出力 +関数 @code{fopen()} に対するモード指定とみなす. たとえば新規書き込み +用の場合 @code{"w"}, 末尾追加の場合 @code{"a"} など. +成功した場合, ファイル識別子として非負整数を返す. 失敗の場合エラーとなる. 不要になったファイルは @code{close_file()} でクローズする. @item @code{get_line()} は現在オープンしているファイルから 1 行読み, 文字列として返す. 引数がない場合, 標準入力から 1 行読む. @item @code{get_byte()} は現在オープンしているファイルから 1 バイト読み 整数として返す. +@item @code{put_byte()} は現在オープンしているファイルに 1 バイト書き, +そのバイトを整数として返す. @item ファイルの終りまで読んだ後に @code{get_line()} が呼ばれた場合, 整数の 0 を返す. @item 読み出した文字列は, 必要があれば @code{sub_str()} などの文字列処理 @@ -590,7 +603,14 @@ xyz123gahaha 呼び出す. \E \BEG -@item @code{open_file()} opens a file for reading. +@item @code{open_file()} opens a file. +If @var{mode} is not specified, a file is opened for reading. +If @var{mode} is specified, it is used as the mode specification for +C standard I/O function @code{fopen()}. For example @code{"w"} requests +that the file is truncated to zero length or created for writing. +@code{"a"} requests that the file is opened for writing or created +if it does not exist. +The stream pointer is set at the end of the file. If successful, it returns a non-negative integer as the file descriptor. Otherwise the system error function is called. Unnecessary files should be closed by @code{close_file()}. @@ -599,6 +619,8 @@ line as a string. If no argument is supplied, it reads standard input. @item @code{get_byte()} reads a byte from an opened file and returns the it as an integer. +@item @code{put_byte()} writes a byte from an opened file and returns the +the byte as an integer. @item A @code{get_line()} call after reading the end of file returns an integer 0. @item Strings can be converted into internal forms with string manipulation