DIRECTORY Atom, Basics, BasicTime, IO, Rope, UXIO; UXIOTestImpl: CEDAR PROGRAM IMPORTS Atom, IO, UXIO ~ BEGIN DoStream: PROC [s: IO.STREAM] ~ { IO.PutRope[s, "Hello world; Cedar is alive on a Sun\L"]; IO.PutF1[s, "a rope: %g\L", [rope["rope"]]]; IO.PutF1[s, "an int: %g\L", [integer[LAST[INT]]]]; IO.PutF1[s, "an int: %g\L", [integer[FIRST[INT]]]]; IO.PutF1[s, "a char: %g\L", [character['c]]]; IO.PutF1[s, "an atom: %g\L", [atom[Atom.MakeAtom["atom"]]]]; IO.PutF1[s, "a bool: %g\L", [boolean[TRUE]]]; IO.PutF1[s, "a card: %g\L", [cardinal[LAST[CARD]]]]; IO.PutF1[s, "a card: %g\L", [cardinal[FIRST[CARD]]]]; IO.PutF1[s, "a real: %g\L", [real[1.0]]]; }; DoStandard: PROC [] ~ { s: IO.STREAM ¬ UXIO.CreateStandardStream[output]; DoStream[s]; }; DoFile: PROC [] ~ { s: IO.STREAM ¬ UXIO.CreateFileStream["myfile", write]; DoStream[s]; }; DoInput: PROC [] ~ { i: IO.STREAM ¬ UXIO.CreateStandardStream[input]; o: IO.STREAM ¬ UXIO.CreateStandardStream[output]; o.PutRope["Type a string: "]; o.PutF1["The line you just typed was: %g\L", [rope[i.GetLineRope[]]]]; o.PutRope["Type an int: "]; o.PutF1["\LYou just typed: %g\L", [integer[i.GetInt[]]]]; { ENABLE { IO.EndOfStream => {o.PutRope["\LCaught one. \L"]; GOTO out }; UNCAUGHT => GOTO out; }; DO o.PutRope["Type an end-of-file or an int: "]; o.PutF1["\LYou just typed: %g\L", [integer[i.GetInt[]]]]; ENDLOOP; EXITS out => NULL; }; }; DoCopy: PROC [] ~ { i: IO.STREAM ¬ UXIO.CreateStandardStream[input]; o: IO.STREAM ¬ UXIO.CreateStandardStream[output]; infile, outfile: Rope.ROPE; o.PutRope["Type input filename: "]; infile ¬ i.GetLineRope[]; o.PutRope["Type output filename: "]; outfile ¬ i.GetLineRope[]; { source: IO.STREAM ¬ UXIO.CreateFileStream[name: infile, access: read]; dest: IO.STREAM ¬ UXIO.CreateFileStream[name: outfile, access: write]; buffer: PACKED ARRAY[0..512) OF CHAR; bufferblock: Basics.UnsafeBlock ¬ [base: NIL, startIndex: 0, count: 512]; TRUSTED { bufferblock.base ¬ LOOPHOLE[@buffer]; { bytesread: INT ¬ source.UnsafeGetBlock[bufferblock]; WHILE bytesread > 0 DO bufferblock.count ¬ bytesread; [] ¬ dest.UnsafePutBlock[bufferblock]; bytesread ¬ source.UnsafeGetBlock[bufferblock]; ENDLOOP; }; }; }; }; DoIndex: PROC [] ~ { i: IO.STREAM ¬ UXIO.CreateStandardStream[input]; o: IO.STREAM ¬ UXIO.CreateStandardStream[output]; s: IO.STREAM ¬ NIL; outfile: Rope.ROPE; o.PutRope["Type output filename: "]; outfile ¬ i.GetLineRope[]; s ¬ UXIO.CreateFileStream[outfile, write]; IO.PutRope[s, "000000000000000000000000\n"]; IO.SetIndex[s, 8]; IO.PutRope[s, "11111111"]; IO.PutF1[o, "final index = %g\n", [integer[IO.GetIndex[s]]]]; IO.Close[s]; }; DoLength: PROC [] ~ { i: IO.STREAM ¬ UXIO.CreateStandardStream[input]; o: IO.STREAM ¬ UXIO.CreateStandardStream[output]; s: IO.STREAM ¬ NIL; infile: Rope.ROPE; o.PutRope["Type input filename: "]; infile ¬ i.GetLineRope[]; s ¬ UXIO.CreateFileStream[infile, read]; IO.PutF[o, "Length of %g is %g\n", [rope[infile]], [integer[IO.GetLength[s]]]]; IO.Close[s]; }; DoInput[]; END.  UXIOTestImpl.mesa Copyright Σ 1988, 1991 by Xerox Corporation. All rights reserved. Carl Hauser, September 29, 1988 3:31:06 pm PDT Doug Wyatt, March 7, 1988 2:43:36 pm PST Michael Plass, November 22, 1991 4:22 pm PST IO.PutF1[s, "a time: %g\L", [time[BasicTime.nullGMT]]]; Κ––(cedarcode) style•NewlineDelimiter ™šœ™Icodešœ Οeœ7™BK™.K™(K™,J™—šΟk ˜ K˜K˜K˜ Kšžœ˜K˜Kšžœ˜K˜—K˜šΟn œžœž˜Kšžœžœž˜Kšœž˜K˜—šŸœžœžœžœ˜!Kšžœ6˜8Kšžœ*˜,Kšžœ0˜2Kšžœ1˜3Kšžœ+˜-Kšžœ:˜