/* REXX command to create the PPWIZARD template books.it from the book reviews text file bookreviews.txt PPWIZARD template books.it will be converted to the book reviews web page later */ /* Initialise variables */ ReviewFile = "bookreviews.txt" OutputFile = "books.it" OutLine = ' ' Flag = 0 Bi = 0 Oi = 0 /* initialize arrays */ /* Previous Year table */ PreviousYears.0 = 1 PreviousYears.1.Year = "2003" PreviousYears.1.File = "<$ReviewPath>/2003.html" /* Load Rexx Utility Functions if they are not already loaded */ if RxFuncQuery( 'SysLoadFuncs' ) then do call RxFuncAdd 'SysLoadFuncs', 'REXXUTIL', 'SysLoadFuncs' call SysLoadFuncs end /* read in input data file , and process */ /* Create Book array, which is the Book Information Array */ /* Create OF array, which is the Output File Arrary */ say 'Reading in Review file 'ReviewFile do while( lines(ReviewFile)) rec = linein(ReviewFile) /* replace all occurrances of "&" with "and" */ SELECT /* Title. Starts new Books entry */ when word(rec,1) = "BTITLE:" then do if Oi > 0 then do Oi = Oi + 1 OF.0 = Oi OF.Oi = '
'Book.Bi.BREV' on 'Book.Bi.BDATE'
' end Bi = Bi + 1 Book.0 = Bi Flag = 0 lenth = length(rec) - 7 rec = right(rec,lenth) Book.Bi.BTITLE = strip(rec) Book.Bi.Anchor = Bi'_'strip(word(rec,1)) Oi = Oi + 1 OF.0 = Oi OF.Oi = ''strip(rec)'
'
end
/* Author */
when word(rec,1) = "BAUTHOR:" then
do
lenth = length(rec) - 8
rec = right(rec,lenth)
Book.Bi.BAUTHOR = strip(rec)
Oi = Oi + 1
OF.0 = Oi
OF.Oi = strip(rec)'
'
end
/* Publisher */
when word(rec,1) = "BPUBLISHER:" then
do
lenth = length(rec) - 11
rec = right(rec,lenth)
Book.Bi.BPUBLISHER = strip(rec)
Oi = Oi + 1
OF.0 = Oi
OF.Oi = strip(rec)'
'
end
/* Format */
when word(rec,1) = "BFORMAT:" then
do
lenth = length(rec) - 8
rec = right(rec,lenth)
Book.Bi.BFORMAT = strip(rec)
Oi = Oi + 1
OF.0 = Oi
OF.Oi = strip(rec)
end
/* Pages */
when word(rec,1) = "BPAGES:" then
do
lenth = length(rec) - 7
rec = right(rec,lenth)
Book.Bi.BPAGES = strip(rec)
OF.Oi = OF.Oi', 'strip(rec)
end
/* Price */
when word(rec,1) = "BPRICE:" then
do
lenth = length(rec) - 7
rec = right(rec,lenth)
Book.Bi.BPRICE = strip(rec)
OF.Oi = OF.Oi', 'strip(rec)'
'strip(rec) end /* Paragraph transition */ when length(strip(rec)) = 0 then do Flag = 1 OF.Oi = OF.Oi'
' end /* Review body element */ otherwise do if Flag = 1 then do Flag = 0 Oi = Oi + 1 OF.0 = Oi OF.Oi = ''strip(rec) end else do Oi = Oi + 1 OF.0 = Oi OF.Oi = strip(rec) end end end end /* Last book's revier and date informatio */ Oi = Oi + 1 OF.0 = Oi OF.Oi = '
'Book.Bi.BREV' on 'Book.Bi.BDATE'
' /* Explisit close of Review input file */ call lineout ReviewFile say 'Close Review file, 'Bi' Books read, 'Oi' lines read' /* Check to see if Output file exists, and delete if it does. (New file every run) */ call SysFileTree OutputFile, 'file', 'F' if file.0 > 0 then call SysFileDelete OutputFile say 'Created new Output file 'OutputFile /* Create stock hearer info in output file */ say 'Start writing outputfile' OutLine = '; Book reviews for the current year' call lineout OutputFile, OutLine OutLine = " " call lineout OutputFile, OutLine OutLine = '; Standard definitions' call lineout OutputFile, OutLine OutLine = '#include common.ih' call lineout OutputFile, OutLine OutLine = " " call lineout OutputFile, OutLine OutLine = "; Standard element - HTML HEAD" call lineout OutputFile, OutLine OutLine = '<$Standard_Header Title="Book reviews for the Current year" Keywords="SF, SFSA, book reviews">' call lineout OutputFile, OutLine OutLine = " " call lineout OutputFile, OutLine OutLine = "; Standard element - HTML BODY, masthaed and top Navigation bar" call lineout OutputFile, OutLine OutLine = '<$Standard_Body>' call lineout OutputFile, OutLine OutLine = 'Previous Years' Reviews | " call lineout OutputFile, OutLine /* Previous Year Table body generation */ do i = 1 to PreviousYears.0 OutLine = '
---|
'PreviousYears.i.Year' | ' call lineout OutputFile, OutLine end OutLine = '
'Book.i.BTITLE' by 'Book.i.BAUTHOR', reviewed by 'Book.i.BREV' on 'Book.i.BDATE' | ' call lineout OutputFile, OutLine end OutLine = '