Skip to content

Add File Input Output in ALGOL 60#6005

Open
rzuckerm wants to merge 2 commits into
TheRenegadeCoder:mainfrom
rzuckerm:algol-file-io
Open

Add File Input Output in ALGOL 60#6005
rzuckerm wants to merge 2 commits into
TheRenegadeCoder:mainfrom
rzuckerm:algol-file-io

Conversation

@rzuckerm
Copy link
Copy Markdown
Collaborator

Congrats on taking the first step to contributing to the Sample Programs repository maintained by The Renegade Coder!
For simplicity, please make sure that your pull request includes one and only one contribution.

Please fill one of the sections below as applicable.
Please also add any other relevant information to the Notes section at the bottom.
You may delete or just ignore any other sections.

Please fill in the checkbox like this:

[x]

Not like these:

[x ]
[ x]
[ x ]

Please put in the relevant issue number in the I fixed #your-issue-number-here item. For example, if your PR is
for an issue called Add Convex Hull in C++, and that issue number is 5164, change your-issue-number-here
to 5164. Do not put any space between # and the issue number. This is important because when the PR is merged,
the corresponding issue will be closed.

For more information please refer to our contributing documentation

I Am Adding a New Code Snippet in an Existing Language

Other Notes

This is a bit of a cheat since ALGOL 60 doesn't support file I/O. Instead it allows I/O via channel numbers. The GNU MARST ALGOL 60 to C translator has a special way to handle this using a FILE_<n> environment variable, which contains the filename for channel n. ALGOL 60 will crash with a fatal error if reading past End-Of-File (EOF). Therefore, an End-Of-Transmission (EOT) character (4) is used to signify EOF. According to my Google searches, using a sentinel value is a common way to handle this in ALGOL 60. Here's my approach:

  • Write to channel 3 one line at a time
  • Write EOT to channel 3
  • Read channel 3 one line at a time, and output each line to stdout. A line is read one character at a time into a buffer until newline, EOT, or buffer full

Where this differs from #5744 is that the reader has no prior knowledge of how many characters to read.

@github-actions github-actions Bot added enhancement Any code that improves the repo file input output See: https://sampleprograms.io/projects/file-input-output/ tests Testing related labels May 24, 2026
@rzuckerm rzuckerm marked this pull request as ready for review May 24, 2026 15:48
@rzuckerm rzuckerm enabled auto-merge (squash) May 24, 2026 15:48
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement Any code that improves the repo file input output See: https://sampleprograms.io/projects/file-input-output/ tests Testing related

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Add File Input Output in ALGOL 60

1 participant