home *** CD-ROM | disk | FTP | other *** search
/ Netware Super Library / Netware Super Library.iso / timevent / taskmstr / scanvols.tsk < prev    next >
Encoding:
Text File  |  1995-05-07  |  3.2 KB  |  137 lines

  1. // Enable LOG ON for debugging purposes since it will
  2. // show the lines processed and their structure.
  3. // (Remove the leading slashes to enable LOG ON)
  4.  
  5. // LOG ON
  6.  
  7.  
  8. // Change to the System Console screen before processing.
  9.  
  10. CHANGE_SCREEN "System Console"
  11.  
  12.  
  13. // Clear the System Console screen.
  14.  
  15. CLS
  16.  
  17.  
  18. // The following displays the currently mounted volumes
  19. // and their space usage on the console screen.
  20.  
  21. VOLINFO
  22.  
  23.  
  24. // Capture the current System Console screen image as
  25. // text (default mode).
  26.  
  27. SAVE_SCREEN SYS:SYSTEM\CONSOLE.DAT
  28.  
  29.  
  30. // Open the System Console screen text image for input.
  31.  
  32. OPEN_READ SYS:SYSTEM\CONSOLE.DAT
  33.  
  34.  
  35. // This WHILE/LOOP scans for the string "Mounted Volumes"
  36. // in each line of the captured System Console screen.
  37. // Mounted Volumes is displayed on the line preceding
  38. // the Volume names shown by the VOLUMES console command.
  39. // (Note: The first pass fails since %1 is not defined.)
  40.  
  41. WHILE NOT SCAN_STRING "Volume Name" "%1"
  42.  
  43.  
  44.   // The "Volume Name" string was not found so read the next
  45.   // line from the input file (System Console screen text image).
  46.  
  47.   READ %1
  48.  
  49.  
  50.   // Abort the Task if a read error occurs.
  51.  
  52.   IF ERRORLEVEL
  53.     ECHO Read error occurred!
  54.     ABORT
  55.   ENDIF
  56.  
  57.  
  58.   // If the read returns a null string, exit since the
  59.   // System Console screen should be padded with spaces.
  60.   // (Note: No spaces are allowed between the strings and
  61.   //        the operators in comparisons.)
  62.  
  63.   IF "%1"==""
  64.     ECHO Unable to locate volume information!
  65.     ABORT
  66.   ENDIF
  67.  
  68.  
  69. // Repeat the process until "Volume Name" or a null string.
  70.  
  71. LOOP
  72.  
  73.  
  74. // The following WHILE/LOOP tests if the read string is null
  75. // The first pass it will not be since it matched above.
  76. // (Note: No spaces are allowed between the strings and the
  77. //        operators in comparisons.)
  78.  
  79. WHILE "%1">""
  80.  
  81.  
  82.   // Read the next line from the captured System Console screen
  83.  
  84.   READ %1
  85.  
  86.  
  87.   // Abort the Task if a read error occurs.
  88.  
  89.   IF ERRORLEVEL
  90.     ECHO Read error occurred!
  91.     ABORT
  92.   ENDIF
  93.  
  94.  
  95.   // If the string "%" is not found on the line, must be
  96.   // out of volumes since ##% would appear as Used/Free.
  97.  
  98.   IF NOT SCAN_STRING "%" "%1" THEN BREAK
  99.  
  100.  
  101.   // The following uses a quirk in the CD/CHDIR command:
  102.   // Since a space is not a valid volume/path character,
  103.   // the parser will ignore any trailing characters after
  104.   // the specified volume/path.
  105.  
  106.   CD %1
  107.  
  108.  
  109.   // At this point, the .TSK has changed the Current Working
  110.   // Directory (CWD) to the root of the (first/next) volume.
  111.   // Another .TSK could be launched to walk the directory
  112.   // tree and delete old/backup files, etc. or the logic
  113.   // could be incorporated herein.
  114.  
  115.   // For this example, we will merely display the CWD.
  116.  
  117.   ECHO Successfully changed to %CWD%
  118.  
  119.  
  120. // Repeat the process until "%" is not found or a null string
  121. // is encountered (indicating an End Of File).
  122.  
  123. LOOP
  124.     
  125.  
  126. // Clean up our work file.
  127.  
  128. DEL SYS:SYSTEM\CONSOLE.DAT
  129.  
  130.  
  131. // Disable LOG ON (if previously enabled).
  132. // (Note: This is not required since TaskMaster will
  133. //        clean up after the Task but it is a sign of
  134. //        proper design and follow through in the logic.)
  135.  
  136. // LOG OFF
  137.