Home » Archimedes archive » Zipped Apps » BCPL » BCPL/armlib/b/StringIO
BCPL/armlib/b/StringIO
This website contains an archive of files for the Acorn Electron, BBC Micro, Acorn Archimedes, Commodore 16 and Commodore 64 computers, which Dominic Ford has rescued from his private collection of floppy disks and cassettes.
Some of these files were originally commercial releases in the 1980s and 1990s, but they are now widely available online. I assume that copyright over them is no longer being asserted. If you own the copyright and would like files to be removed, please contact me.
Tape/disk: | Home » Archimedes archive » Zipped Apps » BCPL |
Filename: | BCPL/armlib/b/StringIO |
Read OK: | ✔ |
File size: | 0F8C bytes |
Load address: | 0000 |
Exec address: | 0000 |
File contents
SECTION "StringStreams" GET "LibHdr" GET "b.IOHdr" MANIFEST { OSFileReadCatalogue = #x05; OSFileLoadFile = #xFF; OSFileSaveFile = #x00 }; LET BufferRdch(channel) = VALOF { LET buffer, bufferPointer, bufferCount = cis!s.buffer.address, cis!s.buffer.pointer, cis!s.buffer.count; LET c = ?; IF bufferPointer>=bufferCount THEN RESULTIS EndStreamCh; c := 0%(buffer+bufferPointer); cis!s.buffer.pointer := bufferPointer+1; RESULTIS c } AND BufferWrch(ch, channel) BE { LET bufferSize, buffer, bufferCount= cos!s.buffer.size, cos!s.buffer.address, cos!s.buffer.count; IF bufferCount>=bufferSize THEN { WriteF("Stream %x6 full: buffer %x6 size %n count %n*n", cos*4, buffer, bufferSize, bufferCount); Stop() }; 0%(buffer+bufferCount) := ch; cos!s.buffer.count := bufferCount+1 } LET MakeStringStream(direction, arg, size) = VALOF { LET StringWrCh(ch, channel) BE { BufferWrch(ch, channel); 0%(cos!s.buffer.address-1) := cos!s.buffer.count }; LET stream = MakeNewStream("string:", s.is.store.bits, direction, BufferRdch, StringWrch); stream!s.buffer.address := arg; stream!s.buffer.size := size; stream!s.buffer.pointer := 0; TEST direction=s.op.input THEN stream!s.buffer.count := size ELSE { stream!s.buffer.count := 0; 0%(arg-1) := 0 }; RESULTIS stream } AND FindStringInput(s, n) = MakeStringStream(s.op.input, s, n) AND StringF(format, a, b, c, d, e, f, g, h, i, j, k) = VALOF { LET o = Output(); LET buffer = GetVec(256/BytesPerWord); LET s, res = ?, ?; s := MakeStringStream(s.op.output, buffer*BytesPerWord+1, 255); SelectOutput(s); WriteF(format, a, b, c, d, e, f, g, h, i, j, k); EndWrite(); SelectOutput(o); res := GetVec((buffer%0)/4); CopyString(buffer, res); FreeVec(buffer); RESULTIS res } AND CopyString(source, dest) BE MoveWords(1, (source%0)/4+1, source, dest) AND FindFileInput(name) = VALOF { LET FileEndRead(stream) BE { FreeVec((stream!s.buffer.address)/BytesPerWord); EndStream(stream) } AND FileUnread() BE { LET bufferPointer = cis!s.buffer.pointer; IF bufferPointer>0 THEN cis!s.buffer.pointer := bufferPointer-1 }; LET parameterBlock = VEC 3; LET result = OSFile(OSFileReadCatalogue, name, parameterBlock); LET buffer, filelength = ?, ?; IF result~=1 THEN RESULTIS 0; fileLength := parameterBlock!2; buffer := GetVec(fileLength/BytesPerWord)*BytesPerWord; IF buffer=0 THEN RESULTIS FindInput(name); parameterBlock!0 := buffer; parameterBlock!1 := 0; parameterBlock!2 := 0; parameterBlock!3 := 0; result := OSFile(OSFileLoadFile, name, parameterBlock); IF result2~=0 THEN RESULTIS 0; result := MakeNewStream(name, s.is.store.bits, s.op.input, BufferRdch, BufferWrch); result!s.buffer.address := buffer; result!s.buffer.size := filelength; result!s.buffer.count := filelength; result!s.buffer.pointer := 0; result!s.unreader := FileUnread; result!s.endreader := FileEndRead; RESULTIS result } AND FindFileOutput(name, size) = VALOF { LET FileEndWrite(stream) BE { LET parameterBlock = VEC 3; parameterBlock!0 := 0; parameterBlock!1 := 0; parameterBlock!2 := stream!s.buffer.address; parameterBlock!3 := parameterBlock!0+stream!s.buffer.count; OSFile(OSFileSaveFile, @(stream!s.name), parameterBlock); FreeVec((stream!s.buffer.address)/BytesPerWord); EndStream(stream) }; LET buffer = GetVec(size)*BytesPerWord; LET result = ?; IF buffer=0 THEN RESULTIS FindOutput(name); result := MakeNewStream(name, s.is.store.bits, s.op.output, BufferRdch, BufferWrch); result!s.buffer.address := buffer; result!s.buffer.size := size; result!s.buffer.count := 0; result!s.buffer.pointer := 0; result!s.endwriter := FileEndWrite; RESULTIS result }
00000000 53 45 43 54 49 4f 4e 20 22 53 74 72 69 6e 67 53 |SECTION "StringS| 00000010 74 72 65 61 6d 73 22 0a 0a 47 45 54 20 22 4c 69 |treams"..GET "Li| 00000020 62 48 64 72 22 0a 0a 47 45 54 20 22 62 2e 49 4f |bHdr"..GET "b.IO| 00000030 48 64 72 22 0a 0a 4d 41 4e 49 46 45 53 54 20 7b |Hdr"..MANIFEST {| 00000040 0a 20 20 20 4f 53 46 69 6c 65 52 65 61 64 43 61 |. OSFileReadCa| 00000050 74 61 6c 6f 67 75 65 09 20 20 3d 20 23 78 30 35 |talogue. = #x05| 00000060 3b 0a 20 20 20 4f 53 46 69 6c 65 4c 6f 61 64 46 |;. OSFileLoadF| 00000070 69 6c 65 09 20 20 3d 20 23 78 46 46 3b 0a 20 20 |ile. = #xFF;. | 00000080 20 4f 53 46 69 6c 65 53 61 76 65 46 69 6c 65 09 | OSFileSaveFile.| 00000090 20 20 3d 20 23 78 30 30 20 7d 3b 0a 0a 4c 45 54 | = #x00 };..LET| 000000a0 20 42 75 66 66 65 72 52 64 63 68 28 63 68 61 6e | BufferRdch(chan| 000000b0 6e 65 6c 29 20 3d 20 56 41 4c 4f 46 0a 7b 20 20 |nel) = VALOF.{ | 000000c0 4c 45 54 20 62 75 66 66 65 72 2c 20 62 75 66 66 |LET buffer, buff| 000000d0 65 72 50 6f 69 6e 74 65 72 2c 20 62 75 66 66 65 |erPointer, buffe| 000000e0 72 43 6f 75 6e 74 20 3d 0a 20 20 20 20 20 20 63 |rCount =. c| 000000f0 69 73 21 73 2e 62 75 66 66 65 72 2e 61 64 64 72 |is!s.buffer.addr| 00000100 65 73 73 2c 20 63 69 73 21 73 2e 62 75 66 66 65 |ess, cis!s.buffe| 00000110 72 2e 70 6f 69 6e 74 65 72 2c 20 63 69 73 21 73 |r.pointer, cis!s| 00000120 2e 62 75 66 66 65 72 2e 63 6f 75 6e 74 3b 0a 20 |.buffer.count;. | 00000130 20 20 4c 45 54 20 63 20 3d 20 3f 3b 0a 20 20 20 | LET c = ?;. | 00000140 49 46 20 62 75 66 66 65 72 50 6f 69 6e 74 65 72 |IF bufferPointer| 00000150 3e 3d 62 75 66 66 65 72 43 6f 75 6e 74 20 54 48 |>=bufferCount TH| 00000160 45 4e 20 52 45 53 55 4c 54 49 53 20 45 6e 64 53 |EN RESULTIS EndS| 00000170 74 72 65 61 6d 43 68 3b 0a 20 20 20 63 20 3a 3d |treamCh;. c :=| 00000180 20 30 25 28 62 75 66 66 65 72 2b 62 75 66 66 65 | 0%(buffer+buffe| 00000190 72 50 6f 69 6e 74 65 72 29 3b 0a 20 20 20 63 69 |rPointer);. ci| 000001a0 73 21 73 2e 62 75 66 66 65 72 2e 70 6f 69 6e 74 |s!s.buffer.point| 000001b0 65 72 20 3a 3d 20 62 75 66 66 65 72 50 6f 69 6e |er := bufferPoin| 000001c0 74 65 72 2b 31 3b 0a 20 20 20 52 45 53 55 4c 54 |ter+1;. RESULT| 000001d0 49 53 20 63 20 7d 0a 0a 41 4e 44 20 42 75 66 66 |IS c }..AND Buff| 000001e0 65 72 57 72 63 68 28 63 68 2c 20 63 68 61 6e 6e |erWrch(ch, chann| 000001f0 65 6c 29 20 42 45 0a 7b 20 20 4c 45 54 20 62 75 |el) BE.{ LET bu| 00000200 66 66 65 72 53 69 7a 65 2c 20 62 75 66 66 65 72 |fferSize, buffer| 00000210 2c 20 62 75 66 66 65 72 43 6f 75 6e 74 3d 0a 20 |, bufferCount=. | 00000220 20 20 20 20 20 63 6f 73 21 73 2e 62 75 66 66 65 | cos!s.buffe| 00000230 72 2e 73 69 7a 65 2c 20 63 6f 73 21 73 2e 62 75 |r.size, cos!s.bu| 00000240 66 66 65 72 2e 61 64 64 72 65 73 73 2c 20 63 6f |ffer.address, co| 00000250 73 21 73 2e 62 75 66 66 65 72 2e 63 6f 75 6e 74 |s!s.buffer.count| 00000260 3b 0a 20 20 20 49 46 20 62 75 66 66 65 72 43 6f |;. IF bufferCo| 00000270 75 6e 74 3e 3d 62 75 66 66 65 72 53 69 7a 65 20 |unt>=bufferSize | 00000280 54 48 45 4e 20 7b 0a 20 20 20 20 20 20 57 72 69 |THEN {. Wri| 00000290 74 65 46 28 22 53 74 72 65 61 6d 20 25 78 36 20 |teF("Stream %x6 | 000002a0 66 75 6c 6c 3a 20 62 75 66 66 65 72 20 25 78 36 |full: buffer %x6| 000002b0 20 73 69 7a 65 20 25 6e 20 63 6f 75 6e 74 20 25 | size %n count %| 000002c0 6e 2a 6e 22 2c 0a 09 20 20 20 20 20 63 6f 73 2a |n*n",.. cos*| 000002d0 34 2c 20 62 75 66 66 65 72 2c 20 62 75 66 66 65 |4, buffer, buffe| 000002e0 72 53 69 7a 65 2c 20 62 75 66 66 65 72 43 6f 75 |rSize, bufferCou| 000002f0 6e 74 29 3b 0a 20 20 20 20 20 20 53 74 6f 70 28 |nt);. Stop(| 00000300 29 20 7d 3b 0a 20 20 20 30 25 28 62 75 66 66 65 |) };. 0%(buffe| 00000310 72 2b 62 75 66 66 65 72 43 6f 75 6e 74 29 20 3a |r+bufferCount) :| 00000320 3d 20 63 68 3b 0a 20 20 20 63 6f 73 21 73 2e 62 |= ch;. cos!s.b| 00000330 75 66 66 65 72 2e 63 6f 75 6e 74 20 3a 3d 20 62 |uffer.count := b| 00000340 75 66 66 65 72 43 6f 75 6e 74 2b 31 20 7d 0a 0a |ufferCount+1 }..| 00000350 4c 45 54 20 4d 61 6b 65 53 74 72 69 6e 67 53 74 |LET MakeStringSt| 00000360 72 65 61 6d 28 64 69 72 65 63 74 69 6f 6e 2c 20 |ream(direction, | 00000370 61 72 67 2c 20 73 69 7a 65 29 20 3d 20 56 41 4c |arg, size) = VAL| 00000380 4f 46 0a 7b 20 20 4c 45 54 20 53 74 72 69 6e 67 |OF.{ LET String| 00000390 57 72 43 68 28 63 68 2c 20 63 68 61 6e 6e 65 6c |WrCh(ch, channel| 000003a0 29 20 42 45 0a 20 20 20 7b 20 20 42 75 66 66 65 |) BE. { Buffe| 000003b0 72 57 72 63 68 28 63 68 2c 20 63 68 61 6e 6e 65 |rWrch(ch, channe| 000003c0 6c 29 3b 0a 20 20 20 20 20 20 30 25 28 63 6f 73 |l);. 0%(cos| 000003d0 21 73 2e 62 75 66 66 65 72 2e 61 64 64 72 65 73 |!s.buffer.addres| 000003e0 73 2d 31 29 20 3a 3d 20 63 6f 73 21 73 2e 62 75 |s-1) := cos!s.bu| 000003f0 66 66 65 72 2e 63 6f 75 6e 74 20 7d 3b 0a 20 20 |ffer.count };. | 00000400 20 4c 45 54 20 73 74 72 65 61 6d 20 3d 20 4d 61 | LET stream = Ma| 00000410 6b 65 4e 65 77 53 74 72 65 61 6d 28 22 73 74 72 |keNewStream("str| 00000420 69 6e 67 3a 22 2c 0a 09 09 09 20 20 20 20 20 20 |ing:",.... | 00000430 73 2e 69 73 2e 73 74 6f 72 65 2e 62 69 74 73 2c |s.is.store.bits,| 00000440 0a 09 09 09 20 20 20 20 20 20 64 69 72 65 63 74 |.... direct| 00000450 69 6f 6e 2c 0a 09 09 09 20 20 20 20 20 20 42 75 |ion,.... Bu| 00000460 66 66 65 72 52 64 63 68 2c 0a 09 09 09 20 20 20 |fferRdch,.... | 00000470 20 20 20 53 74 72 69 6e 67 57 72 63 68 29 3b 0a | StringWrch);.| 00000480 20 20 20 73 74 72 65 61 6d 21 73 2e 62 75 66 66 | stream!s.buff| 00000490 65 72 2e 61 64 64 72 65 73 73 20 3a 3d 20 61 72 |er.address := ar| 000004a0 67 3b 0a 20 20 20 73 74 72 65 61 6d 21 73 2e 62 |g;. stream!s.b| 000004b0 75 66 66 65 72 2e 73 69 7a 65 20 3a 3d 20 73 69 |uffer.size := si| 000004c0 7a 65 3b 0a 20 20 20 73 74 72 65 61 6d 21 73 2e |ze;. stream!s.| 000004d0 62 75 66 66 65 72 2e 70 6f 69 6e 74 65 72 20 3a |buffer.pointer :| 000004e0 3d 20 30 3b 0a 20 20 20 54 45 53 54 20 64 69 72 |= 0;. TEST dir| 000004f0 65 63 74 69 6f 6e 3d 73 2e 6f 70 2e 69 6e 70 75 |ection=s.op.inpu| 00000500 74 20 54 48 45 4e 0a 20 20 20 20 20 20 73 74 72 |t THEN. str| 00000510 65 61 6d 21 73 2e 62 75 66 66 65 72 2e 63 6f 75 |eam!s.buffer.cou| 00000520 6e 74 20 3a 3d 20 73 69 7a 65 0a 20 20 20 45 4c |nt := size. EL| 00000530 53 45 20 7b 0a 20 20 20 20 20 20 73 74 72 65 61 |SE {. strea| 00000540 6d 21 73 2e 62 75 66 66 65 72 2e 63 6f 75 6e 74 |m!s.buffer.count| 00000550 20 3a 3d 20 30 3b 0a 20 20 20 20 20 20 30 25 28 | := 0;. 0%(| 00000560 61 72 67 2d 31 29 20 3a 3d 20 30 20 7d 3b 0a 20 |arg-1) := 0 };. | 00000570 20 20 52 45 53 55 4c 54 49 53 20 73 74 72 65 61 | RESULTIS strea| 00000580 6d 20 7d 0a 0a 41 4e 44 20 46 69 6e 64 53 74 72 |m }..AND FindStr| 00000590 69 6e 67 49 6e 70 75 74 28 73 2c 20 6e 29 20 3d |ingInput(s, n) =| 000005a0 0a 20 20 20 4d 61 6b 65 53 74 72 69 6e 67 53 74 |. MakeStringSt| 000005b0 72 65 61 6d 28 73 2e 6f 70 2e 69 6e 70 75 74 2c |ream(s.op.input,| 000005c0 20 73 2c 20 6e 29 0a 0a 41 4e 44 20 53 74 72 69 | s, n)..AND Stri| 000005d0 6e 67 46 28 66 6f 72 6d 61 74 2c 20 61 2c 20 62 |ngF(format, a, b| 000005e0 2c 20 63 2c 20 64 2c 20 65 2c 20 66 2c 20 67 2c |, c, d, e, f, g,| 000005f0 20 68 2c 20 69 2c 20 6a 2c 20 6b 29 20 3d 20 56 | h, i, j, k) = V| 00000600 41 4c 4f 46 0a 7b 20 20 4c 45 54 20 6f 20 3d 20 |ALOF.{ LET o = | 00000610 4f 75 74 70 75 74 28 29 3b 0a 20 20 20 4c 45 54 |Output();. LET| 00000620 20 62 75 66 66 65 72 20 3d 20 47 65 74 56 65 63 | buffer = GetVec| 00000630 28 32 35 36 2f 42 79 74 65 73 50 65 72 57 6f 72 |(256/BytesPerWor| 00000640 64 29 3b 0a 20 20 20 4c 45 54 20 73 2c 20 72 65 |d);. LET s, re| 00000650 73 20 3d 20 3f 2c 20 3f 3b 0a 20 20 20 73 20 3a |s = ?, ?;. s :| 00000660 3d 20 4d 61 6b 65 53 74 72 69 6e 67 53 74 72 65 |= MakeStringStre| 00000670 61 6d 28 73 2e 6f 70 2e 6f 75 74 70 75 74 2c 20 |am(s.op.output, | 00000680 62 75 66 66 65 72 2a 42 79 74 65 73 50 65 72 57 |buffer*BytesPerW| 00000690 6f 72 64 2b 31 2c 20 32 35 35 29 3b 0a 20 20 20 |ord+1, 255);. | 000006a0 53 65 6c 65 63 74 4f 75 74 70 75 74 28 73 29 3b |SelectOutput(s);| 000006b0 0a 20 20 20 57 72 69 74 65 46 28 66 6f 72 6d 61 |. WriteF(forma| 000006c0 74 2c 20 61 2c 20 62 2c 20 63 2c 20 64 2c 20 65 |t, a, b, c, d, e| 000006d0 2c 20 66 2c 20 67 2c 20 68 2c 20 69 2c 20 6a 2c |, f, g, h, i, j,| 000006e0 20 6b 29 3b 0a 20 20 20 45 6e 64 57 72 69 74 65 | k);. EndWrite| 000006f0 28 29 3b 0a 20 20 20 53 65 6c 65 63 74 4f 75 74 |();. SelectOut| 00000700 70 75 74 28 6f 29 3b 0a 20 20 20 72 65 73 20 3a |put(o);. res :| 00000710 3d 20 47 65 74 56 65 63 28 28 62 75 66 66 65 72 |= GetVec((buffer| 00000720 25 30 29 2f 34 29 3b 0a 20 20 20 43 6f 70 79 53 |%0)/4);. CopyS| 00000730 74 72 69 6e 67 28 62 75 66 66 65 72 2c 20 72 65 |tring(buffer, re| 00000740 73 29 3b 0a 20 20 20 46 72 65 65 56 65 63 28 62 |s);. FreeVec(b| 00000750 75 66 66 65 72 29 3b 0a 20 20 20 52 45 53 55 4c |uffer);. RESUL| 00000760 54 49 53 20 72 65 73 20 7d 0a 0a 41 4e 44 20 43 |TIS res }..AND C| 00000770 6f 70 79 53 74 72 69 6e 67 28 73 6f 75 72 63 65 |opyString(source| 00000780 2c 20 64 65 73 74 29 20 42 45 0a 20 20 20 4d 6f |, dest) BE. Mo| 00000790 76 65 57 6f 72 64 73 28 31 2c 20 28 73 6f 75 72 |veWords(1, (sour| 000007a0 63 65 25 30 29 2f 34 2b 31 2c 20 73 6f 75 72 63 |ce%0)/4+1, sourc| 000007b0 65 2c 20 64 65 73 74 29 0a 0a 41 4e 44 20 46 69 |e, dest)..AND Fi| 000007c0 6e 64 46 69 6c 65 49 6e 70 75 74 28 6e 61 6d 65 |ndFileInput(name| 000007d0 29 20 3d 20 56 41 4c 4f 46 0a 7b 20 20 4c 45 54 |) = VALOF.{ LET| 000007e0 20 46 69 6c 65 45 6e 64 52 65 61 64 28 73 74 72 | FileEndRead(str| 000007f0 65 61 6d 29 20 42 45 0a 20 20 20 7b 20 20 46 72 |eam) BE. { Fr| 00000800 65 65 56 65 63 28 28 73 74 72 65 61 6d 21 73 2e |eeVec((stream!s.| 00000810 62 75 66 66 65 72 2e 61 64 64 72 65 73 73 29 2f |buffer.address)/| 00000820 42 79 74 65 73 50 65 72 57 6f 72 64 29 3b 0a 20 |BytesPerWord);. | 00000830 20 20 20 20 20 45 6e 64 53 74 72 65 61 6d 28 73 | EndStream(s| 00000840 74 72 65 61 6d 29 20 7d 0a 20 20 20 41 4e 44 20 |tream) }. AND | 00000850 46 69 6c 65 55 6e 72 65 61 64 28 29 20 42 45 0a |FileUnread() BE.| 00000860 20 20 20 7b 20 20 4c 45 54 20 62 75 66 66 65 72 | { LET buffer| 00000870 50 6f 69 6e 74 65 72 20 3d 20 63 69 73 21 73 2e |Pointer = cis!s.| 00000880 62 75 66 66 65 72 2e 70 6f 69 6e 74 65 72 3b 0a |buffer.pointer;.| 00000890 20 20 20 20 20 20 49 46 20 62 75 66 66 65 72 50 | IF bufferP| 000008a0 6f 69 6e 74 65 72 3e 30 20 54 48 45 4e 0a 09 20 |ointer>0 THEN.. | 000008b0 63 69 73 21 73 2e 62 75 66 66 65 72 2e 70 6f 69 |cis!s.buffer.poi| 000008c0 6e 74 65 72 20 3a 3d 20 62 75 66 66 65 72 50 6f |nter := bufferPo| 000008d0 69 6e 74 65 72 2d 31 20 7d 3b 0a 0a 20 20 20 4c |inter-1 };.. L| 000008e0 45 54 20 70 61 72 61 6d 65 74 65 72 42 6c 6f 63 |ET parameterBloc| 000008f0 6b 20 3d 20 56 45 43 20 33 3b 0a 20 20 20 4c 45 |k = VEC 3;. LE| 00000900 54 20 72 65 73 75 6c 74 20 3d 20 4f 53 46 69 6c |T result = OSFil| 00000910 65 28 4f 53 46 69 6c 65 52 65 61 64 43 61 74 61 |e(OSFileReadCata| 00000920 6c 6f 67 75 65 2c 20 6e 61 6d 65 2c 20 70 61 72 |logue, name, par| 00000930 61 6d 65 74 65 72 42 6c 6f 63 6b 29 3b 0a 20 20 |ameterBlock);. | 00000940 20 4c 45 54 20 62 75 66 66 65 72 2c 20 66 69 6c | LET buffer, fil| 00000950 65 6c 65 6e 67 74 68 20 3d 20 3f 2c 20 3f 3b 0a |elength = ?, ?;.| 00000960 0a 20 20 20 49 46 20 72 65 73 75 6c 74 7e 3d 31 |. IF result~=1| 00000970 20 54 48 45 4e 20 52 45 53 55 4c 54 49 53 20 30 | THEN RESULTIS 0| 00000980 3b 0a 20 20 20 66 69 6c 65 4c 65 6e 67 74 68 20 |;. fileLength | 00000990 3a 3d 20 70 61 72 61 6d 65 74 65 72 42 6c 6f 63 |:= parameterBloc| 000009a0 6b 21 32 3b 0a 20 20 20 62 75 66 66 65 72 20 3a |k!2;. buffer :| 000009b0 3d 20 47 65 74 56 65 63 28 66 69 6c 65 4c 65 6e |= GetVec(fileLen| 000009c0 67 74 68 2f 42 79 74 65 73 50 65 72 57 6f 72 64 |gth/BytesPerWord| 000009d0 29 2a 42 79 74 65 73 50 65 72 57 6f 72 64 3b 0a |)*BytesPerWord;.| 000009e0 20 20 20 49 46 20 62 75 66 66 65 72 3d 30 20 54 | IF buffer=0 T| 000009f0 48 45 4e 20 52 45 53 55 4c 54 49 53 20 46 69 6e |HEN RESULTIS Fin| 00000a00 64 49 6e 70 75 74 28 6e 61 6d 65 29 3b 0a 0a 20 |dInput(name);.. | 00000a10 20 20 70 61 72 61 6d 65 74 65 72 42 6c 6f 63 6b | parameterBlock| 00000a20 21 30 20 3a 3d 20 62 75 66 66 65 72 3b 0a 20 20 |!0 := buffer;. | 00000a30 20 70 61 72 61 6d 65 74 65 72 42 6c 6f 63 6b 21 | parameterBlock!| 00000a40 31 20 3a 3d 20 30 3b 0a 20 20 20 70 61 72 61 6d |1 := 0;. param| 00000a50 65 74 65 72 42 6c 6f 63 6b 21 32 20 3a 3d 20 30 |eterBlock!2 := 0| 00000a60 3b 0a 20 20 20 70 61 72 61 6d 65 74 65 72 42 6c |;. parameterBl| 00000a70 6f 63 6b 21 33 20 3a 3d 20 30 3b 0a 20 20 20 72 |ock!3 := 0;. r| 00000a80 65 73 75 6c 74 20 3a 3d 20 4f 53 46 69 6c 65 28 |esult := OSFile(| 00000a90 4f 53 46 69 6c 65 4c 6f 61 64 46 69 6c 65 2c 20 |OSFileLoadFile, | 00000aa0 6e 61 6d 65 2c 20 70 61 72 61 6d 65 74 65 72 42 |name, parameterB| 00000ab0 6c 6f 63 6b 29 3b 0a 20 20 20 49 46 20 72 65 73 |lock);. IF res| 00000ac0 75 6c 74 32 7e 3d 30 20 54 48 45 4e 20 52 45 53 |ult2~=0 THEN RES| 00000ad0 55 4c 54 49 53 20 30 3b 0a 0a 20 20 20 72 65 73 |ULTIS 0;.. res| 00000ae0 75 6c 74 20 3a 3d 20 4d 61 6b 65 4e 65 77 53 74 |ult := MakeNewSt| 00000af0 72 65 61 6d 28 6e 61 6d 65 2c 0a 09 09 09 20 20 |ream(name,.... | 00000b00 20 73 2e 69 73 2e 73 74 6f 72 65 2e 62 69 74 73 | s.is.store.bits| 00000b10 2c 0a 09 09 09 20 20 20 73 2e 6f 70 2e 69 6e 70 |,.... s.op.inp| 00000b20 75 74 2c 0a 09 09 09 20 20 20 42 75 66 66 65 72 |ut,.... Buffer| 00000b30 52 64 63 68 2c 0a 09 09 09 20 20 20 42 75 66 66 |Rdch,.... Buff| 00000b40 65 72 57 72 63 68 29 3b 0a 0a 20 20 20 72 65 73 |erWrch);.. res| 00000b50 75 6c 74 21 73 2e 62 75 66 66 65 72 2e 61 64 64 |ult!s.buffer.add| 00000b60 72 65 73 73 20 3a 3d 20 62 75 66 66 65 72 3b 0a |ress := buffer;.| 00000b70 20 20 20 72 65 73 75 6c 74 21 73 2e 62 75 66 66 | result!s.buff| 00000b80 65 72 2e 73 69 7a 65 20 3a 3d 20 66 69 6c 65 6c |er.size := filel| 00000b90 65 6e 67 74 68 3b 0a 20 20 20 72 65 73 75 6c 74 |ength;. result| 00000ba0 21 73 2e 62 75 66 66 65 72 2e 63 6f 75 6e 74 20 |!s.buffer.count | 00000bb0 3a 3d 20 66 69 6c 65 6c 65 6e 67 74 68 3b 0a 20 |:= filelength;. | 00000bc0 20 20 72 65 73 75 6c 74 21 73 2e 62 75 66 66 65 | result!s.buffe| 00000bd0 72 2e 70 6f 69 6e 74 65 72 20 3a 3d 20 30 3b 0a |r.pointer := 0;.| 00000be0 20 20 20 72 65 73 75 6c 74 21 73 2e 75 6e 72 65 | result!s.unre| 00000bf0 61 64 65 72 20 3a 3d 20 46 69 6c 65 55 6e 72 65 |ader := FileUnre| 00000c00 61 64 3b 0a 20 20 20 72 65 73 75 6c 74 21 73 2e |ad;. result!s.| 00000c10 65 6e 64 72 65 61 64 65 72 20 3a 3d 20 46 69 6c |endreader := Fil| 00000c20 65 45 6e 64 52 65 61 64 3b 0a 20 20 20 52 45 53 |eEndRead;. RES| 00000c30 55 4c 54 49 53 20 72 65 73 75 6c 74 20 7d 0a 0a |ULTIS result }..| 00000c40 41 4e 44 20 46 69 6e 64 46 69 6c 65 4f 75 74 70 |AND FindFileOutp| 00000c50 75 74 28 6e 61 6d 65 2c 20 73 69 7a 65 29 20 3d |ut(name, size) =| 00000c60 20 56 41 4c 4f 46 0a 7b 20 20 4c 45 54 20 46 69 | VALOF.{ LET Fi| 00000c70 6c 65 45 6e 64 57 72 69 74 65 28 73 74 72 65 61 |leEndWrite(strea| 00000c80 6d 29 20 42 45 0a 20 20 20 7b 20 20 4c 45 54 20 |m) BE. { LET | 00000c90 70 61 72 61 6d 65 74 65 72 42 6c 6f 63 6b 20 3d |parameterBlock =| 00000ca0 20 56 45 43 20 33 3b 0a 20 20 20 20 20 20 70 61 | VEC 3;. pa| 00000cb0 72 61 6d 65 74 65 72 42 6c 6f 63 6b 21 30 20 3a |rameterBlock!0 :| 00000cc0 3d 20 30 3b 0a 20 20 20 20 20 20 70 61 72 61 6d |= 0;. param| 00000cd0 65 74 65 72 42 6c 6f 63 6b 21 31 20 3a 3d 20 30 |eterBlock!1 := 0| 00000ce0 3b 0a 20 20 20 20 20 20 70 61 72 61 6d 65 74 65 |;. paramete| 00000cf0 72 42 6c 6f 63 6b 21 32 20 3a 3d 20 73 74 72 65 |rBlock!2 := stre| 00000d00 61 6d 21 73 2e 62 75 66 66 65 72 2e 61 64 64 72 |am!s.buffer.addr| 00000d10 65 73 73 3b 0a 20 20 20 20 20 20 70 61 72 61 6d |ess;. param| 00000d20 65 74 65 72 42 6c 6f 63 6b 21 33 20 3a 3d 20 70 |eterBlock!3 := p| 00000d30 61 72 61 6d 65 74 65 72 42 6c 6f 63 6b 21 30 2b |arameterBlock!0+| 00000d40 73 74 72 65 61 6d 21 73 2e 62 75 66 66 65 72 2e |stream!s.buffer.| 00000d50 63 6f 75 6e 74 3b 0a 20 20 20 20 20 20 4f 53 46 |count;. OSF| 00000d60 69 6c 65 28 4f 53 46 69 6c 65 53 61 76 65 46 69 |ile(OSFileSaveFi| 00000d70 6c 65 2c 20 40 28 73 74 72 65 61 6d 21 73 2e 6e |le, @(stream!s.n| 00000d80 61 6d 65 29 2c 20 70 61 72 61 6d 65 74 65 72 42 |ame), parameterB| 00000d90 6c 6f 63 6b 29 3b 0a 20 20 20 20 20 20 46 72 65 |lock);. Fre| 00000da0 65 56 65 63 28 28 73 74 72 65 61 6d 21 73 2e 62 |eVec((stream!s.b| 00000db0 75 66 66 65 72 2e 61 64 64 72 65 73 73 29 2f 42 |uffer.address)/B| 00000dc0 79 74 65 73 50 65 72 57 6f 72 64 29 3b 0a 20 20 |ytesPerWord);. | 00000dd0 20 20 20 20 45 6e 64 53 74 72 65 61 6d 28 73 74 | EndStream(st| 00000de0 72 65 61 6d 29 20 7d 3b 0a 20 20 20 4c 45 54 20 |ream) };. LET | 00000df0 62 75 66 66 65 72 20 3d 20 47 65 74 56 65 63 28 |buffer = GetVec(| 00000e00 73 69 7a 65 29 2a 42 79 74 65 73 50 65 72 57 6f |size)*BytesPerWo| 00000e10 72 64 3b 0a 20 20 20 4c 45 54 20 72 65 73 75 6c |rd;. LET resul| 00000e20 74 20 3d 20 3f 3b 0a 0a 20 20 20 49 46 20 62 75 |t = ?;.. IF bu| 00000e30 66 66 65 72 3d 30 20 54 48 45 4e 20 52 45 53 55 |ffer=0 THEN RESU| 00000e40 4c 54 49 53 20 46 69 6e 64 4f 75 74 70 75 74 28 |LTIS FindOutput(| 00000e50 6e 61 6d 65 29 3b 0a 0a 20 20 20 72 65 73 75 6c |name);.. resul| 00000e60 74 20 3a 3d 20 4d 61 6b 65 4e 65 77 53 74 72 65 |t := MakeNewStre| 00000e70 61 6d 28 6e 61 6d 65 2c 0a 09 09 09 20 20 20 73 |am(name,.... s| 00000e80 2e 69 73 2e 73 74 6f 72 65 2e 62 69 74 73 2c 0a |.is.store.bits,.| 00000e90 09 09 09 20 20 20 73 2e 6f 70 2e 6f 75 74 70 75 |... s.op.outpu| 00000ea0 74 2c 0a 09 09 09 20 20 20 42 75 66 66 65 72 52 |t,.... BufferR| 00000eb0 64 63 68 2c 0a 09 09 09 20 20 20 42 75 66 66 65 |dch,.... Buffe| 00000ec0 72 57 72 63 68 29 3b 0a 0a 20 20 20 72 65 73 75 |rWrch);.. resu| 00000ed0 6c 74 21 73 2e 62 75 66 66 65 72 2e 61 64 64 72 |lt!s.buffer.addr| 00000ee0 65 73 73 20 3a 3d 20 62 75 66 66 65 72 3b 0a 20 |ess := buffer;. | 00000ef0 20 20 72 65 73 75 6c 74 21 73 2e 62 75 66 66 65 | result!s.buffe| 00000f00 72 2e 73 69 7a 65 20 3a 3d 20 73 69 7a 65 3b 0a |r.size := size;.| 00000f10 20 20 20 72 65 73 75 6c 74 21 73 2e 62 75 66 66 | result!s.buff| 00000f20 65 72 2e 63 6f 75 6e 74 20 3a 3d 20 30 3b 0a 20 |er.count := 0;. | 00000f30 20 20 72 65 73 75 6c 74 21 73 2e 62 75 66 66 65 | result!s.buffe| 00000f40 72 2e 70 6f 69 6e 74 65 72 20 3a 3d 20 30 3b 0a |r.pointer := 0;.| 00000f50 20 20 20 72 65 73 75 6c 74 21 73 2e 65 6e 64 77 | result!s.endw| 00000f60 72 69 74 65 72 20 3a 3d 20 46 69 6c 65 45 6e 64 |riter := FileEnd| 00000f70 57 72 69 74 65 3b 0a 20 20 20 52 45 53 55 4c 54 |Write;. RESULT| 00000f80 49 53 20 72 65 73 75 6c 74 20 7d 0a |IS result }.| 00000f8c