/* 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 = '
' 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)'

' end /* Reviewer */ when word(rec,1) = "BREV:" then do lenth = length(rec) - 5 rec = right(rec,lenth) Book.Bi.BREV = strip(rec) end /* Date reviewed */ when word(rec,1) = "BDATE:" then do lenth = length(rec) - 6 rec = right(rec,lenth) Book.Bi.BDATE = strip(rec) end /* Body */ when word(rec,1) = "BBODY:" then do lenth = length(rec) - 6 rec = right(rec,lenth) Oi = Oi + 1 OF.0 = Oi OF.Oi = '

'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 = '

Book Reviews

' call lineout OutputFile, OutLine /* Generate Previous Year Table */ OutLine = '' call lineout OutputFile, OutLine OutLine = '' call lineout OutputFile, OutLine OutLine = "" call lineout OutputFile, OutLine /* Previous Year Table body generation */ do i = 1 to PreviousYears.0 OutLine = '' call lineout OutputFile, OutLine OutLine ='' call lineout OutputFile, OutLine end OutLine = '
Previous Years' Reviews
'PreviousYears.i.Year'
' call lineout OutputFile, OutLine /* Jump table to reviews */ OutLine = '' call lineout OutputFile, OutLine /* Jump Table body generation */ do i = 1 to Book.0 OutLine = '' call lineout OutputFile, OutLine OutLine ='' 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 /* review bodies */ do i = 1 to OF.0 OutLine = OF.i call lineout OutputFile, OutLine end /* Standard Footer */ OutLine = '
' Call lineout OutputFile, Outline OutLine = " " call lineout OutputFile, OutLine OutLine = "; Standard element - Last updated, bottom navigation bar and close of BODY and" call lineout OutputFile, OutLine OutLine = "; HTML tags" call lineout OutputFile, OutLine OutLine = '<$Standard_Foot>' call lineout OutputFile, OutLine /* Explisit close of output file */ call lineout OutputFile say 'Close output file' exit