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

  1. /*
  2.  *
  3.  * Delete file(s) from 1541/Amiga from DOpus.
  4.  *
  5.  * (c) 1995 by Christer Bjarnemo  mr.bjarnemo@mn.medstroms.se
  6.  *
  7.  * Based on Twin-Dopus by Patrick Van Beem (patrick.van.beem@aobh.xs4all.nl),
  8.  * which based he's script on the DOpusLhaARexx package by Geoff Seeley.
  9.  *
  10.  */
  11.  
  12. dircmd = "Work:Emulators/A64/Utils/"    /* Note. If the file ENVARC:1541.PREFS */
  13. rxdir =  "Rexx:Dopus/1541/"             /* exists, that one will override the  */
  14. tmpdir = "t:"                           /* settings here...                    */
  15. DOpusPort   = 'DOPUS.1'
  16.  
  17. snuff = '22'x
  18.  
  19. if open(1,'env:1541.prefs','Read') then do
  20.         dircmd = readln(1)
  21.     rxdir  = readln(1)
  22.         tmpdir = readln(1)
  23.         end
  24. close(1)
  25.  
  26. dircmd = slashpath(dircmd)
  27. rxdir =  slashpath(rxdir)
  28. tmpdir = slashpath(tmpdir)
  29.  
  30. if ~show(l,"rexxsupport.library") then        
  31.     call addlib("rexxsupport.library",0,-30,0)
  32. if showlist('Ports', DOpusPort) = 0 then do
  33.    say 'Directory Opus Arexx port not found. Aborting.'
  34.    call CleanUp
  35. end
  36.  
  37. address(DOpusPort)
  38. options results
  39.  
  40. /* setup DOpus window and tell user what's happening */
  41. Busy on
  42. TopText "Deleting selected files..."
  43.  
  44. /* Get the destination path */
  45. 'Status 6 -1'
  46. GetEntry Result
  47. ToPath = Result
  48. if left(ToPath,1) = '*' then do
  49.    ToPath = SubStr(ToPath,2)
  50.    DoReread='TRUE'
  51. end
  52. else do
  53.    'Status 13 -1'
  54.    ToPath = result
  55.    if ToPath = '' then do
  56.       TopText "No destination directory selected."
  57.       call CleanUp
  58.    end
  59.    DoReread='FALSE'
  60. end
  61. ToPath=Quote(ToPath)
  62.  
  63. /* Get the current path and do file-copy, depending on the  */
  64. /* type of path (1541/normal path)                          */
  65. 'Status 6 -1'
  66. GetEntry Result
  67. FilePath = Result
  68.  
  69. /* Twin-way */
  70. if left(FilePath,1) = '*' then do
  71.     Request 'Do you really wish to delete selected entries?'
  72.     if result = 0 then call cleanup
  73.    FilePath = SubStr(FilePath,2)
  74.    GetSelectedAll
  75.    SelectedEntries = result
  76.    if SelectedEntries = 'RESULT' then do
  77.       TopText "No files selected."
  78.       call CleanUp
  79.    end
  80.    NumberOfEntries = words(SelectedEntries)
  81.    do EntryNumber = 1 to NumberOfEntries
  82.       Index = word(SelectedEntries, EntryNumber)
  83.       GetEntry Index+1
  84.       Entry = result
  85.       File = strip(left(Entry,25))
  86.       if right(FilePath,1) = ':' then
  87.          File = FilePath || File
  88.       else
  89.          File = FilePath || '' || File
  90.       address command dircmd'64Cmd >'tmpdir'1541.tmp "s:'File'" 8'
  91.  
  92. if open(1,tmpdir'1541.tmp','Read') then do
  93.         Do for 8 ; tmp = readln(1) ; End
  94.     say tmp
  95.     Toptext tmp
  96.         close(1)
  97.         end
  98.  
  99.       selection = Index||' 0 0'
  100.       SelectEntry selection
  101.    end
  102. end
  103.  
  104. /* Normal way */
  105. else do
  106.     delete
  107. end
  108.  
  109.  
  110. 'DisplayDir -1'
  111.  
  112. if DoReread='TRUE' then do
  113.    address arexx rxdir'1541Dir.rexx'
  114. end
  115.  
  116. call CleanUp
  117.  
  118. exit
  119.  
  120. /*---------------------------------------------------------------------------*/
  121.  
  122. CleanUp: /* Remove any files and exit */
  123.    Busy off
  124.    exit
  125. return
  126.  
  127. /*--------------------------------------------------------------------------*/
  128.  
  129. Quote: procedure /* add quotes to string */
  130.    parse arg string
  131. return '"'||string||'"'
  132.  
  133. /*--------------------------------------------------------------------------*/
  134.  
  135. GetWord: procedure /* get word from '|' separated string */
  136.  
  137.   parse arg number,words
  138.  
  139.   if(left(words,1) ~= '|') then
  140.      words = '|'||words
  141.   do i=1 to number
  142.      idx = index(words, '|');
  143.      words = substr(words, idx+1)
  144.   end
  145.   end = index(words, '|') - 1
  146.   if words = "" then
  147.      return ""
  148.  
  149.   ret_str = substr(words, 1, end)
  150. return ret_str
  151.  
  152. /*--------------------------------------------------------------------------*/
  153.  
  154. CountWords: procedure /* count words from '|' separated string */
  155.  
  156.    parse arg words
  157.  
  158.    count = 0
  159.    idx = index(words, '|')
  160.    do while idx ~= 0
  161.      count = count + 1
  162.      words = substr(words, idx+1)
  163.      idx = index(words, '|')
  164.    end
  165. return count
  166.  
  167. /*---------------------------------------------------------------------------*/
  168. Slashpath: procedure /* Put a (/) or (:) at the end of filenames (if neccessary) */
  169. parse arg string
  170.     if right(string,1) ~= ':' & right(string,1) ~= '/'  then do
  171.         string = string'/'
  172.         end
  173. return string
  174.  
  175.