home *** CD-ROM | disk | FTP | other *** search
/ Computer Select (Limited Edition) / Computer Select.iso / pcc / v04n09 / zipit.bas < prev    next >
Encoding:
BASIC Source File  |  1991-08-11  |  2.8 KB  |  99 lines

  1. REM ZIPIT.BAS
  2. DECLARE SUB GetInputFile ()
  3. DECLARE SUB GetOutputFile ()
  4. DECLARE SUB Pause ()
  5. DECLARE SUB TestFileName ()
  6. DECLARE SUB ZipIt ()
  7. COMMON SHARED InputFile$, OutputFile$, Chooser$, Sw1$
  8. CONST ZipSpec$ = "C:\UTILS\ZIP\PKZIP", ZipDir$ = "C:\ZIPFILES\"
  9.  
  10. CLS : LOCATE 6, 10: PRINT "Select one of the following: "
  11. LOCATE 8, 20: PRINT "A - Files in one directory only"
  12. LOCATE 10, 20: PRINT "B - Files in directory and all its subdirectories"
  13. LOCATE 12, 20: PRINT "C - All files on current drive modified today"
  14. DO WHILE Chooser$ = ""
  15.   Chooser$ = INKEY$
  16.   IF UCASE$(Chooser$) < "A" OR UCASE$(Chooser$) > "C" THEN : Chooser$ = ""
  17. LOOP
  18.  
  19. SELECT CASE Chooser$
  20. CASE "A", "a"
  21.   CLS : Sw1$ = " "
  22.   GetInputFile
  23.   GetOutputFile
  24.   ZipIt
  25. CASE "B", "b"
  26.   CLS : Sw1$ = "-p -r "
  27.   GetInputFile
  28.   GetOutputFile
  29.   ZipIt
  30. CASE "C", "c"
  31.   CLS : Sw1$ = "-t -p -r "
  32.   InputFile$ = "\*.*"
  33.   GetOutputFile
  34.   ZipIt
  35. END SELECT
  36.  
  37. CLS : SYSTEM
  38.  
  39. SUB GetInputFile
  40.   CLS : LOCATE 10, 10
  41.   INPUT "Enter name of file(s) to Zip (default is *.*): ", InputFile$
  42.   IF InputFile$ = "" THEN InputFile$ = "*.*"
  43. END SUB
  44.  
  45. SUB GetOutputFile
  46.   OutputFile$ = "": CLS : LOCATE 10, 10
  47.   INPUT "Enter name of destination file (no extension): ", OutputFile$
  48.   TestFileName
  49. END SUB
  50.  
  51. SUB Pause
  52.   PRINT "         Press any key to continue..."
  53.   DO: LOOP UNTIL INKEY$ <> ""
  54. END SUB
  55.  
  56. SUB TestFileName
  57.   IF INSTR(OutputFile$, ".") <> 0 THEN
  58.     CLS : PRINT "No extensions allowed! Try again.          ": Pause
  59.     LOCATE 10, 10: PRINT SPACE$(70)
  60.     GetOutputFile
  61.   ELSE
  62.     IF LEN(OutputFile$) > 8 OR LEN(OutputFile$) = 0 THEN
  63.       CLS : PRINT "Filename must be 1-8 characters! Try again.": Pause
  64.       LOCATE 10, 10: PRINT SPACE$(70)
  65.       GetOutputFile
  66.     END IF
  67.   END IF
  68. END SUB
  69.  
  70. SUB ZipIt
  71.   OutputFile$ = ZipDir$ + OutputFile$ + ".ZIP" + " "
  72.   CLS : PRINT "The current drive/directory is "; : SHELL "CD"
  73.   SELECT CASE Chooser$
  74.     CASE "A", "a"
  75.       PRINT "You have chosen files matching the spec " + InputFile$
  76.       PRINT "     in the current or specified directory."
  77.     CASE "B", "b"
  78.       PRINT "You have chosen files matching the spec " + InputFile$
  79.       PRINT "     in the current or specified directory"
  80.       PRINT "     and all its subdirectories."
  81.     CASE "C", "c"
  82.       PRINT "You have chosen to back up all files on the"
  83.       PRINT "     current drive that were created or modified today."
  84.   END SELECT
  85.   PRINT : PRINT "Destination file is " + OutputFile$
  86.   PRINT "Zip selected files (y/n)? "
  87.   DO WHILE OKToZip$ = ""
  88.     OKToZip$ = INKEY$
  89.     IF UCASE$(OKToZip$) <> "Y" AND UCASE$(OKToZip$) <> "N" THEN
  90.       OKToZip$ = ""
  91.     END IF
  92.   LOOP
  93.   SELECT CASE OKToZip$
  94.     CASE "Y", "y"
  95.       CLS : SHELL ZipSpec$ + " " + Sw1$ + OutputFile$ + InputFile$
  96.     CASE ELSE: CLS : SYSTEM
  97.   END SELECT
  98. END SUB
  99.