home *** CD-ROM | disk | FTP | other *** search
/ Amiga Games 1996 January / amigagames-cdrom-1996-01.iso / rexx / extern.filer < prev    next >
Text File  |  1994-05-22  |  4KB  |  138 lines

  1. /*
  2.     $VER: Extern.filer 1.3 (21.05.94)
  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.         21.05.1994    Resident programs were not un-residented at
  45.                 exit - fixed.
  46. */
  47.  
  48. Cmd  = 'Echo'                /* Default values for Arguments    */
  49. Res  = 1
  50. Opt1 = ''
  51. Opt2 = ''
  52. Opt3 = ''
  53. Opt4 = ''
  54. Opt5 = ''
  55.  
  56. ARG Cmd Res Opt1 Opt2 Opt3 Opt4 Opt5    /* Cmd  := command to execute    */
  57.                     /* Res  := make resident? Yes=1    */
  58.                     /* OptX := options for command    */
  59.  
  60. OPTIONS RESULTS                /* aquire results        */
  61.  
  62. ADDRESS 'FilerRexx'            /* default to Filer's ReXX port    */
  63.  
  64. PANEL OFF                /* switch command buttons off    */
  65.  
  66. IF Res = 1 THEN DO            /* make Cmd resident?        */
  67.   SHELL COMMAND 'Resident' Cmd        /* Yes                */
  68. END
  69.  
  70. TEMPFILENAME                /* get name for temporary files    */
  71. IF RESULT = 'RESULT' THEN EXIT 5
  72. TmpFile  = RESULT            /* used for output file        */
  73. TOTEMPF  = '>>' TmpFile
  74. TmpFileX = RESULT || 'x'        /* help file for subdirectories    */
  75. TOTMPFX  = '>>' TmpFileX
  76.  
  77. Opts = ''                /* build option string          */
  78. if Opt1 ~= '' THEN Opts = ' ' || Opt1
  79. if Opt2 ~= '' THEN Opts = Opts Opt2
  80. if Opt3 ~= '' THEN Opts = Opts Opt3
  81. if Opt4 ~= '' THEN Opts = Opts Opt4
  82. if Opt5 ~= '' THEN Opts = Opts Opt5
  83.  
  84.  
  85. GETSOURCEPATH                /* get source directory name    */
  86. IF RESULT = 'RESULT' THEN EXIT 5
  87. PRAGMA('D', RESULT)            /* change dir there        */
  88.  
  89. GETNUMENTRIES                /* get number of source entries */
  90. IF RESULT = 'RESULT' THEN EXIT 5
  91. Anzahl = RESULT
  92.  
  93. DO i = 1 TO Anzahl            /* loop through all entries    */
  94.   GETNAME i                /* get ith entry        */
  95.   IF RESULT = 'RESULT' THEN EXIT 5
  96.   Eintrag = RESULT
  97.  
  98.   Type = LEFT(Eintrag, 1)        /* parse filetype (f, d, F, D)    */
  99.   Name = SUBSTR(Eintrag, 2)        /* parse filename        */
  100.  
  101.   SELECT
  102.  
  103.     /* if selected entry is a directory, use AmigaDOS "List" command to    */
  104.     /* recurse through deeper levels                    */    
  105.  
  106.     WHEN Type = 'd' THEN DO
  107.       'HISTORY External call of Cmd="'||Cmd||Opts||'", Res="'||Res||'", Dir ="'||Name||'"'
  108.       SHELL COMMAND Echo TOTMPFX "FailAt 30"
  109.       SHELL COMMAND 'List' Name 'ALL FILES LFORMAT="'||Cmd||Opts '*"%p%n*"' TOTEMPF '"' TOTMPFX
  110.       SHELL COMMAND 'Execute' TmpFileX
  111.       SHELL COMMAND 'Delete' TmpFileX
  112.       TOGGLEENTRY i
  113.     END
  114.  
  115.     /* if selected entry is a file, call Cmd directly            */
  116.  
  117.     WHEN Type = 'f' THEN DO
  118.       'HISTORY External call of Cmd="'||Cmd||Opts||'", Res="'||Res||'", File="'||Name||'"'
  119.       SHELL COMMAND Cmd||Opts '"'||Name||'"' TOTEMPF
  120.       TOGGLEENTRY i
  121.     END
  122.  
  123.     /* ignore entries not selected (types D and F)            */
  124.  
  125.     OTHERWISE
  126.  
  127.   END    /* SELECT */
  128.  
  129. END    /* DO i   */
  130.  
  131. EXEC 'More' TmpFile            /* use AmigaDOS More for result */
  132. SHELL COMMAND 'Delete' TmpFile        /* delete temporary files    */
  133. IF Res = 1 THEN DO
  134.   SHELL COMMAND 'Resident REMOVE' Cmd    /* remove cmd from resident list*/
  135. END
  136.  
  137. PANEL ON                /* activate command buttons    */
  138.