home *** CD-ROM | disk | FTP | other *** search
- From: jac@yoko.rutgers.edu (Jonathan A. Chandross)
- Newsgroups: comp.sources.apple2
- Subject: v001SRC031: AAF Tools in Basic
- Message-ID: <May.1.17.34.10.1991.22983@yoko.rutgers.edu>
- Date: 1 May 91 21:34:12 GMT
- Approved: jac@paul.rutgers.edu
-
-
- Submitted-by: Andy Tefft (ART100@psuvm.psu.edu)
- Posting-number: Volume 1, Source:31
- Archive-name: archive/aaf_basic
- Architecture: ANY_2
- Version-number: 1.00
-
- The AAF (Apple Archive Format) tools implemented in Basic, for those of
- you lacking a C compiler.
-
- Enjoy.
-
- =paaf.doc
- -
- -Andy Tefft
- -ART100@psuvm.psu.edu
- -99 E. Main St.
- -North East, PA 16428
- -
- -paaf.bas
- -Version 1.00
- -
- -Features of this version:
- -
- -- lets you change the filename that it writes into the file
- - if you desire (for the = line)
- -- if you try and write a line > 79 columns (which would be truncated
- - by mailers) you are warned, but the line is written as-is anyway.
- -
- -You can choose to create a new archive or append to an existing
- -one. The only real difference is if you choose "new" the archive
- -is deleted if it exists already. It is ok to use "append" on
- -a new file.
- -
- =paaf.bas
- - 1 ONERR GOTO 2000
- - 4 LOMEM: 16384
- - 5 IN$ = "X": REM must be first string assigned
- - 10 TEXT : HOME
- - 15 PRINT "AAF Packer, v1.0"
- - 20 PRINT : PRINT "By Andy Tefft (art100@psuvm.psu.edu)"
- - 25 PRINT : PRINT "Freeware. Use with appropriate caution."
- - 30 PRINT : PRINT "Notes:"
- - 40 PRINT : PRINT "1) 'Pathname' means any valid ProDOS'
- - 45 PRINT " full or partial pathname."
- - 46 PRINT
- - 50 PRINT "2) Pressing RETURN at the input/output"
- - 55 PRINT " file prompts returns you to the menu"
- - 60 PRINT : PRINT "3) Both input and output volumes must"
- - 65 PRINT " be online."
- - 70 PRINT : PRINT "4) Looks best in 40 columns."
- - 75 PRINT : PRINT "5) You will be warned when adding lines"
- - 76 PRINT " longer than 79 columns."
- - 80 PRINT : PRINT "Press a key to continue"
- - 90 GET A$
- - 120 FOR R = 768 TO 788: READ X: POKE R,X: NEXT : REM input-anything
- - 130 DATA 162,0,32,117,253,160,2,138,145,105,200,169,0,145,105,200
- - 135 DATA 169,2,145,105,96
- - 140 D$ = CHR$ (4)
- - 145 DIM OU$(100)
- - 150 PRINT D$"prefix": INPUT PR$
- - 160 TEXT : HOME
- - 165 PRINT "AAF Packer v1.0 Andy Tefft 11/23/90"
- - 170 PRINT : PRINT "Prefix: "PR$
- - 171 PRINT "---------------------------------------"
- - 172 POKE 34,5
- - 175 PRINT : PRINT "Menu:"
- - 176 POKE 32,5
- - 180 PRINT : PRINT "P)refix": PRINT "C)atalog"
- - 181 PRINT
- - 185 PRINT "A)ppend to an archive"
- - 190 PRINT "N)ew archive"
- - 195 PRINT : PRINT "E)xit"
- - 199 POKE 32,0
- - 200 VTAB 18: GET C$
- - 210 IF C$ = "e" OR C$ = "E" THEN END
- - 220 IF C$ < > "C" AND C$ < > "c" THEN GOTO 300
- - 230 INPUT "Directory to catalog, return for prefix:";C$
- - 240 S = 1: REM section for error check
- - 250 PRINT D$"cat"C$
- - 260 PRINT "Press a key to return to menu.";: GET A$
- - 270 HOME : GOTO 175
- - 300 IF C$ < > "P" AND C$ < > "p" THEN 400
- - 310 S = 2: REM for error checking
- - 320 PRINT : INPUT "New prefix: ";C$
- - 325 PRINT D$"prefix"C$
- - 330 GOTO 150
- - 400 IF C$ = "A" OR C$ = "a" OR C$ = "N" OR C$ = "n" THEN 410
- - 405 HOME : GOTO 175
- - 410 IF C$ = "N" OR C$ = "n" THEN NF = 1: REM new file
- - 420 PRINT "Archive pathname (return for menu)": INPUT ": ";OF$
- - 425 IF OF$ = "" THEN HOME : GOTO 175
- - 430 S = 3: REM section for errors
- - 440 PRINT D$"open"OF$: PRINT D$"close"OF$
- - 450 IF NF THEN PRINT D$"delete"OF$
- - 460 INPUT "Pathname of file to add to archive? : ";I$
- - 465 IF I$ = "" THEN HOME : GOTO 175
- - 470 S = 4
- - 471 PRINT D$"verify"I$
- - 475 PRINT : PRINT "Filename to put in archive? (return for"
- - 476 PRINT I$;: INPUT " : ";FF$
- - 477 IF FF$ = "" THEN FF$ = I$
- - 482 PRINT D$"open"OF$
- - 483 PRINT D$"append"OF$
- - 484 PRINT D$"write"OF$
- - 485 PRINT "= "FF$
- - 488 PRINT D$
- - 490 PRINT D$"open"I$
- - 500 PRINT D$"read"I$
- - 505 S = 5
- - 510 FOR L = 1 TO 100
- - 520 CALL 768:IN$ = MID$ (IN$,1)
- - 525 VTAB PEEK (37)
- - 530 IF LEN (IN$) < 80 THEN 550
- - 540 PRINT : PRINT ">>> Warning: Line too long:"
- - 541 PRINT : PRINT IN$
- - 545 PRINT
- - 550 OU$(L) = "-" + IN$
- - 560 NEXT
- - 570 PRINT D$
- - 580 PRINT D$"write"OF$
- - 590 FOR L = 1 TO 100
- - 600 PRINT OU$(L): NEXT
- - 610 PRINT D$
- - 620 GOTO 500
- - 700 PRINT D$"write"OF$
- - 710 FOR LL = 1 TO L - 1
- - 720 PRINT OU$(LL): NEXT
- - 725 PRINT "+ End of file "FF$
- - 730 PRINT D$"close"
- - 740 PRINT ">>> Finished. Hit a key for menu."
- - 745 GET A$
- - 750 GOTO 150
- - 1999 END
- - 2000 Y = PEEK (222)
- - 2010 PRINT
- - 2020 IF Y = 5 AND S = 5 THEN 700
- - 2030 IF Y = 6 AND S = 2 THEN 2100
- - 2035 IF Y = 6 AND S = 1 THEN 2200
- - 2040 IF Y = 6 AND S = 3 THEN 2300
- - 2050 IF Y = 6 AND S = 4 THEN 2400
- - 2055 PRINT D$"close"
- - 2060 PRINT ">>> Error #"Y: END
- - 2100 PRINT : PRINT ">>> Error: Volume/dir not found."
- - 2105 PRINT
- - 2110 GOTO 320
- - 2200 PRINT : PRINT ">>> Error: Volume/dir not found."
- - 2205 PRINT
- - 2210 GOTO 230
- - 2300 PRINT ">>> Error: File/directory not found."
- - 2310 PRINT : PRINT "Insert disk if necessary, then hit"
- - 2320 PRINT "return to continue, ? for catalog"
- - 2330 INPUT C$: IF C$ = "" THEN 420
- - 2340 INPUT "Pathname? (return for current prefix) : ";C$
- - 2350 PRINT D$"cat"C$
- - 2360 PRINT "Hit a key.": GET A$: PRINT : GOTO 420
- - 2400 PRINT ">>> Error: input file not found."
- - 2410 PRINT "Hit return to try again, ? for catalog"
- - 2420 INPUT ": ";C$
- - 2430 IF C$ = "" THEN 460
- - 2440 INPUT "Pathname? (return for current prefix) : ";C$
- - 2450 PRINT D$"cat"C$
- - 2460 PRINT "Hit a key.": GET A$: PRINT : GOTO 460
- -
- =upaaf.doc
- -
- -Andy Tefft
- -ART100@psuvm.psu.edu
- -99 E. Main St.
- -North East, PA 16428
- -
- -upaaf.bas
- -Version 1.00
- -
- -This should be exec'ed under basic.system and then saved
- -as aaf.unpacker.
- -
- -Some notes that may/may not be mentioned in the program itself:
- -
- -- it handles multiple files in one posting (of course)
- -- it echoes lines to the screen that are before the first =
- - and after the last + (this isn't specified in the specs)
- -- it attempts to detect whether the last file in the archive
- - was closed with a + line, and issues a warning if it's not.
- - it does not however check for a new = line occurring before a
- - + line. If this mistake exists in the file, the = line will
- - simply be echoed.
- -- Because it's not easy to edit the archive on an apple //,
- - it will prompt for an output file name (default can of
- - course be used)
- -- "pathname" means any valid prodos pathname, with or without
- - a leading volume/directory name. The prefix is shown and
- - prepended to any filenames without a leading slash (by prodos,
- - not my program). Use of an invalid pathname will generate
- - cryptic errors
- -- control-c will exit the program at any time, and will display
- - error #255 and close all files. Because the program builds
- - up a list of the last 100 output lines to write to the file,
- - up to the last 100 lines will not be written to the output
- - file if you interrupt the program. Same for a disk full
- - error.
- -- both input and output volumes must be online at the same time.
- - I had planned on allowing volume switches (that's why I buffer
- - 100 output lines at a time), but I won't unless someone requests
- - it.
- -- Output is formatted for 40 columns, but 80 columns can be
- - used if desired (this makes in-file comments easier to read).
- - 80/40 columns should be selected by the user before running
- - the program.
- -- ">>>" prefixes messages from the program (except prompts)
- - to distinguish them from in-file comments
- -- input anything routine is (I think) from an old dos 3.3
- - public domain disk I found. It allows , and : in input lines.
- - Examine the program for usage.
- -
- =upaaf.bas
- - 4 LOMEM: 16384
- - 5 IN$ = "X": REM must be first string assigned
- - 10 TEXT : HOME
- - 20 PRINT "AAF Unpacker, v1.0"
- - 22 PRINT : PRINT "by Andy Tefft (art100@psuvm.psu.edu)"
- - 24 PRINT : PRINT "This program is freeware. Do what you"
- - 25 PRINT "want with it, but don't blame me if you"
- - 26 PRINT "break it."
- - 28 PRINT : PRINT "Notes (list program for more):"
- - 30 PRINT : PRINT "1) When asked for a pathname, use"
- - 32 PRINT " a full or partial pathname."
- - 34 PRINT : PRINT "2) Type 'PR#3' before running to use"
- - 36 PRINT " 80 columns."
- - 38 PRINT : PRINT "3) Only minimal error checking is done."
- - 40 PRINT : PRINT "4) Input and output volumes must both"
- - 42 PRINT "be online."
- - 44 PRINT : PRINT "Press a key to continue"
- - 45 GET A$
- - 50 REM ARCHIVE FORMAT:
- - 55 REM
- - 60 REM = filename : denotes output file name
- - 70 REM - line : line of output file
- - 80 REM + anything : end of file ("anything" ignored")
- - 85 REM
- - 86 REM all other lines echoed to screen
- - 87 REM
- - 90 REM because of the difficulty of editing text files
- - 91 REM on the apple //, this program prompts for output
- - 92 REM file names, so you can change them if desired.
- - 93 REM
- - 94 REM input anything routine is from an old dos 3.3
- - 95 REM public-domain disk
- - 96 REM
- - 120 FOR R = 768 TO 788: READ X: POKE R,X: NEXT : REM input-anything
- - 130 DATA 162,0,32,117,253,160,2,138,145,105,200,169,0,145,105,200
- - 135 DATA 169,2,145,105,96
- - 140 D$ = CHR$ (4)
- - 145 DIM OU$(100)
- - 150 PRINT D$"prefix": INPUT PR$
- - 160 TEXT : HOME
- - 165 PRINT "AAF Unpacker v1.0 Andy Tefft 11/21/90"
- - 170 PRINT : PRINT "Prefix: "PR$
- - 175 PRINT : PRINT "Enter archive pathname, ? for catalog,"
- - 176 PRINT "/ to change prefix, return to exit."
- - 180 POKE 34,7
- - 190 PRINT
- - 199 ONERR GOTO 2000
- - 200 INPUT ": ";C$
- - 205 IF C$ = "" THEN END
- - 210 IF C$ < > "/" THEN 300
- - 220 PRINT : INPUT "New prefix:";P$
- - 230 PRINT D$"Prefix"P$
- - 240 GOTO 150
- - 300 IF C$ < > "?" THEN 400
- - 310 PRINT D$"cat"
- - 320 GOTO 190
- - 400 PRINT : PRINT ">>> Opening "C$" for input."
- - 405 POKE 34,4:II = 1
- - 406 PRINT D$"verify"C$
- - 407 II = 0
- - 410 PRINT D$"open"C$
- - 415 IL = 0
- - 420 PRINT D$"read"C$
- - 430 CALL 768:IN$ = MID$ (IN$,1)
- - 440 IF LEFT$ (IN$,1) = "=" THEN 450
- - 445 PRINT IN$: GOTO 430
- - 450 OU$ = MID$ (IN$,2)
- - 455 PRINT ">>> ";
- - 460 PRINT "Opening "OU$" for output."
- - 465 PRINT D$: REM stop taking input from file
- - 470 PRINT "Press return to use this, enter a new"
- - 472 PRINT "pathname for output, ? for catalog"
- - 475 INPUT ": ";CC$
- - 476 IF CC$ < > "?" THEN 480
- - 477 PRINT "Path to catalog, return for current dir"
- - 478 INPUT P$: PRINT D$"CAT"P$: GOTO 460
- - 480 IF CC$ < > "" THEN OU$ = CC$
- - 485 OO = 1
- - 490 PRINT D$"open"OU$: PRINT D$"close"OU$: PRINT D$"delete"OU$
- - 491 OO = 0
- - 495 PRINT D$"read"C$
- - 500 OL = 0
- - 505 FI = 1: REM means we've started a file
- - 510 CALL 768:IN$ = MID$ (IN$,1)
- - 520 IF LEFT$ (IN$,1) = "-" THEN 530
- - 521 IF LEFT$ (IN$,1) = "+" THEN 1000
- - 525 PRINT IN$: GOTO 510
- - 530 OL = OL + 1
- - 535 VTAB PEEK (37)
- - 540 OU$(OL) = MID$ (IN$,2)
- - 550 IF OL < 100 GOTO 510
- - 560 REM write 100 lines of output file
- - 570 PRINT D$"open"OU$
- - 580 PRINT D$"append"OU$
- - 590 PRINT D$"write"OU$
- - 600 FOR R = 1 TO 100
- - 610 PRINT OU$(R)
- - 620 NEXT
- - 630 PRINT D$"close"OU$
- - 640 GOTO 495
- - 1000 PRINT D$"open"OU$
- - 1010 PRINT D$"append"OU$
- - 1020 PRINT D$"write"OU$
- - 1030 FOR R = 1 TO OL
- - 1040 PRINT OU$(R): NEXT
- - 1050 PRINT D$"close"OU$
- - 1060 PRINT : PRINT ">>> Finished "OU$
- - 1065 FI = 0
- - 1070 GOTO 420
- - 1999 END
- - 2000 Y = PEEK (222)
- - 2001 PRINT
- - 2005 IF Y = 6 THEN 2100
- - 2010 IF Y = 5 THEN 2020
- - 2015 PRINT "Error #"Y: PRINT D$"close": END
- - 2020 PRINT D$"close": PRINT ">>> End of file encountered."
- - 2030 IF FI = 1 THEN PRINT ">>> "OU$" may be incomplete."
- - 2040 IF FI = 1 THEN PRINT "(no end of file marker found)"
- - 2050 TEXT
- - 2060 END
- - 2100 IF OO = 1 THEN PRINT "Volume/directory not found.": GOTO 455
- - 2110 IF II = 1 THEN PRINT "Input file not found.": GOTO 175
- -
- + END OF ARCHIVE
-