Data commit
This commit is contained in:
parent
7387c8f97b
commit
cb5bb5e222
199093 changed files with 3378972 additions and 0 deletions
46
Task/File-input-output/ALGOL-68/file-input-output.alg
Normal file
46
Task/File-input-output/ALGOL-68/file-input-output.alg
Normal file
|
|
@ -0,0 +1,46 @@
|
|||
PROC copy file v1 = (STRING in name, out name)VOID: (
|
||||
# note: algol68toc-1.18 - can compile, but not run v1 #
|
||||
INT errno;
|
||||
FILE in file, out file;
|
||||
errno := open(in file, in name, stand in channel);
|
||||
errno := open(out file, out name, stand out channel);
|
||||
|
||||
BOOL in ended := FALSE;
|
||||
PROC call back ended = (REF FILE f) BOOL: in ended := TRUE;
|
||||
on logical file end(in file, call back ended);
|
||||
|
||||
STRING line;
|
||||
WHILE
|
||||
get(in file, (line, new line));
|
||||
# WHILE # NOT in ended DO # break to avoid excess new line #
|
||||
put(out file, (line, new line))
|
||||
OD;
|
||||
ended:
|
||||
close(in file);
|
||||
close(out file)
|
||||
);
|
||||
|
||||
PROC copy file v2 = (STRING in name, out name)VOID: (
|
||||
INT errno;
|
||||
FILE in file, out file;
|
||||
errno := open(in file, in name, stand in channel);
|
||||
errno := open(out file, out name, stand out channel);
|
||||
|
||||
PROC call back ended = (REF FILE f) BOOL: GO TO done;
|
||||
on logical file end(in file, call back ended);
|
||||
|
||||
STRING line;
|
||||
DO
|
||||
get(in file, line);
|
||||
put(out file, line);
|
||||
get(in file, new line);
|
||||
put(out file, new line)
|
||||
OD;
|
||||
done:
|
||||
close(in file);
|
||||
close(out file)
|
||||
);
|
||||
|
||||
test:(
|
||||
copy file v2("input.txt","output.txt")
|
||||
)
|
||||
Loading…
Add table
Add a link
Reference in a new issue