1 |
|
---|
2 | :h3 res=100080 id='PANEL_REXAMPLE'. Sample REXX File
|
---|
3 | :color fc=default bc=green.
|
---|
4 | &slash. &asterisk. Example of how a rexx file can operate on a list file created by FM&slash.2 &lpar.the list file should contain filenames only&comma.
|
---|
5 | one per line&rpar.&per. This example can be editted at the boxed comment area below and
|
---|
6 | used with FM&slash.2 Commands containing the &percent.&xclm.metastring&per. Call as "&percent.c &slash.C<.drive&colon.&bsl.path&bsl.>.EXAMPLE&per.CMD &percent.&xclm." &lpar.exclude
|
---|
7 | quotes&rpar. &lpar.for example&colon. &percent.c &slash.C E&colon.&bsl.fm2&bsl.EXAMPLES&per.CMD &percent.&xclm.&rpar.
|
---|
8 | &asterisk.&slash.:color fc=default bc=default.
|
---|
9 |
|
---|
10 | .br
|
---|
11 |
|
---|
12 | :color fc=default bc=green.:p.&slash.&asterisk. suppress echo from "batch" commands &asterisk.&slash.
|
---|
13 | :color fc=default bc=default.
|
---|
14 | .br
|
---|
15 | &apos.&atsign.Echo off&apos.
|
---|
16 | :p.
|
---|
17 | :color fc=default bc=green.&slash.&asterisk. clear screen &lpar.GPs&rpar.&per. &asterisk.&slash.
|
---|
18 | :color fc=default bc=default.
|
---|
19 | .br
|
---|
20 | &apos.&atsign.cls&apos.
|
---|
21 | :p.
|
---|
22 | :color fc=default bc=green.&slash.&asterisk. get name of listfile from command line&per.&asterisk.&slash.:color fc=default bc=default.
|
---|
23 | .br
|
---|
24 | parse arg listfile
|
---|
25 | :p.
|
---|
26 | :color fc=default bc=green.&slash.&asterisk. if no listfile name was given&comma. issue help and exit&per. &asterisk.&slash.
|
---|
27 | :color fc=default bc=default.
|
---|
28 | .br
|
---|
29 | if listfile &eq. &apos.&apos. then
|
---|
30 | .br
|
---|
31 | do
|
---|
32 | .br
|
---|
33 | say &apos.Give the name of a listfile as an argument to this REXX
|
---|
34 | script&per.&apos.
|
---|
35 | .br
|
---|
36 | exit
|
---|
37 | .br
|
---|
38 | end
|
---|
39 | :p.
|
---|
40 | :color fc=default bc=green.&slash.&asterisk. for debugging purposes&colon. &asterisk.&slash.
|
---|
41 | :color fc=default bc=default.
|
---|
42 | .br
|
---|
43 | say &apos.Name of our listfile is "&apos.listfile&apos."&per.&apos.
|
---|
44 | :p.
|
---|
45 | :color fc=default bc=green.&slash.&asterisk. see if the listfile given exists &endash.&endash. exit with
|
---|
46 | error message if not &asterisk.&slash.:color fc=default bc=default.
|
---|
47 | .br
|
---|
48 | rc &eq. stream&lpar.listfile&comma.&apos.C&apos.&comma.&apos.QUERY
|
---|
49 | EXISTS&apos.&rpar.
|
---|
50 | .br
|
---|
51 | if rc &eq. &apos.&apos. then
|
---|
52 | .br
|
---|
53 | do
|
---|
54 | .br
|
---|
55 | say &apos.File "&apos.listfile&apos." doesn&apos.&apos.t exist&per.&apos.
|
---|
56 | .br
|
---|
57 | exit
|
---|
58 | .br
|
---|
59 | end
|
---|
60 | :p.
|
---|
61 | :color fc=default bc=green.&slash.&asterisk. attempt to open the listfile given on the command line
|
---|
62 | &asterisk.&slash.:color fc=default bc=default.
|
---|
63 | .br
|
---|
64 | rc &eq. stream&lpar.listfile&comma.&apos.C&apos.&comma.&apos.OPEN&apos.&rpar.
|
---|
65 | :p.
|
---|
66 | :color fc=default bc=green.&slash.&asterisk. if open was successful&comma. enter loop &asterisk.&slash.
|
---|
67 | :color fc=default bc=default.
|
---|
68 | .br
|
---|
69 | if rc &eq. &apos.READY&colon.&apos. then
|
---|
70 | .br
|
---|
71 | do
|
---|
72 | .br
|
---|
73 | counter &eq. 0 :color fc=default bc=green.&slash.&asterisk. initialize counter &lpar.debugging
|
---|
74 | aid&rpar. &asterisk.&slash.
|
---|
75 | :p.
|
---|
76 | &slash.&asterisk. read each line of the listfile into filename
|
---|
77 | &asterisk.&slash.:color fc=default bc=default.
|
---|
78 | .br
|
---|
79 | do while lines&lpar.listfile&rpar. &eq. 1
|
---|
80 | .br
|
---|
81 | filename &eq. linein&lpar.listfile&rpar.
|
---|
82 | :p.:color fc=default bc=green.&slash.&asterisk. remove any leading&slash.trailing blanks
|
---|
83 | &asterisk.&slash.:color fc=default bc=default.
|
---|
84 | .br
|
---|
85 | filename &eq. strip&lpar.filename&comma.&apos.b&apos.&rpar.
|
---|
86 | :p.:color fc=default bc=green.&slash.&asterisk. process only non&endash.blank strings &asterisk.&slash.
|
---|
87 | :color fc=default bc=default.
|
---|
88 | .br
|
---|
89 | if filename &bsl.&eq. &apos.&apos. then
|
---|
90 | .br
|
---|
91 | do
|
---|
92 | .br
|
---|
93 |
|
---|
94 | .br
|
---|
95 | :color fc=default bc=green.&slash.&asterisk. here you would do something to&slash.with the file in
|
---|
96 | filename&per. since this is only an example&comma. we&apos.ll just print the
|
---|
97 | name&per. Note that you could do most anything to the file here
|
---|
98 | &endash.&endash. use your imagination&per.&asterisk.&slash.:color fc=default bc=default.
|
---|
99 | .br
|
---|
100 |
|
---|
101 | :p. say filename :color fc=default bc=green.&slash.&asterisk.replace with your
|
---|
102 | command&lpar.s&rpar.&xclm.&asterisk.&slash.
|
---|
103 | :p.
|
---|
104 | &slash.&asterisk.end of area where you&apos.d do your special processing&per.&asterisk.&slash.:color fc=default bc=default.
|
---|
105 | .br
|
---|
106 |
|
---|
107 | .br
|
---|
108 | counter &eq. counter &plus. 1 :color fc=default bc=green.&slash.&asterisk. count files processed for
|
---|
109 | debugging&per. &asterisk.&slash.:color fc=default bc=default.
|
---|
110 | .br
|
---|
111 | end
|
---|
112 | .br
|
---|
113 | end
|
---|
114 | :p.:color fc=default bc=green.&slash.&asterisk. close the listfile&per. &asterisk.&slash.:color fc=default bc=default.
|
---|
115 | .br
|
---|
116 | rc &eq. stream&lpar.listfile&comma.&apos.C&apos.&comma.&apos.CLOSE&apos.&rpar.
|
---|
117 | :p.:color fc=default bc=green.&slash.&asterisk. remove the listfile &endash.&endash. checks to disallow
|
---|
118 | wildcards in name &lpar.GPs&rpar.&per. &asterisk.&slash.:color fc=default bc=default.
|
---|
119 | .br
|
---|
120 | if &lpar.pos&lpar.&apos.&asterisk.&apos.&comma.listfile&rpar. &eq. 0&rpar.
|
---|
121 | &. &lpar.pos&lpar.&apos.?&apos.&comma.listfile&rpar. &eq. 0&rpar. then
|
---|
122 | .br
|
---|
123 | do
|
---|
124 | .br
|
---|
125 | &apos.del "&apos.listfile&apos." 1>.NUL 2>.NUL&apos.
|
---|
126 | .br
|
---|
127 | end
|
---|
128 | :p.end
|
---|
129 | .br
|
---|
130 | else :color fc=default bc=green.&slash.&asterisk. couldn&apos.t open listfile &asterisk.&slash.:color fc=default bc=default.
|
---|
131 | .br
|
---|
132 | do
|
---|
133 | .br
|
---|
134 | say &apos.Error opening "&apos.listfile&apos."&per.&apos.
|
---|
135 | .br
|
---|
136 | exit
|
---|
137 | .br
|
---|
138 | end
|
---|
139 | :p.:color fc=default bc=green.&slash.&asterisk. we&apos.re done &endash.&endash. issue count for
|
---|
140 | debugging&per. &asterisk.&slash.:color fc=default bc=default. .
|
---|
141 | .br
|
---|
142 | say &apos. &asterisk.&asterisk.I processed &apos.counter&apos.
|
---|
143 | objects&per.&apos.
|
---|
144 | .br
|
---|
145 |
|
---|