[2] | 1 | /************************************************************************
|
---|
| 2 | * Example of how a rexx file can operate on a list file created by *
|
---|
| 3 | * FM/2 (the list file should contain filenames only, one per line). *
|
---|
| 4 | * *
|
---|
| 5 | * This example can be editted at the boxed comment area below and *
|
---|
| 6 | * used with FM/2 Commands containing the %! metastring. *
|
---|
| 7 | * *
|
---|
| 8 | * Call as "%c /C <drive:\path\>EXAMPLE.CMD %!" (exclude quotes) *
|
---|
| 9 | * (for example: %c /C e:\fm2\EXAMPLES.CMD %!) *
|
---|
| 10 | ************************************************************************/
|
---|
| 11 |
|
---|
| 12 | /* suppress echo from "batch" commands */
|
---|
| 13 | '@Echo off'
|
---|
| 14 | /* clear screen (GPs). */
|
---|
| 15 | '@cls'
|
---|
| 16 |
|
---|
| 17 | /* get name of listfile from command line. */
|
---|
| 18 | parse arg listfile
|
---|
| 19 |
|
---|
| 20 | /* if no listfile name was given, issue help and exit. */
|
---|
| 21 | if listfile = '' then
|
---|
| 22 | do
|
---|
| 23 | say 'Give the name of a listfile as an argument to this REXX script.'
|
---|
| 24 | exit
|
---|
| 25 | end
|
---|
| 26 |
|
---|
| 27 | /* for debugging purposes: */
|
---|
| 28 | say 'Name of our listfile is "'listfile'".'
|
---|
| 29 |
|
---|
| 30 | /* see if the listfile given exists -- exit with error message if not */
|
---|
| 31 | rc = stream(listfile,'C','QUERY EXISTS')
|
---|
| 32 | if rc = '' then
|
---|
| 33 | do
|
---|
| 34 | say 'File "'listfile'" doesn''t exist.'
|
---|
| 35 | exit
|
---|
| 36 | end
|
---|
| 37 |
|
---|
| 38 | /* attempt to open the listfile given on the command line */
|
---|
| 39 | rc = stream(listfile,'C','OPEN')
|
---|
| 40 |
|
---|
| 41 | /* if open was successful, enter loop */
|
---|
| 42 | if rc = 'READY:' then
|
---|
| 43 | do
|
---|
| 44 | counter = 0 /* initialize counter (debugging aid) */
|
---|
| 45 |
|
---|
| 46 | /* read each line of the listfile into filename */
|
---|
| 47 | do while lines(listfile) = 1
|
---|
| 48 | filename = linein(listfile)
|
---|
| 49 |
|
---|
| 50 | /* remove any leading/trailing blanks */
|
---|
| 51 | filename = strip(filename,'b')
|
---|
| 52 |
|
---|
| 53 | /* process only non-blank strings */
|
---|
| 54 | if filename \= '' then
|
---|
| 55 | do
|
---|
| 56 | /*************************************************************
|
---|
| 57 | * here you would do something to/with the file in filename. *
|
---|
| 58 | * since this is only an example, we'll just print the name. *
|
---|
| 59 | * note that you could do most anything to the file here -- *
|
---|
| 60 | * use your imagination. *
|
---|
| 61 | *************************************************************/
|
---|
| 62 |
|
---|
| 63 | say filename /* replace with your command(s)! */
|
---|
| 64 |
|
---|
| 65 | /*************************************************************
|
---|
| 66 | * end of area where you'd do your special processing. *
|
---|
| 67 | *************************************************************/
|
---|
| 68 | counter = counter + 1 /* count files processed for debugging. */
|
---|
| 69 | end
|
---|
| 70 | end
|
---|
| 71 |
|
---|
| 72 | /* close the listfile. */
|
---|
| 73 | rc = stream(listfile,'C','CLOSE')
|
---|
| 74 |
|
---|
| 75 | /* remove the listfile -- checks to disallow wildcards in name (GPs). */
|
---|
| 76 | if (pos('*',listfile) = 0) & (pos('?',listfile) = 0) then
|
---|
| 77 | do
|
---|
| 78 | 'del "'listfile'" 1>NUL 2>NUL'
|
---|
| 79 | end
|
---|
| 80 |
|
---|
| 81 | end
|
---|
| 82 | else /* couldn't open listfile */
|
---|
| 83 | do
|
---|
| 84 | say 'Error opening "'listfile'".'
|
---|
| 85 | exit
|
---|
| 86 | end
|
---|
| 87 |
|
---|
| 88 | /* we're done -- issue count for debugging. */
|
---|
| 89 | say ' **I processed 'counter' objects.'
|
---|