STRINGIO.LST 19 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432
  1. Listing:
  2. 1 IMPLEMENTATION MODULE StringIO;
  3. 2 (*
  4. 3 * REPERTOIRE
  5. 4 * Release 1.6
  6. 5 * By Charles Bradford and Cole Brecheen
  7. 6 * (c) Copyright 1985-1992 PMI
  8. 7 * Green Bay, Wisconsin
  9. 8 * All rights reserved
  10. 9 * (414) 468-6040
  11. 10 *
  12. 11 * $Header: D:/logfiles/mods/stringio.mov 1.7 17 Mar 1991 18:00:12 coleb $
  13. 12 *
  14. 13 *)
  15. 14
  16. 15 IMPORT ErrStrgs;
  17. 16 IMPORT ErrorManager;
  18. 17 IMPORT LowLevel;
  19. 18 IMPORT M2Strings;
  20. 19 IMPORT SYSTEM;
  21. 20 IMPORT FAPI;
  22. 21
  23. 22 VAR
  24. 23 Initialized : BOOLEAN;
  25. 24
  26. 25 PROCEDURE Init();
  27. 26 BEGIN
  28. 27 IF Initialized THEN
  29. 28 RETURN;
  30. 29 ELSE
  31. 30 Initialized := TRUE;
  32. 31 END;
  33. 32 ErrStrgs.Init();
  34. ***** ^ not supported yet
  35. ***** ^ not supported yet
  36. ***** ^ not supported yet
  37. 33 ErrorManager.Init();
  38. ***** ^ not supported yet
  39. ***** ^ not supported yet
  40. ***** ^ not supported yet
  41. 34 LowLevel.Init();
  42. ***** ^ not supported yet
  43. ***** ^ not supported yet
  44. ***** ^ not supported yet
  45. 35 M2Strings.Init();
  46. ***** ^ not supported yet
  47. ***** ^ not supported yet
  48. ***** ^ not supported yet
  49. 36 CrLf[0] := 15C;
  50. ***** ^ undeclared identifier
  51. ***** ^ not supported yet
  52. 37 CrLf[1] := 12C;
  53. ***** ^ undeclared identifier
  54. ***** ^ not supported yet
  55. 38 END Init;
  56. ***** ^ not supported yet
  57. 39
  58. 40
  59. 41 PROCEDURE WriteStr(FileHandle : CARDINAL; TheStr : ARRAY OF CHAR);
  60. ***** ^ not supported yet
  61. 42 VAR
  62. 43 BytesWritten: CARDINAL;
  63. 44 ErrorReturn: CARDINAL;
  64. 45 BEGIN
  65. 46 ErrorReturn := FAPI.DOSWRITE( FileHandle, SYSTEM.ADR(TheStr),
  66. ***** ^ not supported yet
  67. ***** ^ not supported yet
  68. ***** ^ not supported yet
  69. ***** ^ not supported yet
  70. ***** ^ not supported yet
  71. 47 M2Strings.Length(TheStr), SYSTEM.ADR(BytesWritten) );
  72. ***** ^ not supported yet
  73. ***** ^ not supported yet
  74. ***** ^ not supported yet
  75. ***** ^ not supported yet
  76. ***** ^ not supported yet
  77. ***** ^ not supported yet
  78. 48 IF ErrorReturn #0 THEN
  79. 49 ErrorManager.WarnNumber("DOSWRITE error", ErrorReturn);
  80. ***** ^ not supported yet
  81. ***** ^ not supported yet
  82. ***** ^ not supported yet
  83. ***** ^ not supported yet
  84. 50 END;
  85. 51 END WriteStr;
  86. ***** ^ not supported yet
  87. 52
  88. 53
  89. 54 PROCEDURE ReadStr(FileHandle : CARDINAL; VAR TheStr : ARRAY OF CHAR);
  90. ***** ^ not supported yet
  91. 55 VAR
  92. 56 KbdState : FAPI.KBDINFO;
  93. ***** ^ not supported yet
  94. 57 lngth : FAPI.STRINGINBUF;
  95. ***** ^ not supported yet
  96. 58 BytesRead, StrSize, CrSpot : CARDINAL;
  97. 59 Distance, NewFilePtr, OldFilePtr : LONGINT;
  98. 60 linefeed: ARRAY [0..0] OF CHAR;
  99. ***** ^ not supported yet
  100. ***** ^ not supported yet
  101. 61
  102. 62 BEGIN
  103. 63 (*ReadStr*)
  104. 64 TheStr[0] := 0C;
  105. ***** ^ not supported yet
  106. ***** ^ not supported yet
  107. 65 linefeed[0] := CHR(10);
  108. ***** ^ not supported yet
  109. ***** ^ not supported yet
  110. ***** ^ undeclared identifier
  111. ***** ^ not supported yet
  112. 66 StrSize := HIGH(TheStr);
  113. ***** ^ undeclared identifier
  114. ***** ^ not supported yet
  115. 67 (* For some mysterious reason, if you set StrSize to HIGH+1,
  116. 68 the call to KBDSTRINGIN doesn't wait for input. *)
  117. 69 IF FileHandle = inp THEN
  118. ***** ^ undeclared identifier
  119. 70
  120. 71 KbdState.cb := 10;
  121. ***** ^ not supported yet
  122. ***** ^ not supported yet
  123. 72 KbdState.fsMask := FAPI.KEYBOARD_ECHO_ON + FAPI.KEYBOARD_ASCII_MODE;
  124. ***** ^ not supported yet
  125. ***** ^ not supported yet
  126. ***** ^ not supported yet
  127. ***** ^ not supported yet
  128. ***** ^ not supported yet
  129. ***** ^ not supported yet
  130. 73 KbdState.chTurnAround := 0;
  131. ***** ^ not supported yet
  132. ***** ^ not supported yet
  133. 74 KbdState.fsInterim := 0;
  134. ***** ^ not supported yet
  135. ***** ^ not supported yet
  136. 75 KbdState.fsState := 0;
  137. ***** ^ not supported yet
  138. ***** ^ not supported yet
  139. 76
  140. 77 IF 0 # FAPI.KBDSETSTATUS( SYSTEM.ADR(KbdState), 0 ) THEN
  141. ***** ^ not supported yet
  142. ***** ^ not supported yet
  143. ***** ^ not supported yet
  144. ***** ^ not supported yet
  145. ***** ^ not supported yet
  146. ***** ^ not supported yet
  147. 78 END;
  148. 79
  149. 80 lngth.cb := StrSize;
  150. ***** ^ not supported yet
  151. ***** ^ not supported yet
  152. 81 IF 0 # FAPI.KBDSTRINGIN( SYSTEM.ADR(TheStr),
  153. ***** ^ not supported yet
  154. ***** ^ not supported yet
  155. ***** ^ not supported yet
  156. ***** ^ not supported yet
  157. ***** ^ not supported yet
  158. 82 SYSTEM.ADR(lngth), 0, 0 ) THEN
  159. ***** ^ not supported yet
  160. ***** ^ not supported yet
  161. ***** ^ not supported yet
  162. ***** ^ not supported yet
  163. 83 END;
  164. 84 (* This goddamned thing echoes the carriage return. *)
  165. 85 WriteStr( outp, linefeed );
  166. ***** ^ not supported yet
  167. ***** ^ undeclared identifier
  168. ***** ^ not supported yet
  169. 86 (* So we make the best of it by echoing a linefeed. *)
  170. 87 TheStr[ lngth.cchIn ] := 0C;
  171. ***** ^ not supported yet
  172. ***** ^ not supported yet
  173. ***** ^ not supported yet
  174. 88 RETURN;
  175. 89 END;
  176. 90
  177. 91 IF FAPI.DOSCHGFILEPTR( FileHandle,
  178. ***** ^ not supported yet
  179. ***** ^ not supported yet
  180. 92 VAL(LONGINT, 0), 1, SYSTEM.ADR(OldFilePtr)) # 0 THEN
  181. ***** ^ undeclared identifier
  182. ***** ^ not supported yet
  183. ***** ^ not supported yet
  184. ***** ^ not supported yet
  185. ***** ^ not supported yet
  186. 93 END;
  187. 94 (* Move 0 bytes relative to the current position in the
  188. 95 file so that we can find out what our current position is. *)
  189. 96 LowLevel.Fill( SYSTEM.ADR(TheStr), StrSize, 0C );
  190. ***** ^ not supported yet
  191. ***** ^ not supported yet
  192. ***** ^ not supported yet
  193. ***** ^ not supported yet
  194. ***** ^ not supported yet
  195. ***** ^ not supported yet
  196. 97 IF FAPI.DOSREAD( FileHandle, SYSTEM.ADR(TheStr),
  197. ***** ^ not supported yet
  198. ***** ^ not supported yet
  199. ***** ^ not supported yet
  200. ***** ^ not supported yet
  201. ***** ^ not supported yet
  202. 98 StrSize, SYSTEM.ADR(BytesRead) ) = 0 THEN
  203. ***** ^ not supported yet
  204. ***** ^ not supported yet
  205. ***** ^ not supported yet
  206. 99 CrSpot := LowLevel.ScanEQ( BytesRead, CHR(13), SYSTEM.ADR(TheStr) );
  207. ***** ^ not supported yet
  208. ***** ^ not supported yet
  209. ***** ^ undeclared identifier
  210. ***** ^ not supported yet
  211. ***** ^ not supported yet
  212. ***** ^ not supported yet
  213. ***** ^ not supported yet
  214. 100 (* Scan for a carriage return *)
  215. 101 IF (CrSpot < BytesRead) THEN
  216. 102 (* We found one. *)
  217. 103 TheStr[CrSpot] := 0C;
  218. ***** ^ not supported yet
  219. ***** ^ not supported yet
  220. 104 IF (CrSpot < HIGH(TheStr)) AND (TheStr[CrSpot + 1] = CHR(10)) THEN
  221. ***** ^ undeclared identifier
  222. ***** ^ not supported yet
  223. ***** ^ not supported yet
  224. ***** ^ not supported yet
  225. ***** ^ undeclared identifier
  226. ***** ^ not supported yet
  227. 105 (* If the next character is a linefeed *)
  228. 106 INC( CrSpot );
  229. ***** ^ undeclared identifier
  230. ***** ^ not supported yet
  231. 107 TheStr[CrSpot] := 0C;
  232. ***** ^ not supported yet
  233. ***** ^ not supported yet
  234. 108 END;
  235. 109 IF FAPI.DOSCHGFILEPTR( FileHandle,
  236. ***** ^ not supported yet
  237. ***** ^ not supported yet
  238. 110 OldFilePtr + VAL(LONGINT, CrSpot+1), 0,
  239. ***** ^ undeclared identifier
  240. ***** ^ not supported yet
  241. 111 SYSTEM.ADR(NewFilePtr)) # 0 THEN
  242. ***** ^ not supported yet
  243. ***** ^ not supported yet
  244. ***** ^ not supported yet
  245. 112 END;
  246. 113 END;
  247. 114 ELSE
  248. 115 ErrorManager.WARN("DOSREAD error ");
  249. ***** ^ not supported yet
  250. ***** ^ not supported yet
  251. ***** ^ not supported yet
  252. 116 END;
  253. 117 END ReadStr;
  254. ***** ^ not supported yet
  255. 118
  256. 119
  257. 120 PROCEDURE ReadString(FileHandle : CARDINAL; VAR
  258. 121 TheStr : ARRAY OF CHAR; VAR EndOfFileReached:
  259. ***** ^ not supported yet
  260. 122 BOOLEAN );
  261. 123 VAR
  262. 124 StrSize, BytesRead, CrSpot: CARDINAL;
  263. 125 OldFilePtr, NewFilePtr: LONGINT;
  264. 126 BEGIN
  265. 127 StrSize := HIGH(TheStr) + 1;
  266. ***** ^ undeclared identifier
  267. ***** ^ not supported yet
  268. 128 IF FAPI.DOSCHGFILEPTR( FileHandle,
  269. ***** ^ not supported yet
  270. ***** ^ not supported yet
  271. 129 VAL(LONGINT, 0), 1, SYSTEM.ADR(OldFilePtr)) # 0 THEN
  272. ***** ^ undeclared identifier
  273. ***** ^ not supported yet
  274. ***** ^ not supported yet
  275. ***** ^ not supported yet
  276. ***** ^ not supported yet
  277. 130 END;
  278. 131 (* Move 0 bytes relative to the current position in the
  279. 132 file so that we can find out what our current position is. *)
  280. 133 LowLevel.Fill( SYSTEM.ADR(TheStr), StrSize, 0C );
  281. ***** ^ not supported yet
  282. ***** ^ not supported yet
  283. ***** ^ not supported yet
  284. ***** ^ not supported yet
  285. ***** ^ not supported yet
  286. ***** ^ not supported yet
  287. 134 (* If the following read fails, maybe because we've reached
  288. 135 the end of the file, it won't zero out TheStr. We have to
  289. 136 make sure TheStr is null if we're not reading a new string. *)
  290. 137 IF FAPI.DOSREAD( FileHandle, SYSTEM.ADR(TheStr),
  291. ***** ^ not supported yet
  292. ***** ^ not supported yet
  293. ***** ^ not supported yet
  294. ***** ^ not supported yet
  295. ***** ^ not supported yet
  296. 138 StrSize, SYSTEM.ADR(BytesRead) ) = 0 THEN
  297. ***** ^ not supported yet
  298. ***** ^ not supported yet
  299. ***** ^ not supported yet
  300. 139 CrSpot := LowLevel.ScanEQ( BytesRead, CHR(13), SYSTEM.ADR(TheStr) );
  301. ***** ^ not supported yet
  302. ***** ^ not supported yet
  303. ***** ^ undeclared identifier
  304. ***** ^ not supported yet
  305. ***** ^ not supported yet
  306. ***** ^ not supported yet
  307. ***** ^ not supported yet
  308. 140 (* Scan for a carriage return *)
  309. 141 IF (CrSpot < BytesRead) THEN
  310. 142 (* We found one. *)
  311. 143 TheStr[CrSpot] := 0C;
  312. ***** ^ not supported yet
  313. ***** ^ not supported yet
  314. 144 BytesRead := StrSize;
  315. 145 IF (CrSpot < HIGH(TheStr)) AND (TheStr[CrSpot + 1] = CHR(10)) THEN
  316. ***** ^ undeclared identifier
  317. ***** ^ not supported yet
  318. ***** ^ not supported yet
  319. ***** ^ not supported yet
  320. ***** ^ undeclared identifier
  321. ***** ^ not supported yet
  322. 146 (* If the next character is a linefeed *)
  323. 147 INC( CrSpot );
  324. ***** ^ undeclared identifier
  325. ***** ^ not supported yet
  326. 148 TheStr[CrSpot] := 0C;
  327. ***** ^ not supported yet
  328. ***** ^ not supported yet
  329. 149 END;
  330. 150 IF FAPI.DOSCHGFILEPTR( FileHandle,
  331. ***** ^ not supported yet
  332. ***** ^ not supported yet
  333. 151 OldFilePtr + VAL(LONGINT, CrSpot + 1), 0,
  334. ***** ^ undeclared identifier
  335. ***** ^ not supported yet
  336. 152 SYSTEM.ADR(NewFilePtr)) # 0 THEN
  337. ***** ^ not supported yet
  338. ***** ^ not supported yet
  339. ***** ^ not supported yet
  340. 153 END;
  341. 154 END;
  342. 155 END;
  343. 156 EndOfFileReached := BytesRead < StrSize;
  344. 157 END ReadString;
  345. ***** ^ not supported yet
  346. 158
  347. 159
  348. 160 PROCEDURE WriteEol(FileHandle : CARDINAL; TheStr : ARRAY OF CHAR);
  349. ***** ^ not supported yet
  350. 161 VAR
  351. 162 TmpStr : ARRAY [0..255] OF CHAR;
  352. ***** ^ not supported yet
  353. ***** ^ not supported yet
  354. 163 bufstr : ARRAY [0..2] OF CHAR;
  355. ***** ^ not supported yet
  356. ***** ^ not supported yet
  357. 164 BEGIN
  358. 165 IF M2Strings.Length(TheStr)<=254 THEN
  359. ***** ^ not supported yet
  360. ***** ^ not supported yet
  361. ***** ^ not supported yet
  362. 166 M2Strings.Concat(TheStr, CrLf, TmpStr);
  363. ***** ^ not supported yet
  364. ***** ^ not supported yet
  365. ***** ^ not supported yet
  366. ***** ^ undeclared identifier
  367. ***** ^ not supported yet
  368. 167 WriteStr(FileHandle, TmpStr);
  369. ***** ^ not supported yet
  370. ***** ^ not supported yet
  371. 168 ELSE
  372. 169 WriteStr(FileHandle, TheStr);
  373. ***** ^ not supported yet
  374. ***** ^ not supported yet
  375. 170 WriteStr(FileHandle, CrLf);
  376. ***** ^ not supported yet
  377. ***** ^ undeclared identifier
  378. 171 END;
  379. 172 END WriteEol;
  380. ***** ^ not supported yet
  381. 173
  382. 174
  383. 175 PROCEDURE MessageType(FunctionResult : CHAR) : CARDINAL;
  384. 176 BEGIN
  385. 177 RETURN ORD( FunctionResult );
  386. ***** ^ undeclared identifier
  387. ***** ^ not supported yet
  388. 178 END MessageType;
  389. ***** ^ not supported yet
  390. 179
  391. 180
  392. 181 PROCEDURE PrintMessage(FunctionResult : CARDINAL);
  393. 182 VAR
  394. 183 TmpStr: ARRAY [0..79] OF CHAR;
  395. ***** ^ not supported yet
  396. ***** ^ not supported yet
  397. 184 BEGIN
  398. 185 ErrStrgs.NumToStr( FunctionResult, TmpStr );
  399. ***** ^ not supported yet
  400. ***** ^ not supported yet
  401. ***** ^ not supported yet
  402. 186 CASE FunctionResult OF
  403. 187 NoError : (*do nothing*)
  404. ***** ^ undeclared identifier
  405. 188 | PartialRead, EndOfFile:
  406. ***** ^ undeclared identifier
  407. ***** ^ undeclared identifier
  408. 189 WriteStr( ErrorOutp, TmpStr );
  409. ***** ^ not supported yet
  410. ***** ^ undeclared identifier
  411. ***** ^ not supported yet
  412. 190 ELSE
  413. 191 ErrorManager.WARN( TmpStr );
  414. ***** ^ not supported yet
  415. ***** ^ not supported yet
  416. ***** ^ not supported yet
  417. 192 END;
  418. 193 END PrintMessage;
  419. ***** ^ not supported yet
  420. 194
  421. 195 BEGIN
  422. 196 Initialized := FALSE;
  423. 197 Init();
  424. ***** ^ not supported yet
  425. ***** ^ not supported yet
  426. 198 END StringIO.
  427. ***** ^ not supported yet
  428. 228 errors