|
Click here
|
|
|
| r4 is accompanied by Revu, which is a colorful text file viewing accessory. The following is an extract of the CSV2XML.REX example program, as displayed by Revu. This segment splits a comma separated value (CSV) file line into a set of fields. |
A 500 page Rexx's reference has been written by Howard Fosdick. The book describes how to make the best use of Rexx tools
and interfaces, with examples for both Linux and Windows. A tutorial is provided with lots of examples to help you get up
and running with Rexx.
This book (ISBN: 0764579967 ) was published in April 2006 by Wiley at the following online bookstores:
The output of a directory listing utility is often produced in an order that is difficult to sort chronologically. The following program alters the content of directory lines so that dates and times can be sorted chronologically.
/* rev.rex
revise lines in directory listing so they can be sorted chronologically
usage:
r4 rev < directoryListing > sortableDirectoryListing
assume an input line has the following format:
07-27-01 01:01AM 1237 abc.dat
or,
07-27-01 11:01PM 1237 def.dat
the resulting output line will be
2001/07/27 23:01 1237 abc.dat
*/
do lines() /* process all directory listing lines */
/* acquire a directory listing line, and assign text segments to variables */
parse linein month'-'day'-'year hour':'minute +2 amOrPm size file
/* adjust year to four digit format */
if year > 70 then
year = year + 1900
else
year = year + 2000
/* adjust hour to 24 hour clock format */
if hr = 12 then
hr = '00'
if amOrPm = 'PM' then
hour = hour + 12
/* emit sortable line */
say year'/'month'/'day hour':'minute right( size, 10 ) file
end
|
The above directory listing is in a plain text format. Suppose you would prefer the output in an HTML format, that is easier to read. This can be performed by the following additional program. Notice the command pipeline in bold text, which shows how both programs and the sort command are used in series.
/* rev2html.rex
finish revision of lines in directory listing
assume input lines have the following format:
2001/07/27 23:01 1237 abc.dat
usage:
r4 rev < dirinfo.txt | sort /r | r4 rev2html > __readme.htm
*/
say '<html>'
say '<head>'
say '<title>Index of latest revisions</title>'
say '<link rel=stylesheet type="text/css" HREF="kwsw.css">'
say '</head>'
say '<body background=backgrnd.gif>'
say '<center>'
say '<p>This is a listing of the files that have been added'
say '<br>to the <b>latest</b> directory'
say '<br>in reverse chronological order.'
say '<p>'
say '<table cellspacing=5 border=1>'
do lines() /* process all sorted lines */
parse linein date time size file
say '<tr><td>'date'</td><td>'time'</td><td>'size'</td><td>'file'<tr>'
end
say '</table>'
say '</center>'
say '</body>'
say '</html>'
|
|
The following REXX example programs are included:
|
