version 1.1.1.1, 1999/12/08 05:47:44 |
version 1.7, 2001/04/23 05:45:37 |
|
|
|
@comment $OpenXM: OpenXM/src/asir-doc/parts/builtin/io.texi,v 1.6 2001/03/12 05:01:18 noro Exp $ |
|
\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 |
|
\E |
|
\BEG |
|
@node Inputs and Outputs,,, Built-in Function |
|
@section Inputs and Outputs |
|
\E |
|
|
@menu |
@menu |
* end quit:: |
* end quit:: |
|
|
* bsave bload:: |
* bsave bload:: |
* bload27:: |
* bload27:: |
* print:: |
* print:: |
|
* open_file close_file get_line get_byte put_byte purge_stdin:: |
@end menu |
@end menu |
|
|
@node end quit,,, $BF~=PNO(B |
\JP @node end quit,,, $BF~=PNO(B |
|
\EG @node end quit,,, Inputs and Outputs |
@subsection @code{end}, @code{quit} |
@subsection @code{end}, @code{quit} |
@findex end |
@findex end |
@findex quit |
@findex quit |
|
|
@table @t |
@table @t |
@item end, quit |
@item end, quit |
|
\BJP |
:: $B8=:_FI$_9~$_Cf$N%U%!%$%k$rJD$8$k(B. |
:: $B8=:_FI$_9~$_Cf$N%U%!%$%k$rJD$8$k(B. |
$B%H%C%W%l%Y%k$K$*$$$F$O%;%C%7%g%s$r=*N;$9$k$3$H$K$J$k(B. |
$B%H%C%W%l%Y%k$K$*$$$F$O%;%C%7%g%s$r=*N;$9$k$3$H$K$J$k(B. |
|
\E |
|
\BEG |
|
:: Close the currently reading file. |
|
At the top level, terminate the @b{Asir} session. |
|
\E |
@end table |
@end table |
|
|
@itemize @bullet |
@itemize @bullet |
|
\BJP |
@item |
@item |
@code{end}, @code{quit} $B$H$b$KL50z?t$NH!?t$G$"$k$,(B, @samp{()} $B$J$7$G(B |
@code{end}, @code{quit} $B$H$b$KL50z?t$NH!?t$G$"$k$,(B, @samp{()} $B$J$7$G(B |
$B8F$S=P$9$3$H$,$G$-$k(B. $B$$$:$l$b8=:_FI$_9~$_Cf$N%U%!%$%k$rJD$8$k(B. |
$B8F$S=P$9$3$H$,$G$-$k(B. $B$$$:$l$b8=:_FI$_9~$_Cf$N%U%!%$%k$rJD$8$k(B. |
|
|
$B%U%!%$%k$N>l9g(B, $B%U%!%$%k$N=*C<$^$GFI$a$P(B, $B<+F0E*$K%U%!%$%k$OJD$8$i$l$k(B |
$B%U%!%$%k$N>l9g(B, $B%U%!%$%k$N=*C<$^$GFI$a$P(B, $B<+F0E*$K%U%!%$%k$OJD$8$i$l$k(B |
$B$,(B, $B%H%C%W%l%Y%k$N>l9g%W%m%s%W%H$,=P$J$$$^$^(B, $BF~NOBT$A$K$J$k$N$G(B, |
$B$,(B, $B%H%C%W%l%Y%k$N>l9g%W%m%s%W%H$,=P$J$$$^$^(B, $BF~NOBT$A$K$J$k$N$G(B, |
$B%U%!%$%k$N=*C<$K$O(B @code{end$} $B$r=q$/$N$,K>$^$7$$(B. |
$B%U%!%$%k$N=*C<$K$O(B @code{end$} $B$r=q$/$N$,K>$^$7$$(B. |
|
\E |
|
\BEG |
|
@item |
|
These two functions take no arguments. These functions can be called |
|
without a @samp{()}. Either function close the current input file. |
|
This means the termination of the @b{Asir} session at the top level. |
|
@item |
|
An input file will be automatically closed if it is read to its end. |
|
However, if no @code{end$} is written at the last of the input file, |
|
the control will be returned to the top level and @b{Asir} will be |
|
waiting for an input without any prompting. |
|
Thus, in order to avoid confusion, putting a @code{end$} at the last |
|
line of the input file is strongly recommended. |
|
\E |
@end itemize |
@end itemize |
|
|
@example |
@example |
|
|
@end example |
@end example |
|
|
@table @t |
@table @t |
@item $B;2>H(B |
\JP @item $B;2>H(B |
|
\EG @item References |
@fref{load}. |
@fref{load}. |
@end table |
@end table |
|
|
@node load,,, $BF~=PNO(B |
\JP @node load,,, $BF~=PNO(B |
|
\EG @node load,,, Inputs and Outputs |
@subsection @code{load} |
@subsection @code{load} |
@findex load |
@findex load |
|
|
@table @t |
@table @t |
@item load("@var{filename}") |
@item load("@var{filename}") |
:: @var{filename} $B$rFI$_9~$`(B. |
\JP :: @var{filename} $B$rFI$_9~$`(B. |
|
\EG :: Reads a program file @var{filename}. |
@end table |
@end table |
|
|
@table @var |
@table @var |
@item return |
@item return |
(1|0) |
(1|0) |
@item filename |
@item filename |
$B%U%!%$%kL>(B ($B%Q%9L>(B) |
\JP $B%U%!%$%kL>(B ($B%Q%9L>(B) |
|
\EG file (path) name |
@end table |
@end table |
|
|
@itemize @bullet |
@itemize @bullet |
|
\BJP |
@item |
@item |
$B<B:]$N%W%m%0%i%`$N=q$-J}$O(B, @xref{$B%f!<%68@8l(B Asir}. |
$B<B:]$N%W%m%0%i%`$N=q$-J}$O(B, @xref{$B%f!<%68@8l(B Asir}. |
$B%F%-%9%H%U%!%$%k$rFI$_9~$`>l9g(B, @code{cpp} |
$B%F%-%9%H%U%!%$%k$rFI$_9~$`>l9g(B, @code{cpp} |
|
|
$B%5!<%A$9$k(B. $B$=$l$i$K3:Ev$9$k%U%!%$%k$,B8:_$7$J$$>l9g(B, $BI8=`%i%$%V%i%j(B |
$B%5!<%A$9$k(B. $B$=$l$i$K3:Ev$9$k%U%!%$%k$,B8:_$7$J$$>l9g(B, $BI8=`%i%$%V%i%j(B |
$B%G%#%l%/%H%j(B ($B$"$k$$$O4D6-JQ?t(B @code{ASIR_LIBDIR} $B$K@_Dj$5$l$F$$$k(B |
$B%G%#%l%/%H%j(B ($B$"$k$$$O4D6-JQ?t(B @code{ASIR_LIBDIR} $B$K@_Dj$5$l$F$$$k(B |
$B%G%#%l%/%H%j(B) $B$b%5!<%A$9$k(B. |
$B%G%#%l%/%H%j(B) $B$b%5!<%A$9$k(B. |
Windows $BHG$N>l9g(B, @code{ASIR_LIBDIR} $B$,@_Dj$5$l$F$$$J$$>l9g$K$O(B, @code{get_rootdir()/lib} |
Windows $BHG$N>l9g(B, @code{ASIR_LIBDIR} $B$,@_Dj$5$l$F$$$J$$>l9g$K$O(B, |
$B$r%5!<%A$9$k(B. |
@code{get_rootdir()/lib} $B$r%5!<%A$9$k(B. |
@item |
@item |
$BFI$_9~$`%U%!%$%k$N:G8e$K(B, @code{end$} $B$,$J$$$H(B @code{load()} |
$BFI$_9~$`%U%!%$%k$N:G8e$K(B, @code{end$} $B$,$J$$$H(B @code{load()} |
$B=*N;8e$K%W%m%s%W%H$,$G$J$$$,(B, $B<B:]$K$OF~NO$r<u$1IU$1$k(B. $B$7$+$7(B, |
$B=*N;8e$K%W%m%s%W%H$,$G$J$$$,(B, $B<B:]$K$OF~NO$r<u$1IU$1$k(B. $B$7$+$7(B, |
Line 83 Windows $BHG$N>l9g(B, @code{ASIR_LIBDIR} $B$,@_Dj$5 |
|
Line 118 Windows $BHG$N>l9g(B, @code{ASIR_LIBDIR} $B$,@_Dj$5 |
|
$B$?$a(B, @code{end$} $B$r$*4+$a$9$k(B. ) |
$B$?$a(B, @code{end$} $B$r$*4+$a$9$k(B. ) |
@item |
@item |
Windows $BHG$b%G%#%l%/%H%j$N%;%Q%l!<%?$H$7$F(B @samp{/} $B$rMQ$$$k(B. |
Windows $BHG$b%G%#%l%/%H%j$N%;%Q%l!<%?$H$7$F(B @samp{/} $B$rMQ$$$k(B. |
|
\E |
|
\BEG |
|
@item |
|
@xref{User language Asir} for practical programming. |
|
Since text files are read through @code{cpp}, |
|
the user can use, as in C programs, @code{#include} and @code{#define} |
|
in @b{Asir} program source codes. |
|
@item |
|
It returns 1 if the designated file exists, 0 otherwise. |
|
@item |
|
If the @var{filename} begins with @samp{/}, it is understood as an |
|
absolute path name; with @samp{.}, relative path name from current |
|
directory; otherwise, the file is searched first from directories |
|
assigned to an environmental variable @code{ASIRLOADPATH}, then |
|
if the search ends up in failure, the standard library directory |
|
(or directories assigned to @code{ASIR_LIBDIR}) shall be searched. |
|
On Windows, @code{get_rootdir()/lib} is searched if |
|
@code{ASIR_LIBDIR} is not set. |
|
@item |
|
We recommend to write an @code{end} command at the last line of |
|
your program. If not, @b{Asir} will not give you a prompt after it |
|
will have executed @code{load} command. |
|
(Escape with an interrupt character (@pxref{Interruption}), |
|
if you have lost yourself.) |
|
Even in such a situation, |
|
@b{Asir} itself is still ready to read keyboard inputs as usual. |
|
It is, however, embarrassing and may cause other errors. |
|
Therefore, to put an @code{end$} at the last line is desirable. |
|
(Command @code{end;} will work as well, |
|
but it also returns and displays verbose.) |
|
@item |
|
On Windows one has to use @samp{/} as the separator of directory names. |
|
\E |
@end itemize |
@end itemize |
|
|
@table @t |
@table @t |
@item $B;2>H(B |
\JP @item $B;2>H(B |
|
\EG @item References |
@fref{end quit}, @fref{which}, @fref{get_rootdir}. |
@fref{end quit}, @fref{which}, @fref{get_rootdir}. |
@end table |
@end table |
|
|
@node which,,, $BF~=PNO(B |
\JP @node which,,, $BF~=PNO(B |
|
\EG @node which,,, Inputs and Outputs |
@subsection @code{which} |
@subsection @code{which} |
@findex which |
@findex which |
|
|
@table @t |
@table @t |
@item which("@var{filename}") |
@item which("@var{filename}") |
:: $B0z?t(B @var{filename} $B$KBP$7(B, @code{load()} $B$,FI$_9~$`%Q%9L>$rJV$9(B. |
\JP :: $B0z?t(B @var{filename} $B$KBP$7(B, @code{load()} $B$,FI$_9~$`%Q%9L>$rJV$9(B. |
|
\EG :: This returns the path name for the @var{filename} which @code{load()} will read. |
@end table |
@end table |
|
|
@table @var |
@table @var |
@item return |
@item return |
$B%Q%9L>(B |
\JP $B%Q%9L>(B |
|
\EG path name |
@item filename |
@item filename |
$B%U%!%$%kL>(B ($B%Q%9L>(B) $B$^$?$O(B 0 |
\JP $B%U%!%$%kL>(B ($B%Q%9L>(B) $B$^$?$O(B 0 |
|
\EG filename (path name) or 0 |
@end table |
@end table |
|
|
@itemize @bullet |
@itemize @bullet |
|
\BJP |
@item |
@item |
@code{load()} $B$,%U%!%$%k$r%5!<%A$9$k<j=g$K=>$C$F%5!<%A$7(B, |
@code{load()} $B$,%U%!%$%k$r%5!<%A$9$k<j=g$K=>$C$F%5!<%A$7(B, |
$B%U%!%$%k$,B8:_$9$k>l9g$K$O%Q%9L>$rJ8;zNs$H$7$F(B, $BB8:_$7$J$$>l9g(B |
$B%U%!%$%k$,B8:_$9$k>l9g$K$O%Q%9L>$rJ8;zNs$H$7$F(B, $BB8:_$7$J$$>l9g(B |
Line 115 Windows $BHG$b%G%#%l%/%H%j$N%;%Q%l!<%?$H$7$F(B @samp |
|
Line 189 Windows $BHG$b%G%#%l%/%H%j$N%;%Q%l!<%?$H$7$F(B @samp |
|
$B%5!<%A$N<j=g$K$D$$$F$O(B @code{load()} $B$r;2>H(B. |
$B%5!<%A$N<j=g$K$D$$$F$O(B @code{load()} $B$r;2>H(B. |
@item |
@item |
Windows $BHG$b%G%#%l%/%H%j$N%;%Q%l!<%?$H$7$F(B @samp{/} $B$rMQ$$$k(B. |
Windows $BHG$b%G%#%l%/%H%j$N%;%Q%l!<%?$H$7$F(B @samp{/} $B$rMQ$$$k(B. |
|
\E |
|
\BEG |
|
@item |
|
This function searches directory trees according to the same procedure |
|
as @code{load()} will do. Then, returns a string, the path name to the |
|
file if the named file exists; 0 unless otherwise. |
|
@item |
|
For details of searching procedure, |
|
refer to the description about @code{load()}. |
|
@item |
|
On Windows one has to use @samp{/} as the separator of directory names. |
|
\E |
@end itemize |
@end itemize |
|
|
@example |
@example |
Line 127 Windows $BHG$b%G%#%l%/%H%j$N%;%Q%l!<%?$H$7$F(B @samp |
|
Line 213 Windows $BHG$b%G%#%l%/%H%j$N%;%Q%l!<%?$H$7$F(B @samp |
|
@end example |
@end example |
|
|
@table @t |
@table @t |
@item $B;2>H(B |
\JP @item $B;2>H(B |
|
\EG @item References |
@fref{load}. |
@fref{load}. |
@end table |
@end table |
|
|
@node output,,, $BF~=PNO(B |
\JP @node output,,, $BF~=PNO(B |
|
\EG @node output,,, Inputs and Outputs |
@subsection @code{output} |
@subsection @code{output} |
@findex output |
@findex output |
|
|
@table @t |
@table @t |
@item output(["@var{filename}"]) |
@item output(["@var{filename}"]) |
:: $B0J9_$N=PNO@h$r(B @var{filename}$B$^$?$OI8=`=PNO$K@ZBX$($k(B. |
\JP :: $B0J9_$N=PNO@h$r(B @var{filename}$B$^$?$OI8=`=PNO$K@ZBX$($k(B. |
|
\EG :: Writes the return values and prompt onto file @var{filename}. |
@end table |
@end table |
|
|
@table @var |
@table @var |
@item return |
@item return |
1 |
1 |
@item filename |
@item filename |
$B%U%!%$%kL>(B |
\JP $B%U%!%$%kL>(B |
|
\EG filename |
@end table |
@end table |
|
|
@itemize @bullet |
@itemize @bullet |
|
\BJP |
@item |
@item |
@b{Asir} $B$N=PNO$rI8=`=PNO$+$i(B, $B%U%!%$%k$X$N=PNO$K@ZBX$($k(B. |
@b{Asir} $B$N=PNO$rI8=`=PNO$+$i(B, $B%U%!%$%k$X$N=PNO$K@ZBX$($k(B. |
$B$J$*(B, $B%U%!%$%k=PNO$N4V$O(B, $BI8=`=PNO$K$O%-!<%\!<%I$+$i$NF~NO0J30(B, |
$B$J$*(B, $B%U%!%$%k=PNO$N4V$O(B, $BI8=`=PNO$K$O%-!<%\!<%I$+$i$NF~NO0J30(B, |
Line 174 Windows $BHG$b%G%#%l%/%H%j$N%;%Q%l!<%?$H$7$F(B @samp |
|
Line 265 Windows $BHG$b%G%#%l%/%H%j$N%;%Q%l!<%?$H$7$F(B @samp |
|
@code{bload()}, @code{bsave()} $B$r;H$&$N$,(B, $B;~4V(B, $B6u4V$H$b$K8zN($,$h$$(B. |
@code{bload()}, @code{bsave()} $B$r;H$&$N$,(B, $B;~4V(B, $B6u4V$H$b$K8zN($,$h$$(B. |
@item |
@item |
Windows $BHG$b%G%#%l%/%H%j$N%;%Q%l!<%?$H$7$F(B @samp{/} $B$rMQ$$$k(B. |
Windows $BHG$b%G%#%l%/%H%j$N%;%Q%l!<%?$H$7$F(B @samp{/} $B$rMQ$$$k(B. |
|
\E |
|
\BEG |
|
@item |
|
Standard output stream of @b{Asir} is redirected to the specified file. |
|
While @b{Asir} is writing its outputs onto a file, no outputs, except for |
|
keyboard inputs and some of error messages, are written onto the standard |
|
output. (You cannot see the result on the display.) |
|
@item |
|
To direct the @b{Asir} outputs to the standard output, issue the command |
|
without argument, i.e., @code{output()}. |
|
@item |
|
If the specified file already exists, new outputs will be added to the |
|
tail of the file. If not, a file is newly created and the outputs |
|
will be written onto the file. |
|
@item |
|
When file name is specified without double quotes (@code{""}), or |
|
when protected file is specified, an error occurs and the system returns |
|
to the top level. |
|
@item |
|
If you want to write inputs from the key board onto the file as well |
|
as @b{Asir} outputs, put command @code{ctrl("echo",1)}, and then |
|
redirect the standard output to your desired file. |
|
@item |
|
Contents which are written onto the standard error output, CPU time etc., |
|
are not written onto the file. |
|
@item |
|
Reading and writing algebraic expressions which contain neither |
|
functional forms nor unknown coefficients (@code{vtype()} References) |
|
are performed more efficiently, with respect to both time and space, |
|
by @code{bload()} and @code{bsave()}. |
|
@item |
|
On Windows one has to use @samp{/} as the separator of directory names. |
|
\E |
@end itemize |
@end itemize |
|
|
@example |
@example |
|
|
@end example |
@end example |
|
|
@table @t |
@table @t |
@item $B;2>H(B |
\JP @item $B;2>H(B |
|
\EG @item References |
@fref{ctrl}, @fref{bsave bload}. |
@fref{ctrl}, @fref{bsave bload}. |
@end table |
@end table |
|
|
@node bsave bload,,, $BF~=PNO(B |
\JP @node bsave bload,,, $BF~=PNO(B |
|
\EG @node bsave bload,,, Inputs and Outputs |
@subsection @code{bsave}, @code{bload} |
@subsection @code{bsave}, @code{bload} |
@findex bsave |
@findex bsave |
@findex bload |
@findex bload |
|
|
@table @t |
@table @t |
@item bsave(@var{obj},"@var{filename}") |
@item bsave(@var{obj},"@var{filename}") |
:: @var{filename} $B$K(B @var{obj} $B$r%P%$%J%j7A<0$G=q$-9~$`(B. |
\JP :: @var{filename} $B$K(B @var{obj} $B$r%P%$%J%j7A<0$G=q$-9~$`(B. |
@item bsave("@var{filename}") |
\EG :: This function writes @var{obj} onto @var{filename} in binary form. |
:: @var{filename} $B$+$i?t<0$r%P%$%J%j7A<0$GFI$_9~$`(B. |
@item bload("@var{filename}") |
|
\JP :: @var{filename} $B$+$i?t<0$r%P%$%J%j7A<0$GFI$_9~$`(B. |
|
\EG :: This function reads an expression from @var{filename} in binary form. |
@end table |
@end table |
|
|
@table @var |
@table @var |
@item return |
@item return |
@code{bsave()} : 1, @code{bload()} : $BFI$_9~$s$@?t<0(B |
\JP @code{bsave()} : 1, @code{bload()} : $BFI$_9~$s$@?t<0(B |
|
\EG @code{bsave()} : 1, @code{bload()} : the expression read |
@item obj |
@item obj |
$BH!?t7A<0(B, $BL$Dj78?t$r4^$^$J$$G$0U$N?t<0(B |
\JP $BH!?t7A<0(B, $BL$Dj78?t$r4^$^$J$$G$0U$N?t<0(B |
|
\BEG |
|
arbitrary expression which does not contain neither function forms |
|
nor unknown coefficients. |
|
\E |
@item filename |
@item filename |
$B%U%!%$%kL>(B |
\JP $B%U%!%$%kL>(B |
|
\EG filename |
@end table |
@end table |
|
|
@itemize @bullet |
@itemize @bullet |
|
\BJP |
@item |
@item |
@code{bsave()} $B$OFbIt7A<0$r$[$\$=$N$^$^%P%$%J%j7A<0$G%U%!%$%k$K=q$-9~$`(B. |
@code{bsave()} $B$OFbIt7A<0$r$[$\$=$N$^$^%P%$%J%j7A<0$G%U%!%$%k$K=q$-9~$`(B. |
@code{bload()} $B$O(B, @code{bsave()} $B$G=q$-9~$s$@?t<0$rFI$_9~$s$GFbIt7A<0(B |
@code{bload()} $B$O(B, @code{bsave()} $B$G=q$-9~$s$@?t<0$rFI$_9~$s$GFbIt7A<0(B |
|
|
$B$=$N>l9g$K$O(B, $B<+F0E*$K8=:_$NJQ?t=g=x$K$*$1$kFbIt7A<0$KJQ49$5$l$k(B. |
$B$=$N>l9g$K$O(B, $B<+F0E*$K8=:_$NJQ?t=g=x$K$*$1$kFbIt7A<0$KJQ49$5$l$k(B. |
@item |
@item |
Windows $BHG$b%G%#%l%/%H%j$N%;%Q%l!<%?$H$7$F(B @samp{/} $B$rMQ$$$k(B. |
Windows $BHG$b%G%#%l%/%H%j$N%;%Q%l!<%?$H$7$F(B @samp{/} $B$rMQ$$$k(B. |
|
\E |
|
\BEG |
|
@item |
|
Function @code{bsave()} writes an object onto a file in its internal |
|
form (not exact internal form but very similar). |
|
Function @code{bload()} read the expression from files |
|
which is written by @code{bsave()}. |
|
Current implementation support arbitrary expressions, including |
|
lists, arrays (i.e., vectors and matrices), except for function forms |
|
and unknown coefficients (@code{vtype()} References.) |
|
@item |
|
The parser is activated to retrieve expressions written by |
|
@code{output()} , whereas internal forms are directly reconstructed |
|
by @code{bload()} from the @code{bsave()}'ed object in the file. |
|
The latter is much more efficient with respect to both time and space. |
|
@item |
|
It may happen that the variable ordering at reading is changed from |
|
that at writing. In such a case, the variable ordering in the internal |
|
expression is automatically rearranged according to the current |
|
variable ordering. |
|
@item |
|
On Windows one has to use @samp{/} as the separator of directory names. |
|
\E |
@end itemize |
@end itemize |
|
|
@example |
@example |
|
|
@end example |
@end example |
|
|
@table @t |
@table @t |
@item $B;2>H(B |
\JP @item $B;2>H(B |
|
\EG @item References |
@fref{output}. |
@fref{output}. |
@end table |
@end table |
|
|
@node bload27,,, $BF~=PNO(B |
\JP @node bload27,,, $BF~=PNO(B |
|
\EG @node bload27,,, Inputs and Outputs |
@subsection @code{bload27} |
@subsection @code{bload27} |
@findex bload27 |
@findex bload27 |
|
|
@table @t |
@table @t |
@item xxx(@var{filename}) |
@item bload27("@var{filename}") |
:: $B5lHG$G:n$i$l$?(B bsave file $B$NFI$_9~$_(B |
\JP :: $B5lHG$G:n$i$l$?(B bsave file $B$NFI$_9~$_(B |
|
\EG :: Reads bsaved file created by older version of @b{Asir}. |
@end table |
@end table |
|
|
@table @var |
@table @var |
@item return |
@item return |
$BFI$_9~$s$@?t<0(B |
\JP $BFI$_9~$s$@?t<0(B |
|
\EG expression read |
@item filename |
@item filename |
$B%U%!%$%kL>(B |
\JP $B%U%!%$%kL>(B |
|
\EG filename |
@end table |
@end table |
|
|
@itemize @bullet |
@itemize @bullet |
|
\BJP |
@item |
@item |
$B5lHG$G$O(B, $BB?G\D9@0?t$,(B, 1 $B%o!<%I(B 27 bit $B$GI=8=$5$l$F$$$?$,(B, $B?7HG$G$O(B 1 $B%o!<%I(B 32 bit |
$B5lHG$G$O(B, $BB?G\D9@0?t$,(B, 1 $B%o!<%I(B 27 bit $B$GI=8=$5$l$F$$$?$,(B, $B?7HG$G$O(B 1 $B%o!<%I(B 32 bit |
$B$KJQ99$5$l$?(B. $B$3$N$?$a(B, $B5lHG$G(B @code{bsave} $B$5$l$?%P%$%J%j%U%!%$%k$O$=$N$^$^$G$O(B |
$B$KJQ99$5$l$?(B. $B$3$N$?$a(B, $B5lHG$G(B @code{bsave} $B$5$l$?%P%$%J%j%U%!%$%k$O$=$N$^$^$G$O(B |
$BFI$_9~$a$J$$(B. $B$3$N$h$&$J%U%!%$%k$rFI$_9~$`$?$a$K(B @code{bload27} $B$rMQ$$$k(B. |
$BFI$_9~$a$J$$(B. $B$3$N$h$&$J%U%!%$%k$rFI$_9~$`$?$a$K(B @code{bload27} $B$rMQ$$$k(B. |
@item |
@item |
Windows $BHG$b%G%#%l%/%H%j$N%;%Q%l!<%?$H$7$F(B @samp{/} $B$rMQ$$$k(B. |
Windows $BHG$b%G%#%l%/%H%j$N%;%Q%l!<%?$H$7$F(B @samp{/} $B$rMQ$$$k(B. |
|
\E |
|
\BEG |
|
@item |
|
In older versions an arbitrary precision integer is represented as |
|
an array of 27bit integers. In the current version it is represented |
|
as an array of 32bit integers. By this incompatibility the bsaved |
|
file created by older versions cannot be read in the current version |
|
by @code{bload}. |
|
@code{bload27} is used to read such files. |
|
@item |
|
On Windows one has to use @samp{/} as the separator of directory names. |
|
\E |
@end itemize |
@end itemize |
|
|
@table @t |
@table @t |
@item $B;2>H(B |
\JP @item $B;2>H(B |
|
\EG @item References |
@fref{bsave bload}. |
@fref{bsave bload}. |
@end table |
@end table |
|
|
@node print,,, $BF~=PNO(B |
\JP @node print,,, $BF~=PNO(B |
|
\EG @node print,,, Inputs and Outputs |
@subsection @code{print} |
@subsection @code{print} |
@findex print |
@findex print |
|
|
@table @t |
@table @t |
@item print(@var{obj} [,@var{nl}]) |
@item print(@var{obj} [,@var{nl}]) |
:: @var{obj} $B$rI=<($9$k(B. |
\JP :: @var{obj} $B$rI=<($9$k(B. |
|
\EG :: Displays (or outputs) @var{obj}. |
@end table |
@end table |
|
|
@table @var |
@table @var |
@item return |
@item return |
0 |
0 |
@item obj |
@item obj |
$BG$0U(B |
\JP $BG$0U(B |
|
\EG arbitrary |
@item nl |
@item nl |
$B%U%i%0(B ($BG$0U(B) |
\JP $B%U%i%0(B ($BG$0U(B) |
|
\EG flag (arbitrary) |
@end table |
@end table |
|
|
@itemize @bullet |
@itemize @bullet |
|
\BJP |
@item |
@item |
@var{obj} $B$rI>2A$7$FI=<($9$k(B. |
@var{obj} $B$rI>2A$7$FI=<($9$k(B. |
@item |
@item |
Line 319 Windows $BHG$b%G%#%l%/%H%j$N%;%Q%l!<%?$H$7$F(B @samp |
|
Line 501 Windows $BHG$b%G%#%l%/%H%j$N%;%Q%l!<%?$H$7$F(B @samp |
|
@code{print()$} $B$H$9$l$P(B, $B:G8e$N(B 0 $B$O=PNO$5$l$J$$(B. |
@code{print()$} $B$H$9$l$P(B, $B:G8e$N(B 0 $B$O=PNO$5$l$J$$(B. |
@item |
@item |
$BJ#?t$N(B @var{obj} $B$rF1;~$K=PNO$7$?$$;~$O(B @var{obj} $B$r%j%9%H$K$9$k$H$h$$(B. |
$BJ#?t$N(B @var{obj} $B$rF1;~$K=PNO$7$?$$;~$O(B @var{obj} $B$r%j%9%H$K$9$k$H$h$$(B. |
|
\E |
|
\BEG |
|
@item |
|
Displays (or outputs) @var{obj}. |
|
@item |
|
It normally adds linefeed code to cause the cursor moving to the next |
|
line. If 0 or 2 is given as the second argument, it does not add a linefeed. |
|
If the second argument is 0, the output is simply written in the buffer. |
|
If the second argument is 2, the output is flushed. |
|
@item |
|
The return value of this function is 0. |
|
If command @code{print(@var{rat});} is performed at the top level, |
|
first the value of @var{rat} will be printed, |
|
followed by a linefeed, followed by a 0 which is the value of the |
|
function and followed by a linefeed and the next prompt. |
|
(If the command is terminated by a `$', e.g., @code{print(@var{rat})$}, |
|
The last 0 will not be printed. ) |
|
@item |
|
Formatted outputs are not currently supported. |
|
If one wishes to output multiple objects by a single @code{print()} command, |
|
use list like @code{[@var{obj1,...}]}, which is not so beautiful, but |
|
convenient to minimize programming efforts. |
|
\E |
@end itemize |
@end itemize |
|
|
@example |
@example |
Line 327 Windows $BHG$b%G%#%l%/%H%j$N%;%Q%l!<%?$H$7$F(B @samp |
|
Line 532 Windows $BHG$b%G%#%l%/%H%j$N%;%Q%l!<%?$H$7$F(B @samp |
|
xyz123gahaha |
xyz123gahaha |
@end example |
@end example |
|
|
|
\JP @node open_file close_file get_line get_byte put_byte purge_stdin,,, $BF~=PNO(B |
|
\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}"[,"@var{mode}"]) |
|
\JP :: @var{filename} $B$r%*!<%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}. |
|
@item get_byte(@var{num}) |
|
\JP :: $B<1JL;R(B @var{num} $B$N%U%!%$%k$+$i(B 1 $B%P%$%HFI$`(B. |
|
\EG :: Reads a byte from the file indicated by a descriptor @var{num}. |
|
@item put_byte(@var{num}) |
|
\JP :: $B<1JL;R(B @var{num} $B$N%U%!%$%k$K(B 1 $B%P%$%H=q$/(B. |
|
\EG :: Writes a byte to the file indicated by a descriptor @var{num}. |
|
@item purge_stdin() |
|
@item purge_stdin() |
|
\JP :: $BI8=`F~NO$N%P%C%U%!$r%/%j%"$9$k(B. |
|
\EG :: Clears the buffer for the standard input. |
|
@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; @code{get_byte()}, @code{put_byte()} : $B@0?t(B |
|
\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 $B%U%!%$%kL>(B ($B%Q%9L>(B) |
|
\EG file (path) name |
|
@item mode |
|
\JP $BJ8;zNs(B |
|
\EG string |
|
@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$O%U%!%$%k$r%*!<%W%s$9$k(B. @var{mode} $B;XDj$,(B |
|
$B$J$$>l9gFI$_=P$7MQ(B, @var{mode} $B;XDj$,$"$k>l9g$K$O(B, C $B$NI8=`F~=PNO(B |
|
$B4X?t(B @code{fopen()} $B$KBP$9$k%b!<%I;XDj$H$_$J$9(B. $B$?$H$($P?75,=q$-9~$_(B |
|
$BMQ$N>l9g(B @code{"w"}, $BKvHxDI2C$N>l9g(B @code{"a"} $B$J$I(B. |
|
$B@.8y$7$?>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. $B0z?t$,$J$$>l9g(B, $BI8=`F~NO$+$i(B 1 $B9TFI$`(B. |
|
@item @code{get_byte()} $B$O8=:_%*!<%W%s$7$F$$$k%U%!%$%k$+$i(B 1 $B%P%$%HFI$_(B |
|
$B@0?t$H$7$FJV$9(B. |
|
@item @code{put_byte()} $B$O8=:_%*!<%W%s$7$F$$$k%U%!%$%k$K(B 1 $B%P%$%H=q$-(B, |
|
$B$=$N%P%$%H$r@0?t$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. |
|
@item @code{purge_stdin()} $B$O(B, $BI8=`F~NO%P%C%U%!$r6u$K$9$k(B. |
|
$B4X?tFb$G(B @code{get_line()} $B$K$h$jI8=`F~NO$+$iJ8;zNs$r<u$1<h$k>l9g(B, |
|
$B4{$K%P%C%U%!Fb$KB8:_$9$kJ8;zNs$K$h$k8mF0:n$rKI$0$?$a$K$"$i$+$8$a(B |
|
$B8F$S=P$9(B. |
|
\E |
|
\BEG |
|
@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()}. |
|
@item @code{get_line()} reads a line from an opened file and returns the |
|
line as a string. If no argument is supplied, it reads a line from the |
|
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 |
|
functions such as @code{sub_str()}, @code{eval_str()}. |
|
@item @code{purge_stdin()} clears the buffer for the standard input. |
|
When a function receives a character string from @code{get_line()}, |
|
this functions should be called in advance in order to avoid |
|
an incorrect behavior which is caused by the characters already |
|
exists in the buffer. |
|
\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 |
|
[190] close_file(Id); |
|
1 |
|
[191] open_file("test"); |
|
1 |
|
[192] get_line(1); |
|
12345 |
|
|
|
[193] get_byte(1); |
|
54 /* the ASCII code of '6' */ |
|
[194] get_line(1); |
|
7890 /* the rest of the last line */ |
|
[195] def test() @{ return get_line(); @} |
|
[196] def test1() @{ purge_stdin(); return get_line(); @} |
|
[197] test(); |
|
/* a remaining newline character has been read */ |
|
/* returns immediately */ |
|
[198] test1(); |
|
123; /* input from a keyboard */ |
|
123; /* returned value */ |
|
|
|
[199] |
|
|
|
@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 |