Previous Up Next
When doing i/o it is necessary to specify a physical device, a mode (input vs. output, character vs. word), and possibly a file name to select among "files" on a particular physical device.
Each job can has sixteen i/o channels available, each of which can be opened individually to do i/o. The same OPEN system call used to open a tty channel is also used to open i/o channels for other devices. OPEN also specifies the mode and filenames.
You have already seen the use of modes .UAI (unit ascii input) and .UAO (unit ascii output). Modes .UII and .UIO are "image" i/o instead of ascii i/o. They transfer whole words instead of characters, and are used for binary files.
There are two filenames, and also a directory name. These are specified as words of SIXBIT just like the device name.
Once the channel is open, the .IOT UUO is used to transfer the characters in or out, just as it is with the terminal. In fact, the above examples could be adapted to read and write input using disk files only by changing the two OPEN system calls. Alternatively, filename translations could be used to translate device TTY: to a disk file.
Writing output to a file does require one thing that writing output to the terminal does not need: you must "close" the channel when you are finished to make the file appear properly on disk. Closing a terminal i/o channel is also allowed but nobody bothers since it is not necessary. Closing is done with the .CLOSE UUO, which takes the channel number in its AC field just like .IOT.
Here is an example which copies the file SYS;SYSTEM MAIL (the announcements printed when DDT or PWORD starts up) to the file FOO BAR on your own directory.
TITLE FILE COPY A=1 CHDSKI==1 CHDSKO==2 FCOPY: .CALL [ SETZ ? SIXBIT/OPEN/ [.UAI,,CHDSKI] ? [SIXBIT/DSK/] ;Mode, channel and device name [SIXBIT /SYSTEM/] ? [SIXBIT/MAIL/] ;Two filenames. 400000,,[SIXBIT /SYS/]] ;Directory name. .LOSE %LSFIL .CALL [ SETZ ? SIXBIT/OPEN/ [.UAO,,CHDSKO] ? [SIXBIT/DSK/] [SIXBIT /FOO/] ? 400000,,[SIXBIT/BAR/]] ;Note no directory name ! ;The default (your working directory) is used. .LOSE %LSFIL LOOP: .IOT CHDSKI,A ;Read next input character. JUMPL A,EOF ;Negative => there is none, it's eof. .IOT CHDSKO,A ;Else write char to output file. JRST LOOP EOF: .CLOSE CHDSKO, ;Make output file appear. .CLOSE CHDSKI, ;Release input file (to be clean). .LOGOUT 1, END FCOPY