Previous: , Up: READ OUT and WRITE IN   [Index]


7.7.3 CLC-INTERCAL I/O

INTERCAL-72 C-INTERCAL CLC-INTERCAL J-INTERCAL
no see text all versions no

There are also two CLC-INTERCAL-specific I/O mechanisms. These are Baudot-based text I/O (which is also implemented from C-INTERCAL version 0.27 onwards), and CLC-INTERCAL generalised binary I/O (not implemented in C-INTERCAL).

Baudot text-based I/O is specified by using a tail array as an argument to WRITE IN or READ OUT. (A tail array can also be used to specify C-INTERCAL-style Turing Tape I/O. In order to determine which is used: both C-INTERCAL and CLC-INTERCAL use their own sort of I/O unless a command-line argument instructs them to use the other.) In the case of WRITE IN, one line of input is requested from the user (C-INTERCAL requires this to be input in Latin-1, and will then automatically convert it; CLC-INTERCAL gives the option of various character sets for this input as command-line options); the final newline is removed from this line, then it is converted to extended Baudot and stored in the tail array specified (causing an error if the array is too small). Because Baudot is only a 5-bit character set, each element is padded to 16 bits; CLC-INTERCAL pads with zeros, C-INTERCAL pads with random bits. Trying to input at end-of-file will act as if the input were a blank line. READ OUT is the reverse; it interprets the array as extended Baudot and converts it to an appropriate character set (Latin-1 for C-INTERCAL, or whatever was specified on the command line for CLC-INTERCAL), which is output to the user, followed by a newline. Note that the Baudot is often longer than the corresponding character in other character sets due to the need to insert shift codes; for information on the extended Baudot character set, Character Sets.

Generalised binary I/O is specified using a hybrid array as an argument to WRITE IN or READ OUT. Input works by reading in a number of bytes equal to the length of the array (without trying to interpret them or translating them to a different character set), prepending a byte with 172 to the start, padding each byte to 16 bits with random data, then replacing each pair of consecutive bytes (that is, the first and second, the second and third, the third and fourth, and so on) with (the first element selected from the second element) mingled with (the complement of the first element selected from the complement of the second element). Output is the exact opposite of this process. End-of-file reads a 0, which is padded with 0s rather than random data; if a non-end-of-file 0 comes in from the data, its padding will contain at least one 1. Any all-bits-0-even-the-padding being read out will be skipped.


Previous: , Up: READ OUT and WRITE IN   [Index]