[ << ] | [ < ] | [ Up ] | [ > ] | [ >> ] | [Top] | [Contents] | [Index] | [ ? ] |
[ << ] | [ < ] | [ Up ] | [ > ] | [ >> ] | [Top] | [Contents] | [Index] | [ ? ] |
end
, quit
:: Close the currently reading file. At the top level, terminate the Asir session.
end$
is written at the last of the input file,
the control will be returned to the top level and Asir will be
waiting for an input without any prompting.
Thus, in order to avoid confusion, putting a end$
at the last
line of the input file is strongly recommended.
[6] quit; %
load
.
[ << ] | [ < ] | [ Up ] | [ > ] | [ >> ] | [Top] | [Contents] | [Index] | [ ? ] |
load
:: Reads a program file filename.
(1|0)
file (path) name
cpp
,
the user can use, as in C programs, #include
and #define
in Asir program source codes.
The cpp
which is installed to the system with a C compler is used in the unix version.
The mcpp
http://mcpp.sourceforge.net is used in the Windows version.
Note that the length of a line has a limit for an input mcpp
.
The OpenXM/bin/ox_cpp
is used in the unix/OpenXM version
(including cfep/asir for MacOS X).
This is the cpp
distributed with the Portable C compiler http://pcc.ludd.ltu.se.
ASIRLOADPATH
, then
if the search ends up in failure, the standard library directory
(or directories assigned to ASIR_LIBDIR
) shall be searched.
On Windows, get_rootdir()/lib
is searched if
ASIR_LIBDIR
is not set.
end
command at the last line of
your program. If not, Asir will not give you a prompt after it
will have executed load
command.
(Escape with an interrupt character (Interruption),
if you have lost yourself.)
Even in such a situation,
Asir itself is still ready to read keyboard inputs as usual.
It is, however, embarrassing and may cause other errors.
Therefore, to put an end$
at the last line is desirable.
(Command end;
will work as well,
but it also returns and displays verbose.)
[ << ] | [ < ] | [ Up ] | [ > ] | [ >> ] | [Top] | [Contents] | [Index] | [ ? ] |
which
:: This returns the path name for the filename which load()
will read.
path name
filename (path name) or 0
load()
will do. Then, returns a string, the path name to the
file if the named file exists; 0 unless otherwise.
load()
.
[0] which("gr"); ./gb/gr [1] which("/usr/local/lib/gr"); 0 [2] which("/usr/local/lib/asir/gr"); /usr/local/lib/asir/gr
load
.
[ << ] | [ < ] | [ Up ] | [ > ] | [ >> ] | [Top] | [Contents] | [Index] | [ ? ] |
output
:: Writes the return values and prompt onto file filename.
1
filename
output()
.
""
), or
when protected file is specified, an error occurs and the system returns
to the top level.
ctrl("echo",1)
, and then
redirect the standard output to your desired file.
vtype()
References)
are performed more efficiently, with respect to both time and space,
by bload()
and bsave()
.
[83] output("afo"); fctr(x^2-y^2); print("afo"); output(); 1 [87] quit; % cat afo 1 [84] [[1,1],[x+y,1],[x-y,1]] [85] afo 0 [86]
[ << ] | [ < ] | [ Up ] | [ > ] | [ >> ] | [Top] | [Contents] | [Index] | [ ? ] |
bsave
, bload
:: This function writes obj onto filename in binary form.
:: This function reads an expression from filename in binary form.
bsave()
: 1, bload()
: the expression read
arbitrary expression which does not contain neither function forms nor unknown coefficients.
filename
bsave()
writes an object onto a file in its internal
form (not exact internal form but very similar).
Function bload()
read the expression from files
which is written by bsave()
.
Current implementation support arbitrary expressions, including
lists, arrays (i.e., vectors and matrices), except for function forms
and unknown coefficients (vtype()
References.)
output()
, whereas internal forms are directly reconstructed
by bload()
from the bsave()
’ed object in the file.
The latter is much more efficient with respect to both time and space.
[0] A=(x+y+z+u+v+w)^20$ [1] bsave(A,"afo"); 1 [2] B = bload("afo")$ [3] A == B; 1 [4] X=(x+y)^2; x^2+2*y*x+y^2 [5] bsave(X,"afo")$ [6] quit; % asir [0] ord([y,x])$ [1] bload("afo"); y^2+2*x*y+x^2
[ << ] | [ < ] | [ Up ] | [ > ] | [ >> ] | [Top] | [Contents] | [Index] | [ ? ] |
bload27
:: Reads bsaved file created by older version of Asir.
expression read
filename
bload
.
bload27
is used to read such files.
[ << ] | [ < ] | [ Up ] | [ > ] | [ >> ] | [Top] | [Contents] | [Index] | [ ? ] |
print
:: Displays (or outputs) obj.
0
arbitrary
flag (arbitrary)
print(rat);
is performed at the top level,
first the value of 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., print(rat)$
,
The last 0 will not be printed. )
print()
command,
use list like [obj1,...]
, which is not so beautiful, but
convenient to minimize programming efforts.
[8] def cat(L) { while ( L != [] ) { print(car(L),0); L = cdr(L);} print(""); } [9] cat([xyz,123,"gahaha"])$ xyz123gahaha
[ << ] | [ < ] | [ Up ] | [ > ] | [ >> ] | [Top] | [Contents] | [Index] | [ ? ] |
access
:: testing an existence of file.
(1|0)
filename
[ << ] | [ < ] | [ Up ] | [ > ] | [ >> ] | [Top] | [Contents] | [Index] | [ ? ] |
remove_file
:: Delete an file file.
1
filename
[ << ] | [ < ] | [ Up ] | [ > ] | [ >> ] | [Top] | [Contents] | [Index] | [ ? ] |
open_file
, close_file
, get_line
, get_byte
, put_byte
, purge_stdin
:: Opens filename for reading.
:: Closes the file indicated by a descriptor num.
:: Reads a line from the file indicated by a descriptor num.
:: Reads a byte from the file indicated by a descriptor num.
:: Writes a byte c to the file indicated by a descriptor num.
:: Clears the buffer for the standard input.
open_file()
: integer (fild id); close_file()
: 1; get_line()
: string; get_byte()
, put_byte()
: integer
file (path) name
string
non-negative integer (file descriptor)
open_file()
opens a file.
If mode is not specified, a file is opened for reading.
If mode is specified, it is used as the mode specification for
C standard I/O function fopen()
. For example "w"
requests
that the file is truncated to zero length or created for writing.
"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 close_file()
.
If the special file name unix://stdin or unix://stdout or unix://stderr
is given, it returns the file descriptor for the standard input or
the standard output or the standard error stream respectively.
The mode argument is ignored in this case.
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.
get_byte()
reads a byte from an opened file and returns the
it as an integer.
put_byte()
writes a byte from an opened file and returns the
the byte as an integer.
get_line()
call after reading the end of file returns
an integer 0.
sub_str()
, eval_str()
.
purge_stdin()
clears the buffer for the standard input.
When a function receives a character string from 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.
[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]
[ << ] | [ < ] | [ Up ] | [ > ] | [ >> ] |
This document was generated on October 6, 2024 using texi2html 5.0.