home *** CD-ROM | disk | FTP | other *** search
/ Amiga Elysian Archive / AmigaElysianArchive.iso / newc_dev / for16.lha / For.doc < prev    next >
Text File  |  1992-10-10  |  4KB  |  119 lines

  1. /***************************************************************************/
  2. /*                                       */
  3. /*                Itzz                       */
  4. /*                                       */
  5. /***************************************************************************/
  6. /*                                       */
  7. /*        * * * * * * * F O R * * * * * * *               */
  8. /*                                       */
  9. /***************************************************************************/
  10.  
  11. 'for' is intendend to give wildcards to programs like MuchMore which do not
  12. support wildcards by themself. Its command template is
  13.  
  14. for FILE,CMD,EXEC/S,ALL/S
  15.  
  16. FILE     is a filename expression, usually with wildcards. default #?
  17. CMD     is a command string like "MuchMore %s" (notice the quotes !). It
  18.     supports some printf-like expressions.
  19.     %f  the complete filename including the path
  20.     %s  the complete filename without path
  21.     %p  the path of the argument file, without a trailing / or : !!!
  22.     %b  the basename of the file, this is the filename upto the first '.'.
  23.     the default is "%f"
  24. EXEC    the execute flag, if not given, for will only display the commands,
  25.     but not execute them.
  26. ALL     the all flag, directories will be entered (MatchFirst/MatchNext feature!)
  27.  
  28.  
  29. Examples:
  30.  
  31. for *.c "Muchmore %s" exec     displays all C-sources in your current directory
  32. for *.gif "wasp %s %b.iff" exec  will convert all gifs to iff.
  33. for *.c "rename %s %b.d" exec    renames all *.c to *.d (very handy)
  34. for *.o "%b/%s"             lists all your object files. (notice the
  35.                  missing 'exec' !
  36.  
  37. WShell users can get similar effects with
  38. 'List *.c quick lformat "MuchMore %s" | stdin',
  39. but 'for' is more flexible with basenames and extensions.
  40.  
  41. 'for' is very tiny and uses no global variables, so it can (and should) be
  42. made resident (even WShell does not complain about it !!). It is very handy
  43. with aliases and 'inline' ARexx scripts.
  44.  
  45.  
  46. Example:
  47.  
  48. alias More for [] "Muchmore %f" exec        or for WShell
  49. alias More LITERAL for [] "MuchMore /%f" exec
  50.  
  51.  
  52. Caution:
  53. To keep the program small, I've omitted most error and security checks. The
  54. buffer for filenames and commands is 255 bytes long, which should be enough
  55. for most applications, but commands like
  56.  
  57. cd LONG_NAME_FOR_DEVICE:A_COUPLE_OF_LONG_PATHNAMES/ANOTHER_LONG_PATH/DITO
  58. for #? "echo %p %p %p %p %p %p %p %f" 
  59.  
  60. will get the guru for certain, so watch out !!
  61.  
  62.  
  63. /***************************************************************************/
  64. /*                                       */
  65. /* FOR was written, conceived and compiled by                   */
  66. /*                                       */
  67. /*    Michael Illgner                            */
  68. /*    Theodorstr. 27                             */
  69. /*    W-4790 Paderborn                           */
  70. /*    Germany                                */
  71. /*    Tel.: 05251/26488 or 05251/60-2331                   */
  72. /*                                       */
  73. /*    email: fillg1@uni-paderborn.de                     */
  74. /*                                       */
  75. /***************************************************************************/
  76.  
  77. History (short!)
  78.  
  79. V1.0 Initial release
  80.  
  81. V1.1 %f implemented
  82.  
  83. V1.2 AnchorPath must be longword aligned. Thanks to Michael Janich for
  84.      discovering this bug and to Matthias Scheler for explaining it.
  85.      WShell seems to load always at longword boundaries, because I never
  86.      got an error.
  87.  
  88. V1.3 Added quotes around "%f" filenames, so Filenames including spaces are
  89.      allowed. Which guy called the RamDisk "Ram Disk:" :-(
  90.  
  91. V1.4 Added break by CNTRL_C
  92.  
  93. V1.5 Small bug corrected, ArgArray[] must be initialized to NULL. Thanks to
  94.      Michael Janich and Matthias Scheler again for discovering it.
  95.  
  96. V1.6 Added ALL option for recursive scanning of directory.
  97.  
  98.  
  99. ForAll is a similar command, but it will search a directory and all of its
  100. subdirectories for files matching a given pattern. Its command template is
  101.  
  102. ForAll DIR,PAT,CMD,EXEC/S
  103.  
  104. DIR    a string specifying the starting directory
  105. PAT    the filepattern to match for
  106. CMD    the command to execute with a matching file
  107. EXEC    the Execute flag, see above for details
  108.  
  109.  
  110. Example :
  111.  
  112. ForAll DH0: *! delete exec     deletes all emacs-backup files on DH0:
  113. ForAll "" *.c type exec        types all C-Sources in current directory
  114.  
  115. History (short!)
  116.  
  117. V1.0 Initial release
  118.  
  119.