home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 18 REXX / 18-REXX.zip / autobk2.zip / ZapTapes.CMD < prev   
OS/2 REXX Batch file  |  1995-02-07  |  4KB  |  119 lines

  1. /*******************************************************/
  2. /*  REXX program to initialize tapes for backups       */
  3. /*******************************************************/
  4. '@ECHO OFF'
  5. capacity = 250        /* Maximum capacity of each tape */
  6.  
  7. /*******************************************************/
  8. /*  Initialize Visual REXX environment                 */
  9. /*******************************************************/
  10. Call RxFuncAdd 'VInit', 'VREXX', 'VINIT'
  11. initcode = VInit()
  12. If initcode = 'ERROR' Then
  13.    signal CLEANUP
  14. Call VDialogPos 50, 50 /* All dialog boxes centered */
  15.  
  16. /*******************************************************/
  17. /* Set error traps to force clean up on failures       */
  18. /*******************************************************/
  19. Signal On Failure Name CLEANUP
  20. Signal On Halt Name CLEANUP
  21. Signal On Syntax Name CLEANUP
  22.  
  23. /*******************************************************/
  24. /*  Initialize Visual REXX button values               */
  25. /*******************************************************/
  26. Ok         = 1
  27. Cancel     = 2
  28. OkOrCancel = 3
  29. Yes        = 4
  30. No         = 5
  31. YesOrNo    = 6
  32.  
  33. /*******************************************************/
  34. /* Initialize REXXUtil environment (if not present)    */
  35. /*******************************************************/
  36. rxload = RxFuncQuery('SysLoadFuncs')
  37. If rxload Then
  38.    Do
  39.       Call RxFuncAdd 'SysLoadFuncs', 'RexxUtil', 'SysLoadFuncs'
  40.       Call sysloadfuncs
  41.    End
  42.  
  43. /*******************************************************/
  44. /*     Extract the drives available on the system      */
  45. /*******************************************************/
  46. drives = SysDriveMap('C:', 'LOCAL')
  47.  
  48. /*******************************************************/
  49. /*     Load number of drives into table root           */
  50. /*******************************************************/
  51. drive.0 = Words(drives)
  52.  
  53. /*******************************************************/
  54. /*   Load the table with the available drive letters   */
  55. /*******************************************************/
  56. Do x=1 To drive.0 By 1
  57.    Parse Value drives With drive.x drives
  58. End
  59.  
  60. /*******************************************************/
  61. /* Accumulate the total allocated space on all FAT     */
  62. /* and HPFS drives.                                    */
  63. /*******************************************************/
  64. used_sum = 0
  65. Do x=1 To drive.0 By 1
  66.    filesys = FileType(drive.x)
  67.    If filesys = 'FAT' | filesys = 'HPFS' Then
  68.       Do
  69.          drive_info = SysDriveInfo(drive.x)
  70.          Parse Value drive_info With . free_space total_space .
  71.          used_sum = used_sum + (total_space - free_space)
  72.       End
  73. End
  74.  
  75. /*******************************************************/
  76. /* Convert allocated space from bytes to megabytes     */
  77. /*******************************************************/
  78. used_megs = Format((used_sum / 1048576),,0)
  79.  
  80. /*******************************************************/
  81. /* Each tape can hold up to 250 megabytes.  Prompt for */
  82. /* the number of tapes to erase, initialize with the   */
  83. /* number of tapes we estimate we'll need.             */
  84. /*******************************************************/
  85. endloop = 0
  86. Do Until endloop
  87.    prompt.vstring = Format((used_megs / capacity)+1,,0)
  88.    prompt.0 = 2
  89.    prompt.1 = 'Enter number of tapes to  '
  90.    prompt.2 = 'quick erase'
  91.    button = VInputBox('Quick Erase Tapes', 'prompt', 2, OkOrCancel)
  92.    If button = 'OK' Then
  93.       Do
  94.          If Datatype(prompt.vstring) = 'NUM' Then
  95.             Do
  96.                Do x=1 to prompt.vstring
  97.                   msg.0 = 4
  98.                   msg.1 = 'Insert Cartridge #'||x 'of' prompt.vstring
  99.                   msg.2 = ''
  100.                   msg.3 = 'Press OK to erase, or'
  101.                   msg.4 = 'CANCEL to halt processing'
  102.                   button = VMsgBox('Quick Erase Tapes', 'msg', OkOrCancel)
  103.                   If button = 'OK' Then
  104.                      'BACKMAST /QE'
  105.                   Else
  106.                      x = prompt.vstring
  107.                End
  108.                endloop = 1
  109.             End
  110.       End
  111.    Else
  112.       endloop = 1
  113. End
  114. CLEANUP:
  115.    Call VExit
  116.    If rxload Then
  117.       Call SysDropFuncs  /* Drop only if we loaded */
  118.    Exit
  119.