home *** CD-ROM | disk | FTP | other *** search
/ Amiga MA Magazine 1998 #6 / amigamamagazinepolishissue1998.iso / opus / v4 / arexx / restorelhadir.rexx < prev    next >
OS/2 REXX Batch file  |  1977-12-31  |  3KB  |  143 lines

  1. /*rx
  2.  *
  3.  * RestoreLhADir.rexx - Restore the directory buffer where the current LhA
  4.  *                      archive buffer lives
  5.  *
  6.  * $VER: RestoreLhADir 40.4 (23/05/94) by Geoff Seeley
  7.  *
  8.  * Usage: ARexx command RestoreLhADir.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. TopText "Restore original buffered directory..."
  32.  
  33. Busy on
  34.  
  35. /* get window information from DOpus */
  36.  
  37. Status 3
  38. CurrentWindow = result
  39.  
  40. /* get the path/name of the LhA archive file */
  41.  
  42. Status 14 CurrentWindow
  43. LhaFileName = result
  44.  
  45. /* make sure it's an LhA archive listing buffer */
  46.  
  47. if (IsLhAFile(LhaFileName) = 0) then do
  48.  
  49.    /* try other window */
  50.  
  51.    OtherWindow
  52.    'Status 14 -1'
  53.    LhaFileName = Result
  54.  
  55.    if (IsLhAFile(LhaFileName) = 0) then do
  56.  
  57.       Notify "Sorry, no LhA archive buffer found.\You must use the ListLha button first."
  58.       TopText "Restore aborted."
  59.       call CleanUp
  60.  
  61.    end
  62.  
  63.    /* update current window */
  64.  
  65.    if CurrentWindow = 0 then
  66.       CurrentWindow = 1
  67.    else
  68.       CurrentWindow = 0
  69.  
  70. end
  71.  
  72. /* get path to archive */
  73.  
  74. call FindLhaPath
  75. LhaArchive = LhaPath || LhaFileName
  76.  
  77. /* check for existance of archive */
  78.  
  79. if ~exists(LhaArchive) then do
  80.  
  81.    Notify "Can't seem to find '" || LhaArchive || "'\Aborting."
  82.    TopText "Restore aborted."
  83.    call CleanUp
  84.  
  85. end
  86.  
  87. /* read in the directory */
  88.  
  89. ClearWin CurrentWindow
  90. 'ScanDir "'||LhaPath||'"'
  91.  
  92. /* re-select the archive file */
  93.  
  94. 'Select '||LhaFileName||' onlyfiles'
  95.  
  96. TopText "Restored Original Buffered Directory."
  97.  
  98. call CleanUp
  99.  
  100. exit
  101.  
  102. /*--------------------------------------------------------------------------*/
  103.  
  104. IsLhAFile: procedure   /* look at extension, return 1 if right, else 0 */
  105.  
  106.    parse arg AFileName
  107.  
  108.    lps = lastpos(".", AFileName)               
  109.    if lps = 0 then                           
  110.       return 0
  111.  
  112.    FileExt = upper(right(AFileName,length(AFileName)-lps))
  113.  
  114.    if FileExt ~= "LHA" & FileExt ~= "LZH" then
  115.       return 0
  116.    else
  117.       return 1
  118.  
  119. return 0
  120.  
  121. /*--------------------------------------------------------------------------*/
  122.  
  123. FindLhAPath: /* grab invisible file path to archive */
  124.  
  125.    /* find number of entries, path is the last one */
  126.  
  127.    'Status 6 -1'
  128.  
  129.    GetEntry Result
  130.    LhaPath = Result
  131.  
  132. return
  133.  
  134. /*--------------------------------------------------------------------------*/
  135.  
  136. CleanUp: /* clean up files and exit */
  137.  
  138.    Busy off
  139.    exit
  140.  
  141. return
  142.  
  143.