home *** CD-ROM | disk | FTP | other *** search
/ Simtel MSDOS 1992 June / SIMTEL_0692.cdr / msdos / zip / zipcom.arc / ZIPCOM.BAS next >
Encoding:
BASIC Source File  |  1989-03-12  |  7.2 KB  |  106 lines

  1. 1000 '*************************************************************************
  2. 1010 '**********           ZIPCOM V1.0  by Jack E Moore            ************
  3. 1020 '**********         SysOp: ACCOLADE!  (512)388-1445           ************
  4. 1030 '**********                    3/11/89                        ************
  5. 1040 '*************************************************************************
  6. 1050 '
  7. 1060 '  The purpose of ZIPCOM is to allow a sysop to add more than just a 32
  8. 1070 'character comment to a file.  ZIPCOM flings the door wide open on the
  9. 1080 'endless possibilities of creating a BBS unique LOGO that can be attached
  10. 1090 'to each .ZIP file.  LOGO's, like mine below, are now possible!
  11. 1100 '
  12. 1110 '╒═════════════╡ Brought to you by ╞════════════╕
  13. 1120 '│       ACCOLADE! BBS in Round Rock, Texas     │
  14. 1130 '│    (512)388-1445  24 Hours  1200-2400 baud   │
  15. 1140 '│       210 Meg!  Running Genesis Deluxe!      │
  16. 1150 '╘════════════╡ Jack E Moore  SysOp ╞═══════════╛
  17. 1160 '
  18. 1170 '  Of course, You will need to experiment until you find a ZIP COMMENT
  19. 1180 'that works for you.
  20. 1190 '
  21. 1200 '  Syntax:  ZIPCOM filename.ZIP
  22. 1210 '
  23. 1220 '  How does ZIPCOM do this?  Easy!  ZIPCOM reads a user defined ASCII
  24. 1230 'comment file and places it in the ZIP comment area of your .ZIP file.
  25. 1240 'As for the placement of this ZIP comment, ZIP allows the last 2 bytes
  26. 1250 'in the .ZIP file as the ZIP comment size.  The last byte indicates
  27. 1260 'a multiple of 255 bytes, while the second to last byte indicates the
  28. 1270 'remainder.  ie: hex 20 00 would indicate a comment size of 32 bytes and
  29. 1280 'hex C3 0B would indicate a comment size of 3000 bytes.
  30. 1290 '  Although ZIPCOM will allow you to put a ZIP comment of more than 254
  31. 1300 'bytes, it works best if you limit your Zip comment to no more than 254
  32. 1310 'bytes.  With a ZIP comment of more than 255 bytes, you WILL NOT be able
  33. 1320 'to rerun ZIPCOM on your zip file without screwing it up.  This is because
  34. 1330 'ZIPCOM starts from the back of the .ZIP file and scans forward until it
  35. 1340 'sees a hex 00.  By making your comment more than 254 bytes long, you make
  36. 1350 'the byte that ZIPCOM looks for a none hex 00 value, thus effectively
  37. 1360 'removing the key that ZIPCOM looks for.
  38. 1370 '  YOU CAN RUN ZIPCOM WITH A ZIP COMMENT OF MORE THAN 254 BYTES!  BUT
  39. 1380 'REMEMBER!  IF YOUR ZIP COMMENT IS OVER 255 BYTES LONG, RUNNING ZIPCOM
  40. 1390 'ON THE SAME FILE TWICE WILL SCREW IT UP!  SO BE SURE YOU HAVE YOUR
  41. 1400 'ZIP COMMENT RIGHT THE FIRST TIME!
  42. 1410 '  IF YOU KEEP YOUR ZIP COMMENT UNDER 254 BYTES, THEN YOU CAN RUN ZIPCOM
  43. 1420 'ALL DAY LONG ON THE SAME .ZIP FILE.
  44. 1430 '
  45. 1440 '  The other limits I have found is the maximum comment size is around
  46. 1450 '3000 bytes, But, hey!  That's not too bad!  If you can't make your
  47. 1460 'LOGO in 3000 bytes, then you are better off just adding a read.me file...
  48. 1470 '
  49. 1480 '  The only other problem with ZIPCOM is that it can't truncate existing
  50. 1490 'ZIP comments.  That is to say that if you have a 1000 byte comment, and
  51. 1500 'you change it to a 500 byte comment, ZIPCOM will tell ZIP that you have
  52. 1510 'a 500 byte comment (and subsequent UNZIPping will show only those 500
  53. 1520 'bytes), BUT, the trailing 500 bytes from the previous 1000 byte comment
  54. 1530 'will still be there!  This will be transparant to you, but who needs the
  55. 1540 'extra 500 bytes?  This is a problem I have not been able to clear up
  56. 1550 'using BASIC.  So, the only fix for this is to ZIP the file with NO
  57. 1560 'comment, and then run ZIPCOM on it.  You shouldn't have a problem with
  58. 1570 'this, but, I wanted to let you know so no one will come whining back
  59. 1580 'to me.
  60. 1590 '
  61. 1600 '  OK, so why am I bothering to go into so much details on this?  Well,
  62. 1610 'I want the users of this program to understand what is happening so if
  63. 1620 'something doesn't work, they can understand why and recover.
  64. 1630 '
  65. 1640 '  IT IS VERY important for you to experiment on a copy of a .ZIP file
  66. 1650 'until you get the desired result!  (That is, until you can UNZIP your
  67. 1660 'file successfully AND see your NEW ZIP comment!
  68. 1670 '
  69. 1680 '  All in all, ZIPCOM will give your BBS files a distinctive diference!
  70. 1690 '
  71. 1700 '  Now for the bucks blurb.  If you use this program in any way and find
  72. 1710 'it useful, let me know how much you like it by sending a buck or two
  73. 1720 'to me at:      3813 Rolling Hill, Round Rock, Texas  78681
  74. 1730 '
  75. 1740 '  If this program gives a REAL programmer an idea for a more professional
  76. 1750 'program, well, I hope he remembers me!
  77. 1760 '
  78. 1770 '  On with the code....
  79. 1780 '*************************************************************************
  80. 1790 D$ = "c:\zipcom.txt"                                           'D$ = the path and name of the ZIPCOM comment file
  81. 1800 COLOR 10,0 : YY = CSRLIN                                       'set color and find current cursor location
  82. 1810 ON KEY(10) GOSUB 2040 : KEY(10) ON                             'set function key 10 as abort key
  83. 1820 C$ = COMMAND$ : IF C$ = "" THEN INPUT "Enter File name "; C$   'get .ZIP filename from the command line.  if none, ask for one.
  84. 1830 OPEN C$ FOR RANDOM AS #1 LEN = 1 : FIELD #1, 1 AS A$           'open .ZIP filename
  85. 1840 OPEN D$ FOR RANDOM AS #2 LEN = 1 : FIELD #2, 1 AS B$           'open ZIPCOM comment
  86. 1850   L = LOF(2) : L2 = INT(L/255) : L1 = L-(L2*255)               'calculate the byte sizes for the ZIPCOM comment.  L1 = remainder.  L2 = 255 multiple
  87. 1860 LOCATE YY, 1 : PRINT "Searching for comment begin mark";       'report status
  88. 1870 FOR HX = LOF(1) TO 1 STEP -1                                   'start loop that looks for the hex 00
  89. 1880   GET #1, HX                                                   'get a byte
  90. 1890     IF A$ <> CHR$(0) THEN 1900 ELSE 1910                       'compare it to hex 00. if not, loop again, else assign HX with the location, and break from loop
  91. 1900 NEXT
  92. 1910 PRINT ".  Found";                                              'report status
  93. 1920   LSET A$ = CHR$(L1)     : PUT #1, HX - 1                      'assign L1 to the location before where the hex 00 was found earlier
  94. 1930   LSET A$ = CHR$(L2)     : PUT #1, HX                          'assign L2 to the location where the hex 00 was found earlier
  95. 1940   LSET A$ = CHR$(13)     : PUT #1, HX + 1                      'add a carriage return...
  96. 1950   LSET A$ = CHR$(10)     : PUT #1, HX + 2                      'and a line feed to aid in prettying up the display
  97. 1960 PRINT ".  Adding Comment";                                     'report status
  98. 1970 FOR X = HX + 3 TO LOF(2) + HX + 2                              'starting at an offset of 3, (to compensate for the above 5 lines) start adding the ZIP comment
  99. 1980   XX = XX + 1                                                  'counter that advances through the ZIP comment
  100. 1990   GET #2, XX : BB$ = B$                                        'get a byte from the ZIP comment
  101. 2000   LSET A$ = BB$ : PUT #1, X                                    'sequentially add the ZIP comment to the .ZIP file
  102. 2010 NEXT
  103. 2020 PRINT ".  Done"                                                'report status
  104. 2030 CLOSE                                                          'close all open files
  105. 2040 SYSTEM                                                         'break to DOS
  106.