other-io.red 2.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091
  1. %
  2. % OTHER-IO.RED - Miscellaneous input and output functions
  3. %
  4. % Author: Eric Benson
  5. % Symbolic Computation Group
  6. % Computer Science Dept.
  7. % University of Utah
  8. % Date: 28 August 1981
  9. % Copyright (c) 1981 University of Utah
  10. %
  11. % Edit by Cris Perdue, 27 Jan 1983 1428-PST
  12. % put in Kessler's change so ChannelLineLength allows Len=0 to mean that
  13. % EOL is not to be automatically written.
  14. % <PSL.KERNEL>OTHER-IO.RED.3, 29-Dec-82 12:23:52, Edit by PERDUE
  15. % added LPosn and ChannelLPosn
  16. % <PSL.KERNEL>OTHER-IO.RED.2, 17-Sep-82 15:46:38, Edit by BENSON
  17. % Added ChannelLinelength, ChannelPosn, ChannelEject, ChannelTerPri
  18. % ChannelReadCH, ChannelPrinC
  19. % <PSL.INTERP>OTHER-IO.RED.3, 21-Jul-82 00:48:35, Edit by BENSON
  20. % Made ReadCh do case conversion for *Raise
  21. % Most of the uninteresting I/O functions from the Standard Lisp report
  22. global '(OUT!*); % Current output channel
  23. fluid '(!*Raise); % controls case conversion of IDs
  24. on SysLisp;
  25. external WArray LinePosition, % Array indexed by channel
  26. MaxLine; % ditto
  27. syslsp procedure ChannelEject C; %. Skip to top of next output page
  28. << ChannelWriteChar(C, char FF); % write a formfeed
  29. NIL >>;
  30. syslsp procedure Eject(); %. Skip to top of next output page
  31. ChannelEject LispVar OUT!*;
  32. syslsp procedure ChannelLineLength(Chn, Len); %. Set maximum line length
  33. begin scalar OldLen, StripLen;
  34. OldLen := MaxLine[Chn];
  35. if Len then
  36. if IntP Len and Len >= 0 then
  37. MaxLine[Chn] := Len
  38. else
  39. StdError BldMsg('"%r is an invalid line length", Len);
  40. return OldLen; % if Len is NIL, just return current
  41. end;
  42. syslsp procedure LineLength Len; %. Set maximum line length
  43. ChannelLineLength(LispVar OUT!*, Len);
  44. syslsp procedure ChannelPosn Chn; %. Number of characters since last EOL
  45. LinePosition[Chn];
  46. syslsp procedure Posn(); %. Number of characters since last EOL
  47. ChannelPosn LispVar OUT!*;
  48. syslsp procedure ChannelLPosn Chn; %. Number of EOLs since last FF
  49. PagePosition[Chn];
  50. syslsp procedure LPosn(); %. Number of EOLs since last FF
  51. ChannelLPosn LispVar OUT!*;
  52. syslsp procedure ChannelReadCH Chn; %. Read a single character ID
  53. begin scalar X; % for Standard Lisp compatibility
  54. X := ChannelReadChar Chn; % converts lower to upper when *RAISE
  55. if LispVar !*Raise and X >= char lower a and X <= char lower z then
  56. X := char A + (X - char lower a);
  57. return MkID X;
  58. end;
  59. syslsp procedure ReadCH(); %. Read a single character ID
  60. ChannelReadCH LispVar IN!*;
  61. syslsp procedure ChannelTerPri Chn; %. Terminate current output line
  62. << ChannelWriteChar(Chn, char EOL);
  63. NIL >>;
  64. syslsp procedure TerPri(); %. Terminate current output line
  65. ChannelTerPri LispVar OUT!*;
  66. off SysLisp;
  67. LoadTime PutD('PrinC, 'EXPR, cdr GetD 'Prin2); % same definition as Prin2
  68. LoadTime PutD('ChannelPrinC, 'EXPR, cdr GetD 'ChannelPrin2);
  69. % same definition as ChannelPrin2
  70. END;