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

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