import "io" let start() be { let infilename = "dir0.b", outfilename = "dir0copy.b", buffer = vec(129), r, r2; r := devctl(dc$tapeload, 1, infilename, 'R'); if r < 0 then { out("error %d from tapeload %s\n", r, infilename); finish } r := devctl(dc$tapeload, 2, outfilename, 'W'); if r < 0 then { out("error %d from tapeload %s\n", r, outfilename); finish } r := devctl(dc$tapecheck, 1); // this function is optional test r = 0 then out("tape 1 not available") else out("tape 1 open for %c\n", r); r := devctl(dc$tapelength, 1); // this function is optional and unrealistic if r < 0 then { out("error %d from tapelength\n", r); finish } out("tape in unit 1 %d bytes of data\n", r); while true do { r := devctl(dc$taperead, 1, buffer); // r will always be 512 except for errors and the last block if r < 0 then { out("error %d from taperead\n", r); finish } r2 := devctl(dc$tapewrite, 2, buffer, r); // last parameter must be 512 except for the last block if r2 < 0 then { out("error %d from tapewrite\n", r2); finish } byte r of buffer := '\0'; out("read and copied %d bytes:\n%s\n-----------------------------------------------------------------\n", r, buffer); if r <> 512 then break } r := devctl(dc$tapeunload, 1); if r < 0 then { out("error %d from tapeunload (1)\n", r); finish } r := devctl(dc$tapeunload, 2); if r < 0 then { out("error %d from tapeunload (2)\n", r); finish } }