home *** CD-ROM | disk | FTP | other *** search
/ Magazyn Amiga Shareware Floppies / ma23.dms / ma23.adf / Filer / Rexx / Extern.filer < prev    next >
Text File  |  1993-11-26  |  4KB  |  136 lines

  1. /*
  2.     $VER: Extern.filer 1.2 (24.11.93)
  3.  
  4.     Authors:
  5.         Michael Boehnisch (billy@uni-paderborn.de)    (mb)
  6.         Matthias Scheler (tron@uni-paderborn.de)    (ms)
  7.  
  8.     Function:
  9.         External  AmigaDOS Command Interface for Filer 3.10.  Calls
  10.         arbitrary  commands  with  selected files in Filer's source
  11.         window as arguments, recurses through selected directories.
  12.  
  13.     Requires:
  14.         C:Resident
  15.         More
  16.  
  17.     Call:
  18.         Extern CMD [RES] [OPT1] ... [OPT5]
  19.  
  20.         CMD  -    AmigaDOS command to execute on selected files
  21.  
  22.         RES  -    determines if Cmd is to be made resident.  Set to 1
  23.             if you wish "extern" to try.  Any other value loads
  24.             Cmd  from  disk  each  time  it  is  executed  (not
  25.             recommended)
  26.  
  27.         OPT? -    Options passed directly to Cmd
  28.  
  29.     Examples for "Filer.RC":
  30.         XBUTTON 3,0,0,1,"Version","Extern C:Version 1"
  31.         XBUTTON 3,2,0,1,"Strings","Extern WhatIs 1 A 5"
  32.  
  33.     History:
  34.         18.06.1992    First release (mb)
  35.         21.06.1992    Review for Filer 3.00 Gamma 8 (ms)
  36.         23.06.1992    Removed  bug  with  missing  " signs around
  37.                 file  names.   Now  works correctly on file
  38.                 names with embedded white space. (mb)
  39.         24.11.1993    Major rewiew for Filer 3.10 Gamma release:
  40.                 - adaptet this header
  41.                 - removed small bug when dirs are selected
  42.                 - added HISTORY support
  43.                 (mb)
  44. */
  45.  
  46. Cmd  = 'Echo'                /* Default values for Arguments    */
  47. Res  = 1
  48. Opt1 = ''
  49. Opt2 = ''
  50. Opt3 = ''
  51. Opt4 = ''
  52. Opt5 = ''
  53.  
  54. ARG Cmd Res Opt1 Opt2 Opt3 Opt4 Opt5    /* Cmd  := command to execute    */
  55.                     /* Res  := make resident? Yes=1    */
  56.                     /* OptX := options for command    */
  57.  
  58. OPTIONS RESULTS                /* aquire results        */
  59.  
  60. ADDRESS 'FilerRexx'            /* default to Filer's ReXX port    */
  61.  
  62. PANEL OFF                /* switch command buttons off    */
  63.  
  64. IF Res = 1 THEN DO            /* make Cmd resident?        */
  65.   SHELL COMMAND 'Resident' Cmd        /* Yes                */
  66. END
  67.  
  68. TEMPFILENAME                /* get name for temporary files    */
  69. IF RESULT = 'RESULT' THEN EXIT 5
  70. TmpFile  = RESULT            /* used for output file        */
  71. TOTEMPF  = '>>' TmpFile
  72. TmpFileX = RESULT || 'x'        /* help file for subdirectories    */
  73. TOTMPFX  = '>>' TmpFileX
  74.  
  75. Opts = ''                /* build option string          */
  76. if Opt1 ~= '' THEN Opts = ' ' || Opt1
  77. if Opt2 ~= '' THEN Opts = Opts Opt2
  78. if Opt3 ~= '' THEN Opts = Opts Opt3
  79. if Opt4 ~= '' THEN Opts = Opts Opt4
  80. if Opt5 ~= '' THEN Opts = Opts Opt5
  81.  
  82.  
  83. GETSOURCEPATH                /* get source directory name    */
  84. IF RESULT = 'RESULT' THEN EXIT 5
  85. PRAGMA('D', RESULT)            /* change dir there        */
  86.  
  87. GETNUMENTRIES                /* get number of source entries */
  88. IF RESULT = 'RESULT' THEN EXIT 5
  89. Anzahl = RESULT
  90.  
  91. DO i = 1 TO Anzahl            /* loop through all entries    */
  92.   GETNAME i                /* get ith entry        */
  93.   IF RESULT = 'RESULT' THEN EXIT 5
  94.   Eintrag = RESULT
  95.  
  96.   Type = LEFT(Eintrag, 1)        /* parse filetype (f, d, F, D)    */
  97.   Name = SUBSTR(Eintrag, 2)        /* parse filename        */
  98.  
  99.   SELECT
  100.  
  101.     /* if selected entry is a directory, use AmigaDOS "List" command to    */
  102.     /* recurse through deeper levels                    */    
  103.  
  104.     WHEN Type = 'd' THEN DO
  105.       'HISTORY External call of Cmd="'||Cmd||Opts||'", Res="'||Res||'", Dir ="'||Name||'"'
  106.       SHELL COMMAND Echo TOTMPFX "FailAt 30"
  107.       SHELL COMMAND 'List' Name 'ALL FILES LFORMAT="'||Cmd||Opts '*"%p%n*"' TOTEMPF '"' TOTMPFX
  108.       SHELL COMMAND 'Execute' TmpFileX
  109.       SHELL COMMAND 'Delete' TmpFileX
  110.       TOGGLEENTRY i
  111.     END
  112.  
  113.     /* if selected entry is a file, call Cmd directly            */
  114.  
  115.     WHEN Type = 'f' THEN DO
  116.       'HISTORY External call of Cmd="'||Cmd||Opts||'", Res="'||Res||'", File="'||Name||'"'
  117.       SHELL COMMAND Cmd||Opts '"'||Name||'"' TOTEMPF
  118.       TOGGLEENTRY i
  119.     END
  120.  
  121.     /* ignore entries not selected (types D and F)            */
  122.  
  123.     OTHERWISE
  124.  
  125.   END    /* SELECT */
  126.  
  127. END    /* DO i   */
  128.  
  129. EXEC 'More' TmpFile            /* use AmigaDOS More for result */
  130. SHELL COMMAND 'Delete' TmpFile        /* delete temporary files    */
  131. IF Res ~= 1 THEN DO
  132.   SHELL COMMAND 'Resident REMOVE' Cmd    /* remove cmd from resident list*/
  133. END
  134.  
  135. PANEL ON                /* activate command buttons    */
  136.