PRINTERU.LST 6.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192
  1. Listing:
  2. 1 IMPLEMENTATION MODULE PrinterUtils;
  3. 2 (*
  4. 3 * ModBase
  5. 4 * Release 3.0
  6. 5 * (c) Copyright 1986 - 1991 PMI
  7. 6 * P.O. Box 8402
  8. 7 * Green Bay Wi 53308
  9. 8 * All Rights Reserved
  10. 9 * by Ed Ross
  11. 10 *)
  12. 11
  13. 12 FROM SYSTEM IMPORT BYTE,ADR;
  14. 13 FROM DateFunctions IMPORT Date,DateToStr;
  15. 14 FROM StrConv IMPORT RealToStr,CardinalToStr,IntegerToStr,LongIntegerToStr;
  16. 15 FROM StringIO IMPORT WriteEol;
  17. 16 FROM M2Strings IMPORT Length,Assign;
  18. 17 FROM StrEdit IMPORT Center,RightJustify,CrunchBlanks,Append,MakeCurrency;
  19. 18 FROM Storage IMPORT ALLOCATE,DEALLOCATE;
  20. 19 FROM NumTypes IMPORT Real8;
  21. 20 FROM LowLevel IMPORT Fill;
  22. 21
  23. 22 TYPE DisplayLine = POINTER TO DisplayRec;
  24. ***** ^ undeclared identifier
  25. 23
  26. 24 DisplayRec = RECORD
  27. 25 Str : POINTER TO ARRAY[0..300] OF CHAR;
  28. ***** ^ not supported yet
  29. ***** ^ not supported yet
  30. 26 NbrBytes : CARDINAL;
  31. 27 END;
  32. ***** ^ not supported yet
  33. 28
  34. 29 PROCEDURE OverWrite(obj : ARRAY OF CHAR; VAR targ : ARRAY OF CHAR; Pos : CARDINAL);
  35. ***** ^ not supported yet
  36. ***** ^ not supported yet
  37. 30
  38. 31 VAR
  39. 32 J : CARDINAL;
  40. 33 K : CARDINAL;
  41. 34 BEGIN
  42. 35 K := Length(obj) + Pos;
  43. ***** ^ not supported yet
  44. ***** ^ not supported yet
  45. 36 IF K > Length(targ)
  46. ***** ^ not supported yet
  47. ***** ^ not supported yet
  48. 37 THEN K := Length(targ)
  49. ***** ^ not supported yet
  50. ***** ^ not supported yet
  51. 38 ELSE K := Length(obj)
  52. ***** ^ not supported yet
  53. ***** ^ not supported yet
  54. 39 END;
  55. 40 FOR J := 0 TO Length(obj) -1 DO
  56. ***** ^ not supported yet
  57. ***** ^ not supported yet
  58. ***** ^ FOR needs integer variable and bounds
  59. 41 targ[Pos + J] := obj[J];
  60. ***** ^ not supported yet
  61. ***** ^ not supported yet
  62. ***** ^ not supported yet
  63. ***** ^ not supported yet
  64. 42 END;
  65. 43
  66. 44 END OverWrite;
  67. ***** ^ not supported yet
  68. 45
  69. 46 PROCEDURE SetupDisplayLine(VAR PL : DisplayLine; NbrOfCols:CARDINAL);
  70. 47 BEGIN
  71. 48 ALLOCATE(PL,SIZE(PL^));
  72. ***** ^ not supported yet
  73. ***** ^ not supported yet
  74. ***** ^ undeclared identifier
  75. ***** ^ not supported yet
  76. 49 PL^.NbrBytes := NbrOfCols + 2;
  77. ***** ^ not supported yet
  78. ***** ^ not supported yet
  79. 50 ALLOCATE(PL^.Str,PL^.NbrBytes);
  80. ***** ^ not supported yet
  81. ***** ^ not supported yet
  82. ***** ^ not supported yet
  83. ***** ^ not supported yet
  84. ***** ^ not supported yet
  85. 51
  86. 52 ClearDisplayLine(PL);
  87. ***** ^ undeclared identifier
  88. ***** ^ not supported yet
  89. 53 END SetupDisplayLine;
  90. ***** ^ not supported yet
  91. 54
  92. 55
  93. 56 PROCEDURE RemoveDisplayLine(VAR PL : DisplayLine);
  94. 57 BEGIN
  95. 58 DEALLOCATE(PL^.Str,PL^.NbrBytes);
  96. ***** ^ not supported yet
  97. ***** ^ not supported yet
  98. ***** ^ not supported yet
  99. ***** ^ not supported yet
  100. ***** ^ not supported yet
  101. 59 DEALLOCATE(PL,SIZE(PL^));
  102. ***** ^ not supported yet
  103. ***** ^ not supported yet
  104. ***** ^ undeclared identifier
  105. ***** ^ not supported yet
  106. 60 PL := NIL;
  107. ***** ^ not supported yet
  108. 61 END RemoveDisplayLine;
  109. ***** ^ not supported yet
  110. 62
  111. 63
  112. 64 PROCEDURE AddPrintElemt(VAR PL: DisplayLine; elemt: ARRAY OF BYTE; PT : CHAR;
  113. ***** ^ not supported yet
  114. 65 ColNbr, NbrCols : CARDINAL; Justification : CHAR);
  115. 66 TYPE
  116. 67 DTypes = RECORD
  117. 68 CASE : CHAR OF
  118. ***** ^ not supported yet
  119. ***** ^ 'POINTER' expected
  120. 69 'R' : R : Real8;
  121. 70 |'I' : I : INTEGER;
  122. 71 |'L' : L : LONGINT;
  123. 72 |'C' : C : CARDINAL;
  124. 73 |'D' : D : Date;
  125. 74 |'S' : S : ARRAY[0..300] OF CHAR; (* string *)
  126. 75 |'$' : Dollar : Real8; (* Prefix with $ dollar type *)
  127. 76 |'%' : Percent :Real8; (* percent type suffix with '%'*)
  128. 77 END;
  129. 78 END;
  130. 79 CharSet = SET OF CHAR;
  131. 80 VAR
  132. 81 P : POINTER TO DTypes;
  133. 82 S : ARRAY [0..300] OF CHAR;
  134. 83 ok : BOOLEAN;
  135. 84 BEGIN
  136. 85 P := ADR(elemt);
  137. 86 P^.S[NbrCols] :=0C;
  138. 87 CASE PT OF (* first go through the conversions *)
  139. 88 'R','%','$' : RealToStr(P^.R,2,NbrCols,S);
  140. 89 |'I' : IntegerToStr(P^.I,NbrCols,S);
  141. 90 |'C' : CardinalToStr(P^.C,NbrCols,S);
  142. 91 |'L' : LongIntegerToStr(P^.L,NbrCols,S);
  143. 92 |'D' : DateToStr(P^.D,S,ok);
  144. 93 IF NOT ok
  145. 94 THEN S:= '?????'
  146. 95 END;
  147. 96 END;
  148. 97 IF PT IN CharSet{'R','I','C','L','D','%'}
  149. 98 THEN
  150. 99 Assign( S,P^.S);
  151. 100 END;
  152. 101 IF PT = '%'
  153. 102 THEN Append(P^.S,'%');
  154. 103 ELSIF PT = 'R'
  155. 104 THEN
  156. 105 MakeCurrency('$',P^.S);
  157. 106 Assign( P^.S,S); (* kluge here *)
  158. 107 RightJustify(S,NbrCols);
  159. 108 Assign(S,P^.S );
  160. 109
  161. 110 END;
  162. 111
  163. 112 CASE Justification OF
  164. 113 'C' : Center(P^.S,NbrCols);
  165. 114 |'R' : RightJustify(P^.S,10);
  166. 115 END;
  167. 116 OverWrite(P^.S,PL^.Str^,ColNbr);
  168. 117 S := S; (* debug stop *)
  169. 118 END AddPrintElemt;
  170. 119
  171. 120 PROCEDURE PrintDisplayLine(PL : DisplayLine; Handle : CARDINAL);
  172. 121 BEGIN
  173. 122 WriteEol(Handle,PL^.Str^);
  174. 123 END PrintDisplayLine;
  175. 124
  176. 125 PROCEDURE GetDisplayLine(PL : DisplayLine; VAR Display : ARRAY OF CHAR);
  177. 126 BEGIN
  178. 127 Assign(PL^.Str^,Display );
  179. 128 END GetDisplayLine;
  180. 129
  181. 130 PROCEDURE ClearDisplayLine(VAR PL : DisplayLine);
  182. 131 BEGIN
  183. 132 Fill(ADR(PL^.Str^),PL^.NbrBytes-1,' ');
  184. 133 PL^.Str^[PL^.NbrBytes-1] := CHR(0);
  185. 134 END ClearDisplayLine;
  186. 135
  187. 136 END PrinterUtils.
  188. 50 errors