ioto.red 4.6 KB

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