home *** CD-ROM | disk | FTP | other *** search
/ Amiga MA Magazine 1998 #6 / amigamamagazinepolishissue1998.iso / opus / v4 / arexx / getsizeslha.rexx < prev    next >
OS/2 REXX Batch file  |  1977-12-31  |  3KB  |  159 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.3 (22/05/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. if ~show(l,"rexxsupport.library") then        
  19.     call addlib("rexxsupport.library",0,-30,0)
  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 -1'
  34. LhaArchive = result
  35.  
  36. /* make sure it's an LhA archive listing buffer */
  37.  
  38. if IsLhaFile(LhaArchive) = 0 then do
  39.  
  40.    /* try the other window */
  41.  
  42.    OtherWindow
  43.    'Status 14 -1'
  44.    LhaArchive = result
  45.  
  46.    if IsLhaFile(LhaArchive) = 0 then do
  47.  
  48.       Notify "Sorry, No LhA archive buffer found. You must use the ListLha button first."
  49.       call CleanUp
  50.  
  51.    end
  52.  
  53. end
  54.  
  55. /* get total count of files */
  56.  
  57. 'Status 6 -1'
  58. TotalFiles = result - 1
  59.  
  60. /* get total bytes in archive */
  61.  
  62. GetEntry TotalFiles
  63. TotalBytes = result
  64.  
  65. TotalBytes = substr(TotalBytes, 1, 9)
  66. TotalBytes = strip(TotalBytes)
  67.  
  68. /* adjust total for footer */
  69.  
  70. TotalFiles = TotalFiles - 2
  71.  
  72. /* get list of selected entries */
  73.  
  74. GetSelectedAll
  75. SelectedEntries = result
  76.  
  77. if SelectedEntries = 'RESULT' then do
  78.  
  79.    Notify "Please select file(s) to total..."
  80.    call CleanUp
  81.  
  82. end
  83.  
  84. NumberOfEntries = words(SelectedEntries)
  85.  
  86. Busy on
  87.  
  88. /* sum the files */
  89.  
  90. NumberOfBytes = 0
  91. NumberOfFiles = 0
  92.  
  93. call SumEachFile
  94.  
  95. TopText "Files: " || NumberOfFiles || "/" || TotalFiles || "  Bytes: " || NumberOfBytes || "/" || TotalBytes
  96.  
  97. Busy off
  98.  
  99. exit 0
  100.  
  101. /*----------------------------------------------------------------------------*/
  102.  
  103. SumEachFile: /* add each selected file to total */
  104.  
  105.    do EntryNumber = 1 to NumberOfEntries
  106.  
  107.       /* get entry number, retrieve entry */
  108.  
  109.       Index = word(SelectedEntries, EntryNumber)
  110.  
  111.       GetEntry Index + 1
  112.       Entry = result
  113.  
  114.       /* grab file name/path */
  115.  
  116.       File = substr(Entry, 10)
  117.       Size = substr(Entry, 1, 9)
  118.  
  119.       NumberOfFiles = NumberOfFiles + 1
  120.       NumberOfBytes = NumberOfBytes + Size
  121.  
  122.       /* make sure user see's the entry */
  123.  
  124.       TopText "Files: " || NumberOfFiles || "/" || TotalFiles || "  Bytes: " || NumberOfBytes || "/" || TotalBytes
  125.  
  126.    end
  127.  
  128. return
  129.  
  130. /*---------------------------------------------------------------------------*/
  131.  
  132. IsLhAFile: procedure   /* look at extension, return 1 if right, else 0 */
  133.  
  134.    parse arg AFileName
  135.  
  136.    lps = lastpos(".", AFileName)               
  137.    if lps = 0 then                           
  138.       return 0
  139.  
  140.    FileExt = upper(right(AFileName,length(AFileName)-lps))
  141.  
  142.    if FileExt ~= "LHA" & FileExt ~= "LZH" then
  143.       return 0
  144.    else
  145.       return 1
  146.  
  147. return 0
  148.  
  149. /*---------------------------------------------------------------------------*/
  150.  
  151. CleanUp: /* clean up and exit */
  152.  
  153.    Busy off
  154.  
  155.    exit 0
  156.  
  157. return
  158.  
  159.