-- TestIODefs.mesa DIRECTORY IODefs USING [CR, WriteLine, WriteString, WriteChar, WriteDecimal, ReadDecimal, GetOutputStream, SetOutputStream, GetInputStream, SetInputStream, ReadChar, ReadID], StreamDefs USING [StreamHandle, NewByteStream, Read, Write, Append]; TestIODefs: PROGRAM IMPORTS IODefs, StreamDefs = BEGIN OPEN IODefs, StreamDefs; n: INTEGER; s,in,out: StreamHandle; name: STRING ← [40]; ch: CHARACTER; WriteLine["Program Started"]; WriteString["Here is 'a: "]; WriteChar['a]; WriteChar[CR]; WriteString["Here is 23: "]; WriteDecimal[23]; WriteChar[CR]; WriteString["Type a Number: "]; n ← ReadDecimal[]; WriteString["I read: "]; WriteDecimal[n]; WriteChar[CR]; WriteLine["About to get and set streams"]; s ← GetOutputStream[]; SetOutputStream[s]; s ← GetInputStream[]; SetInputStream[s]; WriteString["Are you still there (y or n)? "]; IF ReadChar[]='y THEN WriteLine["Good"] ELSE WriteLine["Bad"]; WriteString["Type input file name: "]; ReadID[name]; WriteLine["Opening "]; WriteString[name]; WriteLine[" for reading"]; in ← NewByteStream[name, Read]; WriteString["Type output file name: "]; ReadID[name]; WriteLine["Opening "]; WriteString[name]; WriteLine[" for writing"]; out ← NewByteStream[name, Write+Append]; SetInputStream[in]; UNTIL in.endof[in] DO ch ← ReadChar[]; WriteChar[ch]; out.put[out,ch]; ENDLOOP; in.destroy[in]; out.destroy[out]; END.