home *** CD-ROM | disk | FTP | other *** search
/ Black Box 4 / BlackBox.cdr / progbas / pbclon18.arj / ARCVIEW.BAS < prev    next >
BASIC Source File  |  1992-04-22  |  4KB  |  114 lines

  1. '   +----------------------------------------------------------------------+
  2. '   |                                                                      |
  3. '   |       PBClone  Copyright (c) 1990-1992  Thomas G. Hanlin III         |
  4. '   |                                                                      |
  5. '   +----------------------------------------------------------------------+
  6.  
  7. ' This is another simple demo of the PBClone routines.  It allows you to
  8. ' view the files in an archive (.ARC, .ARJ, .LZH, .PAK, .ZIP, or .ZOO).
  9.  
  10. ' Syntax:
  11. '   ARCVIEW arcname[.ext] [/V]
  12.  
  13. ' The file extension for the archive is optional, although you may want to
  14. ' specify it if there is a possibility that you have two archives of the
  15. ' same name but different extensions (e.g., FOO.ARJ and FOO.ZIP).  The /V
  16. ' option allows you to specify a full listing-- without it, you will get
  17. ' a "wide format" display containing just the file names in the archive.
  18.  
  19. ' Typically, this would be converted to an .EXE file using these steps:
  20. '    BC ARCVIEW/O;
  21. '    LINK ARCVIEW/EX,,NUL,PBCLONE;
  22.  
  23.    DECLARE SUB CloseA ()
  24.    DECLARE SUB DateN2S (MonthNr%, Day%, Year%, DateSt$)
  25.    DECLARE SUB FindFirstA (Archive$, FileName$, ErrCode%)
  26.    DECLARE SUB FindNextA (ErrCode%)
  27.    DECLARE SUB GetCRCAL (CRC32&)
  28.    DECLARE SUB GetDateA (MonthNr%, Day%, Year%)
  29.    DECLARE SUB GetNameA (FileName$, FileNameLen%)
  30.    DECLARE SUB GetSizeAL (OriginalSize&, CurrentSize&)
  31.    DECLARE SUB GetTimeA (Hour%, Minute%, Second%)
  32.    DECLARE SUB TimeN2S (Hour%, Minute%, Second%, TimeSt$)
  33.  
  34.    DECLARE SUB PrintComma (Number&, FieldLen%)
  35.  
  36.    DEFINT A-Z
  37.  
  38.    Cmd$ = LTRIM$(RTRIM$(UCASE$(COMMAND$)))
  39.    IF LEN(Cmd$) = 0 OR INSTR(Cmd$, "/?") > 0 THEN
  40.       PRINT "ARCVIEW: View Archive Demo for PBClone by Thomas G. Hanlin III"
  41.       PRINT
  42.       PRINT "Syntax:"
  43.       PRINT "  ARCVIEW arcname[.ext] [/V]
  44.       PRINT
  45.       PRINT "Use /V for a full listing, as opposed to just a list of the files contained"
  46.       PRINT "in the archive.  ARCVIEW currently supports ARC, ARJ, LZH, PAK, ZIP, and ZOO."
  47.       END
  48.    END IF
  49.    tmp = INSTR(Cmd$, "/V")
  50.    IF tmp THEN
  51.       FullView = -1
  52.       Cmd$ = LTRIM$(RTRIM$(LEFT$(Cmd$, tmp - 1) + MID$(Cmd$, tmp + 2)))
  53.    END IF
  54.    IF LEN(Cmd$) THEN
  55.       Arc$ = Cmd$
  56.    ELSE
  57.       PRINT "Please specify the name of an archive."
  58.       END
  59.    END IF
  60.  
  61.    FindFirstA Arc$, "*.*", ErrCode
  62.    IF ErrCode THEN
  63.       PRINT "Unable to open archive "; CHR$(34); Arc$; CHR$(34)
  64.       END
  65.    END IF
  66.  
  67.    IF FullView THEN
  68.       PRINT "Filename       Date       Time    CRC        Curr. Size    Orig. Size"
  69.       PRINT "------------   --------   -----   --------   -----------   -----------"
  70.    END IF
  71.  
  72.    FileName$ = SPACE$(12)
  73.    DO
  74.       GetNameA FileName$, FLen
  75.       IF FullView THEN
  76.          PRINT LEFT$(FileName$, FLen); SPACE$(15 - FLen);
  77.          GetDateA Month, Day, Year
  78.          DateSt$ = "xx/xx/xx"
  79.          DateN2S Month, Day, Year, DateSt$
  80.          PRINT DateSt$; "   ";
  81.          GetTimeA Hour, Minute, Second
  82.          TimeSt$ = "xx:xx"
  83.          TimeN2S Hour, Minute, Second, TimeSt$
  84.          PRINT TimeSt$; "   ";
  85.          GetCRCAL CRC32&
  86.          HexCRC$ = RIGHT$("00000000" + HEX$(CRC32&), 8)
  87.          PRINT HexCRC$;
  88.          GetSizeAL OriginalSize&, CurrentSize&
  89.          PrintComma CurrentSize&, 14
  90.          PrintComma OriginalSize&, 14
  91.          PRINT
  92.       ELSE
  93.          PRINT LEFT$(FileName$, FLen); SPACE$(16 - FLen);
  94.       END IF
  95.       FindNextA ErrCode
  96.    LOOP UNTIL ErrCode
  97.  
  98.    CloseA
  99.  
  100. SUB PrintComma (Number&, FieldLen)
  101.    N$ = LTRIM$(STR$(Number&))
  102.    R$ = ""
  103.    DO WHILE LEN(N$) > 3
  104.       R$ = RIGHT$(N$, 3) + "," + R$
  105.       N$ = LEFT$(N$, LEN(N$) - 3)
  106.    LOOP
  107.    IF LEN(N$) THEN R$ = N$ + "," + R$
  108.    IF RIGHT$(R$, 1) = "," THEN R$ = LEFT$(R$, LEN(R$) - 1)
  109.    IF LEN(R$) < FieldLen THEN
  110.       R$ = SPACE$(FieldLen - LEN(R$)) + R$
  111.    END IF
  112.    PRINT R$;
  113. END SUB
  114.