source: branches/ticket_150/example.tmp@ 869

Last change on this file since 869 was 2, checked in by root, 23 years ago

Initial revision

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 2.9 KB
Line 
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. */
18parse arg listfile
19
20/* if no listfile name was given, issue help and exit. */
21if listfile = '' then
22do
23 say 'Give the name of a listfile as an argument to this REXX script.'
24 exit
25end
26
27/* for debugging purposes: */
28say 'Name of our listfile is "'listfile'".'
29
30/* see if the listfile given exists -- exit with error message if not */
31rc = stream(listfile,'C','QUERY EXISTS')
32if rc = '' then
33do
34 say 'File "'listfile'" doesn''t exist.'
35 exit
36end
37
38/* attempt to open the listfile given on the command line */
39rc = stream(listfile,'C','OPEN')
40
41/* if open was successful, enter loop */
42if rc = 'READY:' then
43do
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
81end
82else /* couldn't open listfile */
83do
84 say 'Error opening "'listfile'".'
85 exit
86end
87
88/* we're done -- issue count for debugging. */
89say ' **I processed 'counter' objects.'
Note: See TracBrowser for help on using the repository browser.