Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
63 changes: 63 additions & 0 deletions archive/a/algol60/file-input-output.alg
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
begin
integer ch;
integer array buf[1:21];
integer i, len;


procedure writeFile;
begin
outstring(2, "Hello from ALGOL 60!");
end;

procedure outAsciiChar(ch);
value ch;
integer ch;
begin
outchar(
1,
"\x01\x02\x03\x04\x05\x06\x07\x08\t\n\x0b\x0c\r\x0e\x0f"
"\x10\x11\x12\x13\x14\x15\x16\x17\x18\x19\x1a\x1b\x1c\x1d\x1e\x1f"
" !\"#$\x25&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNO"
"PQRSTUVWXYZ[\\]^_`abcdefghijklmnopqrstuvwxyz{|}~\x7f'",
ch
)
end;

procedure printFile;
begin
integer i;
for i := 1 step 1 until len do outAsciiChar(buf[i])
end;

procedure readFile;
begin
len := 0;

for i := 1 step 1 until 20 do
begin
inchar(
2,
"\x01\x02\x03\x04\x05\x06\x07\x08\t\n\x0b\x0c\r\x0e\x0f"
"\x10\x11\x12\x13\x14\x15\x16\x17\x18\x19\x1a\x1b\x1c\x1d\x1e\x1f"
" !\"#$\x25&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNO"
"PQRSTUVWXYZ[\\]^_`abcdefghijklmnopqrstuvwxyz{|}~\x7f'",
ch
);
comment map invalid chars to 0;
if ch >= 129 then ch := 0;

comment stop only on invalid;
if ch = 0 then goto done;

len := len + 1;
buf[len] := ch;
end;

done:
end;

writeFile;
readFile;
printFile;

end
3 changes: 2 additions & 1 deletion archive/a/algol60/testinfo.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,12 @@ container:
sh -c 'marst -l 255 -o {{ source.name }}.c {{ source.name }}{{ source.extension }} && \
gcc -o {{ source.name }} {{ source.name }}.c -lm -lalgol && \
(echo "#!/bin/sh"; \
echo "(printf \"%d\n\" \"\$#\"; printf \"%s\0\" \"\$@\") | ./{{ source.name }}" \
echo "(printf \"%d\n\" \"\$#\"; printf \"%s\0\" \"\$@\") | FILE_2=output.txt ./{{ source.name }}" \
) >{{ source.name }}.sh'
cmd: "sh {{ source.name }}.sh"

notes:
- "Since ALGOL 60 does not support command-line arguments directly, the command line arguments are delivered like this:"
- "- Number of arguments followed by newline (ASCII 10). Use 'ininteger' to read this"
- "- Each argument is separated by a null byte (ASCII 0)"
- "Channel 2 is mapped to the file 'output.txt'"
Loading