version 1.2, 1999/12/21 02:47:33 |
version 1.3, 2000/03/02 07:46:14 |
|
|
@comment $OpenXM$ |
@comment $OpenXM: OpenXM/src/asir-doc/parts/builtin/io.texi,v 1.2 1999/12/21 02:47:33 noro Exp $ |
\BJP |
\BJP |
@node $BF~=PNO(B,,, $BAH$_9~$_H!?t(B |
@node $BF~=PNO(B,,, $BAH$_9~$_H!?t(B |
@section $BF~=PNO(B |
@section $BF~=PNO(B |
|
|
* bsave bload:: |
* bsave bload:: |
* bload27:: |
* bload27:: |
* print:: |
* print:: |
|
* open_file close_file get_line:: |
@end menu |
@end menu |
|
|
\JP @node end quit,,, $BF~=PNO(B |
\JP @node end quit,,, $BF~=PNO(B |
Line 81 line of the input file is strongly recommended. |
|
Line 82 line of the input file is strongly recommended. |
|
@table @t |
@table @t |
@item load("@var{filename}") |
@item load("@var{filename}") |
\JP :: @var{filename} $B$rFI$_9~$`(B. |
\JP :: @var{filename} $B$rFI$_9~$`(B. |
\EG :: Read a program file @var{filename}. |
\EG :: Reads a program file @var{filename}. |
@end table |
@end table |
|
|
@table @var |
@table @var |
Line 531 convenient to minimize programming efforts. |
|
Line 532 convenient to minimize programming efforts. |
|
xyz123gahaha |
xyz123gahaha |
@end example |
@end example |
|
|
|
\JP @node open_file close_file get_line,,, $BF~=PNO(B |
|
\EG @node open_file close_file get_line,,, Inputs and Outputs |
|
@subsection @code{open_file}, @code{close_file}, @code{get_line} |
|
@findex open_file |
|
@findex close_file |
|
@findex get_line |
|
|
|
@table @t |
|
@item open_file("@var{filename}") |
|
\JP :: @var{filename} $B$rFI$_=P$7MQ$K%*!<%W%s$9$k(B. |
|
\EG :: Opens @var{filename} for reading. |
|
@item close_file(@var{num}) |
|
\JP :: $B<1JL;R(B @var{num} $B$N%U%!%$%k$r%/%m!<%:$9$k(B. |
|
\EG :: Closes the file indicated by a descriptor @var{num}. |
|
@item get_line(@var{num}) |
|
\JP :: $B<1JL;R(B @var{num} $B$N%U%!%$%k$+$i(B 1 $B9TFI$`(B. |
|
\EG :: Reads a line from the file indicated by a descriptor @var{num}. |
|
@end table |
|
|
|
@table @var |
|
@item return |
|
\JP @code{open_file()} : $B@0?t(B ($B<1JL;R(B); @code{close_file()} : 1; @code{get_line()} : $BJ8;zNs(B |
|
\EG @code{open_file()} : integer (fild id); @code{close_file()} : 1; @code{get_line()} : string |
|
@item filename |
|
\JP $B%U%!%$%kL>(B ($B%Q%9L>(B) |
|
\EG file (path) name |
|
@item num |
|
\JP $BHsIi@0?t(B ($B%U%!%$%k<1JL;R(B) |
|
\EG non-negative integer (file descriptor) |
|
@end table |
|
|
|
@itemize @bullet |
|
\BJP |
|
@item @code{open_file()} $B$OFI$_=P$7MQ$K%U%!%$%k$r%*!<%W%s$9$k(B. $B@.8y$7$?(B |
|
$B>l9g(B, $B%U%!%$%k<1JL;R$H$7$FHsIi@0?t$rJV$9(B. $B<:GT$N>l9g%(%i!<$H$J$k(B. |
|
$BITMW$K$J$C$?%U%!%$%k$O(B @code{close_file()} $B$G%/%m!<%:$9$k(B. |
|
@item @code{get_line()} $B$O8=:_%*!<%W%s$7$F$$$k%U%!%$%k$+$i(B 1 $B9TFI$_(B, |
|
$BJ8;zNs$H$7$FJV$9(B. |
|
@item $B%U%!%$%k$N=*$j$^$GFI$s$@8e$K(B @code{get_line()} $B$,8F$P$l$?>l9g(B, |
|
$B@0?t$N(B 0 $B$rJV$9(B. |
|
@item $BFI$_=P$7$?J8;zNs$O(B, $BI,MW$,$"$l$P(B @code{sub_str()} $B$J$I$NJ8;zNs=hM}(B |
|
$B4X?t$G2C9)$7$?$N$A(B @code{eval_str()} $B$K$h$jFbIt7A<0$KJQ49$G$-$k(B. |
|
\E |
|
\BEG |
|
@item @code{open_file()} opens a file for reading. |
|
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()}. |
|
@item @code{get_line()} reads a line from an opened file and returns the |
|
line as a string. |
|
@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 |
|
functions such as @code{sub_str()}, @code{eval_str()}. |
|
\E |
|
@end itemize |
|
|
|
@example |
|
[185] Id = open_file("test"); |
|
0 |
|
[186] get_line(Id); |
|
12345 |
|
|
|
[187] get_line(Id); |
|
67890 |
|
|
|
[188] get_line(Id); |
|
0 |
|
[189] type(@@@@); |
|
0 |
|
@end example |
|
|
|
@table @t |
|
\JP @item $B;2>H(B |
|
\EG @item References |
|
@fref{eval_str}, @fref{str_len str_chr sub_str}. |
|
@end table |