home *** CD-ROM | disk | FTP | other *** search
/ Source Code 1992 March / Source_Code_CD-ROM_Walnut_Creek_March_1992.iso / usenet / compsrcs / apple2 / 49 < prev    next >
Encoding:
Internet Message Format  |  1991-05-02  |  11.5 KB

  1. From: jac@yoko.rutgers.edu (Jonathan A. Chandross)
  2. Newsgroups: comp.sources.apple2
  3. Subject: v001SRC031:  AAF Tools in Basic
  4. Message-ID: <May.1.17.34.10.1991.22983@yoko.rutgers.edu>
  5. Date: 1 May 91 21:34:12 GMT
  6. Approved: jac@paul.rutgers.edu
  7.  
  8.  
  9. Submitted-by: Andy Tefft (ART100@psuvm.psu.edu)
  10. Posting-number: Volume 1, Source:31
  11. Archive-name: archive/aaf_basic
  12. Architecture: ANY_2
  13. Version-number: 1.00
  14.  
  15. The AAF (Apple Archive Format) tools implemented in Basic, for those of
  16. you lacking a C compiler.
  17.  
  18. Enjoy.
  19.  
  20. =paaf.doc
  21. -
  22. -Andy Tefft
  23. -ART100@psuvm.psu.edu
  24. -99 E. Main St.
  25. -North East, PA 16428
  26. -
  27. -paaf.bas
  28. -Version 1.00
  29. -
  30. -Features of this version:
  31. -
  32. -- lets you change the filename that it writes into the file
  33. -  if you desire (for the = line)
  34. -- if you try and write a line > 79 columns (which would be truncated
  35. -  by mailers) you are warned, but the line is written as-is anyway.
  36. -
  37. -You can choose to create a new archive or append to an existing
  38. -one. The only real difference is if you choose "new" the archive
  39. -is deleted if it exists already. It is ok to use "append" on
  40. -a new file.
  41. -
  42. =paaf.bas
  43. - 1  ONERR  GOTO 2000
  44. - 4  LOMEM: 16384
  45. - 5 IN$ = "X": REM  must be first string assigned
  46. - 10  TEXT : HOME
  47. - 15  PRINT "AAF Packer, v1.0"
  48. - 20  PRINT : PRINT "By Andy Tefft (art100@psuvm.psu.edu)"
  49. - 25  PRINT : PRINT "Freeware. Use with appropriate caution."
  50. - 30  PRINT : PRINT "Notes:"
  51. - 40  PRINT : PRINT "1) 'Pathname' means any valid ProDOS'
  52. - 45  PRINT "   full or partial pathname."
  53. - 46  PRINT
  54. - 50  PRINT "2) Pressing RETURN at the input/output"
  55. - 55  PRINT "   file prompts returns you to the menu"
  56. - 60  PRINT : PRINT "3) Both input and output volumes must"
  57. - 65  PRINT "   be online."
  58. - 70  PRINT : PRINT "4) Looks best in 40 columns."
  59. - 75  PRINT : PRINT "5) You will be warned when adding lines"
  60. - 76  PRINT "   longer than 79 columns."
  61. - 80  PRINT : PRINT "Press a key to continue"
  62. - 90  GET A$
  63. - 120  FOR R = 768 TO 788: READ X: POKE R,X: NEXT : REM input-anything
  64. - 130  DATA 162,0,32,117,253,160,2,138,145,105,200,169,0,145,105,200
  65. - 135  DATA  169,2,145,105,96
  66. - 140 D$ =  CHR$ (4)
  67. - 145  DIM OU$(100)
  68. - 150  PRINT D$"prefix": INPUT PR$
  69. - 160  TEXT : HOME
  70. - 165  PRINT "AAF Packer v1.0   Andy Tefft   11/23/90"
  71. - 170  PRINT : PRINT "Prefix: "PR$
  72. - 171  PRINT "---------------------------------------"
  73. - 172  POKE 34,5
  74. - 175  PRINT : PRINT "Menu:"
  75. - 176  POKE 32,5
  76. - 180  PRINT : PRINT "P)refix": PRINT "C)atalog"
  77. - 181  PRINT
  78. - 185  PRINT "A)ppend to an archive"
  79. - 190  PRINT "N)ew archive"
  80. - 195  PRINT : PRINT "E)xit"
  81. - 199  POKE 32,0
  82. - 200  VTAB 18: GET C$
  83. - 210  IF C$ = "e" OR C$ = "E" THEN  END
  84. - 220  IF C$ <  > "C" AND C$ <  > "c" THEN  GOTO 300
  85. - 230  INPUT "Directory to catalog, return for prefix:";C$
  86. - 240 S = 1: REM  section for error check
  87. - 250  PRINT D$"cat"C$
  88. - 260  PRINT "Press a key to return to menu.";: GET A$
  89. - 270  HOME : GOTO 175
  90. - 300  IF C$ <  > "P" AND C$ <  > "p" THEN 400
  91. - 310 S = 2: REM  for error checking
  92. - 320  PRINT : INPUT "New prefix: ";C$
  93. - 325  PRINT D$"prefix"C$
  94. - 330  GOTO 150
  95. - 400  IF C$ = "A" OR C$ = "a" OR C$ = "N" OR C$ = "n" THEN 410
  96. - 405  HOME : GOTO 175
  97. - 410  IF C$ = "N" OR C$ = "n" THEN NF = 1: REM  new file
  98. - 420  PRINT "Archive pathname (return for menu)": INPUT ": ";OF$
  99. - 425  IF OF$ = "" THEN  HOME : GOTO 175
  100. - 430 S = 3: REM  section for errors
  101. - 440  PRINT D$"open"OF$: PRINT D$"close"OF$
  102. - 450  IF NF THEN  PRINT D$"delete"OF$
  103. - 460  INPUT "Pathname of file to add to archive?     : ";I$
  104. - 465  IF I$ = "" THEN  HOME : GOTO 175
  105. - 470 S = 4
  106. - 471  PRINT D$"verify"I$
  107. - 475  PRINT : PRINT "Filename to put in archive? (return for"
  108. - 476  PRINT I$;: INPUT " : ";FF$
  109. - 477  IF FF$ = "" THEN FF$ = I$
  110. - 482  PRINT D$"open"OF$
  111. - 483  PRINT D$"append"OF$
  112. - 484  PRINT D$"write"OF$
  113. - 485  PRINT "= "FF$
  114. - 488  PRINT D$
  115. - 490  PRINT D$"open"I$
  116. - 500  PRINT D$"read"I$
  117. - 505 S = 5
  118. - 510  FOR L = 1 TO 100
  119. - 520  CALL 768:IN$ =  MID$ (IN$,1)
  120. - 525  VTAB  PEEK (37)
  121. - 530  IF  LEN (IN$) < 80 THEN 550
  122. - 540  PRINT : PRINT ">>> Warning: Line too long:"
  123. - 541  PRINT : PRINT IN$
  124. - 545  PRINT
  125. - 550 OU$(L) = "-" + IN$
  126. - 560  NEXT
  127. - 570  PRINT D$
  128. - 580  PRINT D$"write"OF$
  129. - 590  FOR L = 1 TO 100
  130. - 600  PRINT OU$(L): NEXT
  131. - 610  PRINT D$
  132. - 620  GOTO 500
  133. - 700  PRINT D$"write"OF$
  134. - 710  FOR LL = 1 TO L - 1
  135. - 720  PRINT OU$(LL): NEXT
  136. - 725  PRINT "+ End of file "FF$
  137. - 730  PRINT D$"close"
  138. - 740  PRINT ">>> Finished. Hit a key for menu."
  139. - 745  GET A$
  140. - 750  GOTO 150
  141. - 1999  END
  142. - 2000 Y =  PEEK (222)
  143. - 2010  PRINT
  144. - 2020  IF Y = 5 AND S = 5 THEN 700
  145. - 2030  IF Y = 6 AND S = 2 THEN 2100
  146. - 2035  IF Y = 6 AND S = 1 THEN 2200
  147. - 2040  IF Y = 6 AND S = 3 THEN 2300
  148. - 2050  IF Y = 6 AND S = 4 THEN 2400
  149. - 2055  PRINT D$"close"
  150. - 2060  PRINT ">>> Error #"Y: END
  151. - 2100  PRINT : PRINT ">>> Error: Volume/dir not found."
  152. - 2105  PRINT
  153. - 2110  GOTO 320
  154. - 2200  PRINT : PRINT ">>> Error: Volume/dir not found."
  155. - 2205  PRINT
  156. - 2210  GOTO 230
  157. - 2300  PRINT ">>> Error: File/directory not found."
  158. - 2310  PRINT : PRINT "Insert disk if necessary, then hit"
  159. - 2320  PRINT "return to continue, ? for catalog"
  160. - 2330  INPUT C$: IF C$ = "" THEN 420
  161. - 2340  INPUT "Pathname? (return for current prefix)   : ";C$
  162. - 2350  PRINT D$"cat"C$
  163. - 2360  PRINT "Hit a key.": GET A$: PRINT : GOTO 420
  164. - 2400  PRINT ">>> Error: input file not found."
  165. - 2410  PRINT "Hit return to try again, ? for catalog"
  166. - 2420  INPUT ": ";C$
  167. - 2430  IF C$ = "" THEN 460
  168. - 2440  INPUT "Pathname? (return for current prefix)   : ";C$
  169. - 2450  PRINT D$"cat"C$
  170. - 2460  PRINT "Hit a key.": GET A$: PRINT : GOTO 460
  171. -
  172. =upaaf.doc
  173. -
  174. -Andy Tefft
  175. -ART100@psuvm.psu.edu
  176. -99 E. Main St.
  177. -North East, PA 16428
  178. -
  179. -upaaf.bas
  180. -Version 1.00
  181. -
  182. -This should be exec'ed under basic.system and then saved
  183. -as aaf.unpacker.
  184. -
  185. -Some notes that may/may not be mentioned in the program itself:
  186. -
  187. -- it handles multiple files in one posting (of course)
  188. -- it echoes lines to the screen that are before the first =
  189. -  and after the last + (this isn't specified in the specs)
  190. -- it attempts to detect whether the last file in the archive
  191. -  was closed with a + line, and issues a warning if it's not.
  192. -  it does not however check for a new = line occurring before a
  193. -  + line. If this mistake exists in the file, the = line will
  194. -  simply be echoed.
  195. -- Because it's not easy to edit the archive on an apple //,
  196. -  it will prompt for an output file name (default can of
  197. -  course be used)
  198. -- "pathname" means any valid prodos pathname, with or without
  199. -  a leading volume/directory name. The prefix is shown and
  200. -  prepended to any filenames without a leading slash (by prodos,
  201. -  not my program). Use of an invalid pathname will generate
  202. -  cryptic errors
  203. -- control-c will exit the program at any time, and will display
  204. -  error #255 and close all files. Because the program builds
  205. -  up a list of the last 100 output lines to write to the file,
  206. -  up to the last 100 lines will not be written to the output
  207. -  file if you interrupt the program. Same for a disk full
  208. -  error.
  209. -- both input and output volumes must be online at the same time.
  210. -  I had planned on allowing volume switches (that's why I buffer
  211. -  100 output lines at a time), but I won't unless someone requests
  212. -  it.
  213. -- Output is formatted for 40 columns, but 80 columns can be
  214. -  used if desired (this makes in-file comments easier to read).
  215. -  80/40 columns should be selected by the user before running
  216. -  the program.
  217. -- ">>>" prefixes messages from the program (except prompts)
  218. -  to distinguish them from in-file comments
  219. -- input anything routine is (I think) from an old dos 3.3
  220. -  public domain disk I found. It allows , and : in input lines.
  221. -  Examine the program for usage.
  222. -
  223. =upaaf.bas
  224. - 4  LOMEM: 16384
  225. - 5 IN$ = "X": REM  must be first string assigned
  226. - 10  TEXT : HOME
  227. - 20  PRINT "AAF Unpacker, v1.0"
  228. - 22  PRINT : PRINT "by Andy Tefft  (art100@psuvm.psu.edu)"
  229. - 24  PRINT : PRINT "This program is freeware. Do what you"
  230. - 25  PRINT "want with it, but don't blame me if you"
  231. - 26  PRINT "break it."
  232. - 28  PRINT : PRINT "Notes (list program for more):"
  233. - 30  PRINT : PRINT "1) When asked for a pathname, use"
  234. - 32  PRINT "   a full or partial pathname."
  235. - 34  PRINT : PRINT "2) Type 'PR#3' before running to use"
  236. - 36  PRINT "   80 columns."
  237. - 38  PRINT : PRINT "3) Only minimal error checking is done."
  238. - 40  PRINT : PRINT "4) Input and output volumes must both"
  239. - 42  PRINT "be online."
  240. - 44  PRINT : PRINT "Press a key to continue"
  241. - 45  GET A$
  242. - 50  REM  ARCHIVE FORMAT:
  243. - 55  REM
  244. - 60  REM  = filename : denotes output file name
  245. - 70  REM  - line     : line of output file
  246. - 80  REM  + anything : end of file ("anything" ignored")
  247. - 85  REM
  248. - 86  REM  all other lines echoed to screen
  249. - 87  REM
  250. - 90  REM  because of the difficulty of editing text files
  251. - 91  REM  on the apple //, this program prompts for output
  252. - 92  REM  file names, so you can change them if desired.
  253. - 93  REM
  254. - 94  REM  input anything routine is from an old dos 3.3
  255. - 95  REM  public-domain disk
  256. - 96  REM
  257. - 120  FOR R = 768 TO 788: READ X: POKE R,X: NEXT : REM input-anything
  258. - 130  DATA 162,0,32,117,253,160,2,138,145,105,200,169,0,145,105,200
  259. - 135  DATA  169,2,145,105,96
  260. - 140 D$ =  CHR$ (4)
  261. - 145  DIM OU$(100)
  262. - 150  PRINT D$"prefix": INPUT PR$
  263. - 160  TEXT : HOME
  264. - 165  PRINT "AAF Unpacker v1.0  Andy Tefft  11/21/90"
  265. - 170  PRINT : PRINT "Prefix: "PR$
  266. - 175  PRINT : PRINT "Enter archive pathname, ? for catalog,"
  267. - 176  PRINT "/ to change prefix, return to exit."
  268. - 180  POKE 34,7
  269. - 190  PRINT
  270. - 199  ONERR  GOTO 2000
  271. - 200  INPUT ": ";C$
  272. - 205  IF C$ = "" THEN  END
  273. - 210  IF C$ <  > "/" THEN 300
  274. - 220  PRINT : INPUT "New prefix:";P$
  275. - 230  PRINT D$"Prefix"P$
  276. - 240  GOTO 150
  277. - 300  IF C$ <  > "?" THEN 400
  278. - 310  PRINT D$"cat"
  279. - 320  GOTO 190
  280. - 400  PRINT : PRINT ">>> Opening "C$" for input."
  281. - 405  POKE 34,4:II = 1
  282. - 406  PRINT D$"verify"C$
  283. - 407 II = 0
  284. - 410  PRINT D$"open"C$
  285. - 415 IL = 0
  286. - 420  PRINT D$"read"C$
  287. - 430  CALL 768:IN$ =  MID$ (IN$,1)
  288. - 440  IF  LEFT$ (IN$,1) = "=" THEN 450
  289. - 445  PRINT IN$: GOTO 430
  290. - 450 OU$ =  MID$ (IN$,2)
  291. - 455  PRINT ">>> ";
  292. - 460  PRINT "Opening "OU$" for output."
  293. - 465  PRINT D$: REM  stop taking input from file
  294. - 470  PRINT "Press return to use this, enter a new"
  295. - 472  PRINT "pathname for output, ? for catalog"
  296. - 475  INPUT ": ";CC$
  297. - 476  IF CC$ <  > "?" THEN 480
  298. - 477  PRINT "Path to catalog, return for current dir"
  299. - 478  INPUT P$: PRINT D$"CAT"P$: GOTO 460
  300. - 480  IF CC$ <  > "" THEN OU$ = CC$
  301. - 485 OO = 1
  302. - 490  PRINT D$"open"OU$: PRINT D$"close"OU$: PRINT D$"delete"OU$
  303. - 491 OO = 0
  304. - 495  PRINT D$"read"C$
  305. - 500 OL = 0
  306. - 505 FI = 1: REM  means we've started a file
  307. - 510  CALL 768:IN$ =  MID$ (IN$,1)
  308. - 520  IF  LEFT$ (IN$,1) = "-" THEN 530
  309. - 521  IF  LEFT$ (IN$,1) = "+" THEN 1000
  310. - 525  PRINT IN$: GOTO 510
  311. - 530 OL = OL + 1
  312. - 535  VTAB  PEEK (37)
  313. - 540 OU$(OL) =  MID$ (IN$,2)
  314. - 550  IF OL < 100 GOTO 510
  315. - 560  REM   write 100 lines of output file
  316. - 570  PRINT D$"open"OU$
  317. - 580  PRINT D$"append"OU$
  318. - 590  PRINT D$"write"OU$
  319. - 600  FOR R = 1 TO 100
  320. - 610  PRINT OU$(R)
  321. - 620  NEXT
  322. - 630  PRINT D$"close"OU$
  323. - 640  GOTO 495
  324. - 1000  PRINT D$"open"OU$
  325. - 1010  PRINT D$"append"OU$
  326. - 1020  PRINT D$"write"OU$
  327. - 1030  FOR R = 1 TO OL
  328. - 1040  PRINT OU$(R): NEXT
  329. - 1050  PRINT D$"close"OU$
  330. - 1060  PRINT : PRINT ">>> Finished "OU$
  331. - 1065 FI = 0
  332. - 1070  GOTO 420
  333. - 1999  END
  334. - 2000 Y =  PEEK (222)
  335. - 2001  PRINT
  336. - 2005  IF Y = 6 THEN 2100
  337. - 2010  IF Y = 5 THEN 2020
  338. - 2015  PRINT "Error #"Y: PRINT D$"close": END
  339. - 2020  PRINT D$"close": PRINT ">>> End of file encountered."
  340. - 2030  IF FI = 1 THEN  PRINT ">>> "OU$" may be incomplete."
  341. - 2040  IF FI = 1 THEN  PRINT "(no end of file marker found)"
  342. - 2050  TEXT
  343. - 2060  END
  344. - 2100  IF OO = 1 THEN  PRINT "Volume/directory not found.": GOTO 455
  345. - 2110  IF II = 1 THEN  PRINT "Input file not found.": GOTO 175
  346. -
  347. + END OF ARCHIVE
  348.