ioto.red 4.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158
  1. % ----------------------------------------------------------------------
  2. % $Id: ioto.red,v 1.4 2003/12/02 15:27:36 sturm Exp $
  3. % ----------------------------------------------------------------------
  4. % Copyright (c) 1995-1999 Andreas Dolzmann and Thomas Sturm
  5. % ----------------------------------------------------------------------
  6. % $Log: ioto.red,v $
  7. % Revision 1.4 2003/12/02 15:27:36 sturm
  8. % Introduced ioto_nterpri to avoid ugly linebreaks in verbosity output.
  9. %
  10. % Revision 1.3 1999/03/22 15:22:20 dolzmann
  11. % Changed copyright information.
  12. % Corrected comments.
  13. %
  14. % Revision 1.2 1999/01/17 15:32:20 dolzmann
  15. % Added comments.
  16. %
  17. % Revision 1.1 1996/04/30 12:06:42 sturm
  18. % Merged ioto, lto, and sfto into rltools.
  19. %
  20. % Revision 1.1 1996/03/22 11:58:08 sturm
  21. % Moved and renamed. Previously iotopsl.red.
  22. %
  23. % Revision 1.5 1996/03/09 13:34:44 sturm
  24. % Added use of !#-macros for resolving Lisp dependencies.
  25. % Minor modifications in procedure ioto_realtime.
  26. %
  27. % Revision 1.4 1996/03/04 17:20:02 sturm
  28. % Added procedure ioto_prtmsg.
  29. % Tried to achive CSL compatibility:
  30. % Added procedures ioto_pslp, ioto_flush.
  31. % Used SL function posn instead of system call.
  32. % Under CSL, ioto_realtime should return "???" now.
  33. %
  34. % Revision 1.3 1995/08/30 08:10:33 sturm
  35. % Added procedure procedure ioto_cplu. :-)
  36. %
  37. % Revision 1.2 1995/07/07 10:55:51 sturm
  38. % Added procedure ioto_realtime.
  39. %
  40. % Revision 1.1 1995/06/21 14:32:12 dolzmann
  41. % Initial check-in.
  42. %
  43. % ----------------------------------------------------------------------
  44. lisp <<
  45. fluid '(ioto_rcsid!* ioto_copyright!*);
  46. ioto_rcsid!* := "$Id: ioto.red,v 1.4 2003/12/02 15:27:36 sturm Exp $";
  47. ioto_copyright!* := "Copyright (c) 1995-1999 by A. Dolzmann and T. Sturm"
  48. >>;
  49. module ioto;
  50. % Input/Output tools.
  51. fluid '(ioto_realtime!* datebuffer);
  52. ioto_realtime!* := 0;
  53. procedure ioto_prin2(l);
  54. % Input/Output tools prin2. [l] is an atom or a list. Returns ANY.
  55. % Prints either the atom [l] or each element in the list [l]
  56. % without any space between the elements. The output is not
  57. % buffered.
  58. ioto_prin21(l,nil,nil,nil);
  59. procedure ioto_tprin2(l);
  60. % Input/Output tools conditional terpri prin2. [l] is an atom or a
  61. % list. Returns ANY. Equivalent to [ioto_cterpri();ioto_prin2(l)].
  62. ioto_prin21(l,t,nil,nil);
  63. procedure ioto_prin2t(l);
  64. % Input/Output tools prin2 conditional terpri. [l] is an atom or a
  65. % list. Returns ANY. Equivalent to [ioto_prin2(l);ioto_cterpri()].
  66. ioto_prin21(l,nil,t,nil);
  67. procedure ioto_tprin2t(l);
  68. % Input/Output tools conditional terpri prin2 conditional terpri.
  69. % [l] is an atom or a list. Returns ANY. Equivalent to
  70. % [ioto_cterpri();ioto_prin2(l);ioto_cterpri()].
  71. ioto_prin21(l,t,t,nil);
  72. procedure ioto_prtmsg(l);
  73. % Input/Output tools print message. [l] is an atom or a list.
  74. % Returns ANY. Prints either the atom [l] or each element in the
  75. % list [l] seperated by one space between the elements. The output
  76. % is not buffered. Does before and after the printing an
  77. % [ioto_cterpri].
  78. ioto_prin21(l,t,t,t);
  79. procedure ioto_prin21(l,flg1,flg2,spc);
  80. % Input/Output tools prin2 subroutine. [l] is an atom or a list;
  81. % [flg1], [flg2], and [spc] are Boolean. Returns ANY.
  82. <<
  83. if l and atom l then l := {l};
  84. if flg1 then ioto_cterpri();
  85. for each x in l do <<
  86. prin2 x;
  87. if spc then prin2 " "
  88. >>;
  89. ioto_flush();
  90. if flg2 then ioto_cterpri()
  91. >>;
  92. procedure ioto_cterpri();
  93. % Input/Output tools conditional terpri. No parameter. Returns ANY.
  94. % Does a [terpri()] if the cursor is not on the beginning of a
  95. % line.
  96. if posn()>0 then
  97. terpri();
  98. procedure ioto_nterpri(n);
  99. if posn() + n > linelength nil then
  100. terpri();
  101. fluid '(fancy!-switch!-on!* fancy!-switch!-off!*);
  102. procedure ioto_cplu(s,c);
  103. % Input/Output tools conditional plural. [s] is a string; [c] is
  104. % Boolean. Returns a string. Appends a ``s'' to [s], provided that
  105. % [c] is non-[nil].
  106. if c then compress reversip('!" . '!s . cdr reversip explode s) else s;
  107. procedure ioto_realtime();
  108. % Input/Output tools real time. No parameter. Returns wall clock
  109. % seconds since previous call.
  110. begin scalar aa,res;
  111. aa := ioto_datestamp();
  112. res := aa - ioto_realtime!*;
  113. ioto_realtime!* := aa;
  114. return res
  115. end;
  116. procedure ioto_flush();
  117. % Input/Output flush. No parameter. Returns ANY. Flushes the output
  118. % buffer.
  119. !#if (memq 'psl lispsystem!*)
  120. <<
  121. flushbuffer out!*;
  122. channelflush out!*
  123. >>;
  124. !#else
  125. flush();
  126. !#endif
  127. procedure ioto_datestamp();
  128. % Input/Output datestamp. No parameter. Returns an integer the
  129. % number of secons since an fixed date.
  130. !#if (memq 'psl lispsystem!*)
  131. <<
  132. date();
  133. sys2int wgetv(datebuffer,0)
  134. >>;
  135. !#else
  136. datestamp();
  137. !#endif
  138. endmodule; % [ioto]
  139. end; % of file