home *** CD-ROM | disk | FTP | other *** search
/ The Best of Mecomp Multimedia 1 / Mecomp-CD.iso / amiga / tools / opus / opus-tools_4.x / dopuslharexx / arexx / getsizeslha.rexx < prev    next >
OS/2 REXX Batch file  |  1994-01-03  |  2KB  |  132 lines

  1. /*rx
  2.  *
  3.  * GetSizesLhA.rexx - Find total size of all files selected in a DOpus 
  4.  *                    LhA buffer window
  5.  *
  6.  * $VER: GetSizesLhA 40.2 (03/01/94) by Geoff Seeley
  7.  *
  8.  * Usage: ARexx command GetSizesLhA.rexx (from DOpus)
  9.  *
  10.  */
  11.  
  12. /*---------------------------------------------------------------------------*/
  13.  
  14. /* misc. variables */
  15.  
  16. DOpusPort = 'DOPUS.1'
  17.  
  18. LhaExt1 = '.lha'
  19. LhaExt2 = '.lzh'
  20.  
  21. /* make sure we've got somebody to talk to */
  22.  
  23. if showlist('Ports', DOpusPort) = 0 then do
  24.    say 'Directory Opus ARexx port not found. Aborting.'
  25.    call CleanUp
  26. end
  27.  
  28. address 'DOPUS.1'
  29. options results
  30.  
  31. /* get the path/name of the LhA archive file */
  32.  
  33. Status 14
  34. LhaArchive = result
  35.  
  36. /* make sure it's an LhA archive listing buffer */
  37.  
  38. if right(LhaArchive, 4, ' ') ~= LhaExt1 & right(LhaArchive, 4, ' ') ~= LhaExt2 then do
  39.  
  40.    Notify "Sorry, buffer isn't an LhA archive. You must use the ListLha button first."
  41.    call CleanUp
  42.  
  43. end
  44.  
  45. /* get total count of files */
  46.  
  47. Status 6
  48. TotalFiles = result - 1
  49.  
  50. /* get total bytes in archive */
  51.  
  52. GetEntry TotalFiles
  53. TotalBytes = result
  54.  
  55. TotalBytes = substr(TotalBytes, 1, 9)
  56. TotalBytes = strip(TotalBytes)
  57.  
  58. /* adjust total for footer */
  59.  
  60. TotalFiles = TotalFiles - 2
  61.  
  62. /* get list of selected entries */
  63.  
  64. GetSelectedAll
  65. SelectedEntries = result
  66.  
  67. if SelectedEntries = 'RESULT' then do
  68.  
  69.    Notify "Please select file(s) to total..."
  70.    call CleanUp
  71.  
  72. end
  73.  
  74. NumberOfEntries = words(SelectedEntries)
  75.  
  76. Busy on
  77.  
  78. /* sum the files */
  79.  
  80. NumberOfBytes = 0
  81. NumberOfFiles = 0
  82.  
  83. call SumEachFile
  84.  
  85. TopText "Files: " || NumberOfFiles || "/" || TotalFiles || "  Bytes: " || NumberOfBytes || "/" || TotalBytes
  86.  
  87. Busy off
  88.  
  89. exit 0
  90.  
  91. /*----------------------------------------------------------------------------*/
  92.  
  93. SumEachFile: /* add each selected file to total */
  94.  
  95.    do EntryNumber = 1 to NumberOfEntries
  96.  
  97.       /* get entry number, retrieve entry */
  98.  
  99.       Index = word(SelectedEntries, EntryNumber)
  100.  
  101.       GetEntry Index + 1
  102.       Entry = result
  103.  
  104.       /* grab file name/path */
  105.  
  106.       File = substr(Entry, 10)
  107.       Size = substr(Entry, 1, 9)
  108.  
  109.       NumberOfFiles = NumberOfFiles + 1
  110.       NumberOfBytes = NumberOfBytes + Size
  111.  
  112.       /* make sure user see's the entry */
  113.  
  114.       ScrollToShow Index
  115.  
  116.       TopText "Files: " || NumberOfFiles || "/" || TotalFiles || "  Bytes: " || NumberOfBytes || "/" || TotalBytes
  117.  
  118.    end
  119.  
  120. return
  121.  
  122. /*---------------------------------------------------------------------------*/
  123.  
  124. CleanUp: /* clean up and exit */
  125.  
  126.    Busy off
  127.  
  128.    exit 0
  129.  
  130. return
  131.  
  132.