Go to the first, previous, next, last section, table of contents.


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)
:: Writes a byte to the file indicated by a descriptor num.
purge_stdin()
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
section eval_str, section str_len, str_chr, sub_str.


Go to the first, previous, next, last section, table of contents.