Hello, I am just starting to learn Forth. I appreciate the efforts put to produce and maintain this nice package.
I wanted to write a simple program that reads input from stdin, and writes it out to stdout doing a little translation. At first I thought I could make use of key and key?, but I see the documentation indicates this can't be used on stdin. So, I tried read-line. This works mostly. I can read characters one at a time, and the main program's begin ... while loop will terminate at EOF. But, as one would expect by something called read-line, it consumes returns on its own. I'd like to receive those. Then I tried a combination of read-file and read-line with: chr 0 stdin read-line hoping to get the flag to know whether the end of the input has been reached (which read-file doesn't provide), but this doesn't work either, and the program hangs indefinitely. In case it matters, I'm actually running this on a phone running Lineage OS (ostensibly Android) under termux. I don't think it effects the behavior. I did find something on rosettacode: https://rosettacode.org/wiki/Copy_stdin_to_stdout#Forth So I am currently using slurp-fid to dump all of stdin into memory, and then reading a character out and updating the address pointer as I go. But I was wondering if it is possible to do this from just reading characters directly from the file descriptor. Is there some other check for EOF I missed in the documentation? Thanks for reading.
signature.asc
Description: OpenPGP digital signature
