[ << ] [ < ] [ Up ] [ > ] [ >> ]         [Top] [Contents] [Index] [ ? ]

6.11 Inputs and Outputs


[ << ] [ < ] [ Up ] [ > ] [ >> ]         [Top] [Contents] [Index] [ ? ]

6.11.1 end, quit

end, quit

:: Close the currently reading file. At the top level, terminate the Asir session.

[6] quit;
%
References

load.


[ << ] [ < ] [ Up ] [ > ] [ >> ]         [Top] [Contents] [Index] [ ? ]

6.11.2 load

load("filename")

:: Reads a program file filename.

return

(1|0)

filename

file (path) name

References

end, quit, which, get_rootdir.


[ << ] [ < ] [ Up ] [ > ] [ >> ]         [Top] [Contents] [Index] [ ? ]

6.11.3 which

which("filename")

:: This returns the path name for the filename which load() will read.

return

path name

filename

filename (path name) or 0

[0] which("gr");               
./gb/gr
[1] which("/usr/local/lib/gr");
0
[2] which("/usr/local/lib/asir/gr");
/usr/local/lib/asir/gr
References

load.


[ << ] [ < ] [ Up ] [ > ] [ >> ]         [Top] [Contents] [Index] [ ? ]

6.11.4 output

output(["filename"])

:: Writes the return values and prompt onto file filename.

return

1

filename

filename

[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]
References

ctrl, bsave, bload.


[ << ] [ < ] [ Up ] [ > ] [ >> ]         [Top] [Contents] [Index] [ ? ]

6.11.5 bsave, bload

bsave(obj,"filename")

:: This function writes obj onto filename in binary form.

bload("filename")

:: This function reads an expression from filename in binary form.

return

bsave() : 1, bload() : the expression read

obj

arbitrary expression which does not contain neither function forms nor unknown coefficients.

filename

filename

[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
References

output.


[ << ] [ < ] [ Up ] [ > ] [ >> ]         [Top] [Contents] [Index] [ ? ]

6.11.6 bload27

bload27("filename")

:: Reads bsaved file created by older version of Asir.

return

expression read

filename

filename

References

bsave, bload.


[ << ] [ < ] [ Up ] [ > ] [ >> ]         [Top] [Contents] [Index] [ ? ]

6.11.7 print

print(obj [,nl])

:: Displays (or outputs) obj.

return

0

obj

arbitrary

nl

flag (arbitrary)

[8] def cat(L) { while ( L != [] ) { print(car(L),0); L = cdr(L);}
print(""); }
[9] cat([xyz,123,"gahaha"])$
xyz123gahaha

[ << ] [ < ] [ Up ] [ > ] [ >> ]         [Top] [Contents] [Index] [ ? ]

6.11.8 access

access(file)

:: testing an existence of file.

return

(1|0)

file

filename


[ << ] [ < ] [ Up ] [ > ] [ >> ]         [Top] [Contents] [Index] [ ? ]

6.11.9 remove_file

remove_file(file)

:: Delete an file file.

return

1

file

filename


[ << ] [ < ] [ Up ] [ > ] [ >> ]         [Top] [Contents] [Index] [ ? ]

6.11.10 open_file, close_file, get_line, get_byte, put_byte, purge_stdin

open_file("filename"[,"mode"])

:: Opens filename for reading.

close_file(num)

:: Closes the file indicated by a descriptor num.

get_line([num])

:: Reads a line from the file indicated by a descriptor num.

get_byte(num)

:: Reads a byte from the file indicated by a descriptor num.

put_byte(num,c)

:: Writes a byte c to the file indicated by a descriptor num.

purge_stdin()

:: Clears the buffer for the standard input.

return

open_file() : integer (fild id); close_file() : 1; get_line() : string; get_byte(), put_byte() : integer

filename

file (path) name

mode

string

num

non-negative integer (file descriptor)

[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] 

References

eval_str, str_len, str_chr, sub_str.


[ << ] [ < ] [ Up ] [ > ] [ >> ]

This document was generated on April 26, 2024 using texi2html 5.0.