APPEND.LST 18 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405
  1. Listing:
  2. 1 MODULE Append;
  3. 2
  4. 3 IMPORT Drectory;
  5. 4 IMPORT HandleIO;
  6. 5 IMPORT StringIO;
  7. 6 IMPORT LowLevel;
  8. 7 IMPORT M2Strings;
  9. 8 IMPORT Numbers;
  10. 9 IMPORT NumTypes;
  11. 10 IMPORT EnvironUtils;
  12. 11 IMPORT VStorage;
  13. 12 (*
  14. 13 IMPORT InitJPI;
  15. 14 *)
  16. 15
  17. 16 PROCEDURE AppendToFile(OldHandle : CARDINAL; DestFileName : ARRAY OF CHAR) :
  18. ***** ^ not supported yet
  19. 17 CARDINAL;
  20. 18 TYPE
  21. 19 memptr =
  22. 20 RECORD
  23. 21 addr : LowLevel.Address8086;
  24. ***** ^ not supported yet
  25. 22 size : CARDINAL;
  26. 23 END;
  27. ***** ^ not supported yet
  28. 24 VAR
  29. 25 TheDrive : CHAR;
  30. 26 MemoryPtr : memptr;
  31. ***** ^ not supported yet
  32. 27 NewHandle : CARDINAL;
  33. 28 SavedMessage : CARDINAL;
  34. 29 FreeBytes, FileSize, DestSize, BytesToRead : LONGINT;
  35. 30
  36. 31 PROCEDURE ReadOldFile(VAR MemoryPtr : memptr);
  37. 32 VAR
  38. 33 BytesAvailable : CARDINAL;
  39. 34 rgstr : LowLevel.regpack;
  40. ***** ^ not supported yet
  41. 35 BEGIN
  42. 36 (*ReadOldFile*)
  43. 37 IF BytesToRead <= Numbers.Lc( 0 ) THEN
  44. ***** ^ not supported yet
  45. ***** ^ not supported yet
  46. ***** ^ not supported yet
  47. 38 MemoryPtr.addr.x := NIL;
  48. ***** ^ not supported yet
  49. ***** ^ not supported yet
  50. ***** ^ not supported yet
  51. 39 RETURN;
  52. 40 END;
  53. 41 BytesAvailable := EnvironUtils.MemAvail( 10000);
  54. ***** ^ not supported yet
  55. ***** ^ not supported yet
  56. ***** ^ not supported yet
  57. 42 WITH MemoryPtr DO
  58. ***** ^ not supported yet
  59. 43 IF BytesToRead > Numbers.Lc( BytesAvailable ) THEN
  60. ***** ^ not supported yet
  61. ***** ^ not supported yet
  62. ***** ^ not supported yet
  63. 44 size := BytesAvailable;
  64. ***** ^ not supported yet
  65. ***** ^ incompatible assignment
  66. 45 ELSE
  67. 46 size := Numbers.C( BytesToRead );
  68. ***** ^ not supported yet
  69. ***** ^ not supported yet
  70. ***** ^ not supported yet
  71. ***** ^ not supported yet
  72. 47 END;
  73. 48 VStorage.DosAlloc(addr.a, size);
  74. ***** ^ not supported yet
  75. ***** ^ not supported yet
  76. ***** ^ not supported yet
  77. ***** ^ not supported yet
  78. ***** ^ not supported yet
  79. 49 rgstr.c.x := size;
  80. ***** ^ not supported yet
  81. ***** ^ not supported yet
  82. ***** ^ not supported yet
  83. ***** ^ not supported yet
  84. 50 (*CX gets number of bytes to read.*)
  85. 51 rgstr.a.h := CHR(3FH);
  86. ***** ^ not supported yet
  87. ***** ^ not supported yet
  88. ***** ^ not supported yet
  89. ***** ^ undeclared identifier
  90. ***** ^ not supported yet
  91. 52 (*DOS Read From file Code*)
  92. 53 rgstr.b.x := OldHandle;
  93. ***** ^ not supported yet
  94. ***** ^ not supported yet
  95. ***** ^ not supported yet
  96. 54 rgstr.d.x := addr.off;
  97. ***** ^ not supported yet
  98. ***** ^ not supported yet
  99. ***** ^ not supported yet
  100. ***** ^ not supported yet
  101. ***** ^ not supported yet
  102. 55 rgstr.ds := addr.seg;
  103. ***** ^ not supported yet
  104. ***** ^ not supported yet
  105. ***** ^ not supported yet
  106. ***** ^ not supported yet
  107. 56 END;
  108. ***** ^ not supported yet
  109. 57 LowLevel.msdos(rgstr);
  110. ***** ^ not supported yet
  111. ***** ^ not supported yet
  112. ***** ^ not supported yet
  113. 58 IF LowLevel.FlaggedError(rgstr.flags) THEN
  114. ***** ^ not supported yet
  115. ***** ^ not supported yet
  116. ***** ^ not supported yet
  117. ***** ^ not supported yet
  118. 59 StringIO.PrintMessage(StringIO.MessageType(rgstr.a.l));
  119. ***** ^ not supported yet
  120. ***** ^ not supported yet
  121. ***** ^ not supported yet
  122. ***** ^ not supported yet
  123. ***** ^ not supported yet
  124. ***** ^ not supported yet
  125. ***** ^ not supported yet
  126. 60 ELSE
  127. 61 BytesToRead := BytesToRead - Numbers.Lc( MemoryPtr.size );
  128. ***** ^ not supported yet
  129. ***** ^ not supported yet
  130. ***** ^ not supported yet
  131. ***** ^ not supported yet
  132. 62 (* Can't use DEC here because JPI doesn't allow LONGINTs
  133. 63 to be decremented by CARDINAL values. *)
  134. 64 END;
  135. 65 END ReadOldFile;
  136. ***** ^ not supported yet
  137. 66
  138. 67 PROCEDURE WriteNewFile(MemoryPtr : memptr);
  139. 68 VAR
  140. 69 rgstr : LowLevel.regpack;
  141. ***** ^ not supported yet
  142. 70 BEGIN
  143. 71 (*WriteNewFile*)
  144. 72 IF MemoryPtr.addr.x=NIL THEN
  145. ***** ^ not supported yet
  146. ***** ^ not supported yet
  147. ***** ^ not supported yet
  148. 73 RETURN;
  149. 74 END;
  150. 75 rgstr.b.x := NewHandle;
  151. ***** ^ not supported yet
  152. ***** ^ not supported yet
  153. ***** ^ not supported yet
  154. 76 rgstr.c.x := MemoryPtr.size;
  155. ***** ^ not supported yet
  156. ***** ^ not supported yet
  157. ***** ^ not supported yet
  158. ***** ^ not supported yet
  159. ***** ^ not supported yet
  160. 77 rgstr.ds := MemoryPtr.addr.seg;
  161. ***** ^ not supported yet
  162. ***** ^ not supported yet
  163. ***** ^ not supported yet
  164. ***** ^ not supported yet
  165. ***** ^ not supported yet
  166. 78 rgstr.d.x := MemoryPtr.addr.off;
  167. ***** ^ not supported yet
  168. ***** ^ not supported yet
  169. ***** ^ not supported yet
  170. ***** ^ not supported yet
  171. ***** ^ not supported yet
  172. ***** ^ not supported yet
  173. 79 rgstr.a.h := CHR(40H);
  174. ***** ^ not supported yet
  175. ***** ^ not supported yet
  176. ***** ^ not supported yet
  177. ***** ^ undeclared identifier
  178. ***** ^ not supported yet
  179. 80 (*Write to a file or device.*)
  180. 81 LowLevel.msdos(rgstr);
  181. ***** ^ not supported yet
  182. ***** ^ not supported yet
  183. ***** ^ not supported yet
  184. 82 IF rgstr.a.x<rgstr.c.x THEN
  185. ***** ^ not supported yet
  186. ***** ^ not supported yet
  187. ***** ^ not supported yet
  188. ***** ^ not supported yet
  189. ***** ^ not supported yet
  190. ***** ^ not supported yet
  191. 83 (*if fewer than c.x bytes were actually written*)
  192. 84 SavedMessage := HandleIO.CloseHandle(NewHandle);
  193. ***** ^ not supported yet
  194. ***** ^ not supported yet
  195. ***** ^ not supported yet
  196. 85 StringIO.WriteEol(StringIO.outp, '');
  197. ***** ^ not supported yet
  198. ***** ^ not supported yet
  199. ***** ^ not supported yet
  200. ***** ^ not supported yet
  201. ***** ^ not supported yet
  202. 86 StringIO.WriteStr(StringIO.outp, 'No room.');
  203. ***** ^ not supported yet
  204. ***** ^ not supported yet
  205. ***** ^ not supported yet
  206. ***** ^ not supported yet
  207. ***** ^ not supported yet
  208. 87 HALT();
  209. ***** ^ undeclared identifier
  210. ***** ^ not supported yet
  211. 88 END;
  212. 89 VStorage.DosDealloc(MemoryPtr.addr.x, MemoryPtr.size);
  213. ***** ^ not supported yet
  214. ***** ^ not supported yet
  215. ***** ^ not supported yet
  216. ***** ^ not supported yet
  217. ***** ^ not supported yet
  218. ***** ^ not supported yet
  219. ***** ^ not supported yet
  220. 90 END WriteNewFile;
  221. ***** ^ not supported yet
  222. 91
  223. 92 BEGIN
  224. 93 (*AppendToFile*)
  225. 94 DestSize := Numbers.Lc( 0 );
  226. ***** ^ not supported yet
  227. ***** ^ not supported yet
  228. ***** ^ not supported yet
  229. 95 FileSize := HandleIO.FileLength(OldHandle);
  230. ***** ^ not supported yet
  231. ***** ^ not supported yet
  232. ***** ^ not supported yet
  233. 96 BytesToRead := FileSize;
  234. 97 IF M2Strings.Pos(':',DestFileName)=(1) THEN
  235. ***** ^ not supported yet
  236. ***** ^ not supported yet
  237. ***** ^ not supported yet
  238. 98 TheDrive := DestFileName[0];
  239. ***** ^ not supported yet
  240. ***** ^ not supported yet
  241. 99 ELSE
  242. 100 TheDrive := 'Z';
  243. 101 (*Determines the drive to which we're copying.
  244. 102 'Z' means "default drive" to FreeDiskSpace.*)
  245. 103 END;
  246. 104 SavedMessage := Drectory.FreeDiskSpace(TheDrive,FreeBytes);
  247. ***** ^ not supported yet
  248. ***** ^ not supported yet
  249. ***** ^ not supported yet
  250. 105 IF SavedMessage # StringIO.NoError THEN
  251. ***** ^ not supported yet
  252. ***** ^ not supported yet
  253. 106 RETURN SavedMessage;
  254. 107 END;
  255. 108 SavedMessage := HandleIO.OpenFile(NewHandle,DestFileName);
  256. ***** ^ not supported yet
  257. ***** ^ not supported yet
  258. ***** ^ not supported yet
  259. 109 IF SavedMessage = StringIO.NoError THEN
  260. ***** ^ not supported yet
  261. ***** ^ not supported yet
  262. 110 DestSize := HandleIO.FileLength(NewHandle);
  263. ***** ^ not supported yet
  264. ***** ^ not supported yet
  265. ***** ^ not supported yet
  266. 111 ELSE
  267. 112 RETURN SavedMessage;
  268. 113 END;
  269. 114 IF FileSize > FreeBytes THEN
  270. 115 SavedMessage := StringIO.AccessDenied;
  271. ***** ^ not supported yet
  272. ***** ^ not supported yet
  273. 116 (*This will have to stand for 'Not enough room.'*)
  274. 117 RETURN SavedMessage;
  275. 118 END;
  276. 119 HandleIO.SetFilePtr( NewHandle, HandleIO.FromEnd, NumTypes.L0 );
  277. ***** ^ not supported yet
  278. ***** ^ not supported yet
  279. ***** ^ not supported yet
  280. ***** ^ not supported yet
  281. ***** ^ not supported yet
  282. ***** ^ not supported yet
  283. 120 IF SavedMessage # StringIO.NoError THEN
  284. ***** ^ not supported yet
  285. ***** ^ not supported yet
  286. 121 RETURN SavedMessage;
  287. 122 END;
  288. 123 REPEAT
  289. 124 ReadOldFile(MemoryPtr);
  290. ***** ^ not supported yet
  291. ***** ^ not supported yet
  292. 125 WriteNewFile(MemoryPtr);
  293. ***** ^ not supported yet
  294. ***** ^ not supported yet
  295. 126 UNTIL BytesToRead <= Numbers.Lc( 0 );
  296. ***** ^ not supported yet
  297. ***** ^ not supported yet
  298. ***** ^ not supported yet
  299. 127 RETURN HandleIO.CloseHandle(NewHandle);
  300. ***** ^ not supported yet
  301. ***** ^ not supported yet
  302. ***** ^ not supported yet
  303. 128 END AppendToFile;
  304. ***** ^ not supported yet
  305. 129
  306. 130
  307. 131 VAR
  308. 132 fname1, fname2: ARRAY [0..79] OF CHAR;
  309. ***** ^ not supported yet
  310. ***** ^ not supported yet
  311. 133 OldHandle : CARDINAL;
  312. 134
  313. 135 BEGIN
  314. 136 IF NOT EnvironUtils.ParsedParam( 1, fname1 ) THEN
  315. ***** ^ not supported yet
  316. ***** ^ not supported yet
  317. ***** ^ not supported yet
  318. 137 StringIO.WriteStr( StringIO.outp, 'Dest file: ' );
  319. ***** ^ not supported yet
  320. ***** ^ not supported yet
  321. ***** ^ not supported yet
  322. ***** ^ not supported yet
  323. ***** ^ not supported yet
  324. 138 StringIO.ReadStr( StringIO.inp, fname1 );
  325. ***** ^ not supported yet
  326. ***** ^ not supported yet
  327. ***** ^ not supported yet
  328. ***** ^ not supported yet
  329. ***** ^ not supported yet
  330. 139 END;
  331. 140 IF NOT EnvironUtils.ParsedParam( 2, fname2 ) THEN
  332. ***** ^ not supported yet
  333. ***** ^ not supported yet
  334. ***** ^ not supported yet
  335. 141 StringIO.WriteStr( StringIO.outp, 'Srce file: ' );
  336. ***** ^ not supported yet
  337. ***** ^ not supported yet
  338. ***** ^ not supported yet
  339. ***** ^ not supported yet
  340. ***** ^ not supported yet
  341. 142 StringIO.ReadStr( StringIO.inp, fname2 );
  342. ***** ^ not supported yet
  343. ***** ^ not supported yet
  344. ***** ^ not supported yet
  345. ***** ^ not supported yet
  346. ***** ^ not supported yet
  347. 143 END;
  348. 144 IF HandleIO.OpenFile( OldHandle, fname2 ) = StringIO.NoError THEN
  349. ***** ^ not supported yet
  350. ***** ^ not supported yet
  351. ***** ^ not supported yet
  352. ***** ^ not supported yet
  353. ***** ^ not supported yet
  354. 145 IF AppendToFile( OldHandle, fname1 ) = StringIO.NoError THEN
  355. ***** ^ not supported yet
  356. ***** ^ not supported yet
  357. ***** ^ not supported yet
  358. ***** ^ not supported yet
  359. 146 IF HandleIO.CloseHandle( OldHandle ) = StringIO.NoError THEN
  360. ***** ^ not supported yet
  361. ***** ^ not supported yet
  362. ***** ^ not supported yet
  363. ***** ^ not supported yet
  364. ***** ^ not supported yet
  365. 147 StringIO.PrintMessage( Drectory.DeleteFile( fname2 ) );
  366. ***** ^ not supported yet
  367. ***** ^ not supported yet
  368. ***** ^ not supported yet
  369. ***** ^ not supported yet
  370. ***** ^ not supported yet
  371. 148 END;
  372. 149 ELSE
  373. 150 StringIO.WriteStr( StringIO.outp, 'Could not append to ' );
  374. ***** ^ not supported yet
  375. ***** ^ not supported yet
  376. ***** ^ not supported yet
  377. ***** ^ not supported yet
  378. ***** ^ not supported yet
  379. 151 StringIO.WriteStr( StringIO.outp, fname1 );
  380. ***** ^ not supported yet
  381. ***** ^ not supported yet
  382. ***** ^ not supported yet
  383. ***** ^ not supported yet
  384. ***** ^ not supported yet
  385. 152 END;
  386. 153 ELSE
  387. 154 StringIO.WriteStr( StringIO.outp, fname2 );
  388. ***** ^ not supported yet
  389. ***** ^ not supported yet
  390. ***** ^ not supported yet
  391. ***** ^ not supported yet
  392. ***** ^ not supported yet
  393. 155 StringIO.WriteStr( StringIO.outp, ' not found.' );
  394. ***** ^ not supported yet
  395. ***** ^ not supported yet
  396. ***** ^ not supported yet
  397. ***** ^ not supported yet
  398. ***** ^ not supported yet
  399. 156 END;
  400. 157 END Append.
  401. 242 errors