/* Convert HTML tags to uppercase */ /* Display blank line */ Say /* Leave debug information on errors */ Signal On Error Name Quit Signal On Failure Name Quit Signal On Halt Name Quit Signal On Syntax Name Quit /* Initialize RexxUtil */ If RxFuncQuery( "sysloadfuncs" ) <> 0 Then Do Call RxFuncAdd "sysloadfuncs", "RexxUtil", "sysloadfuncs" Call sysloadfuncs End /* Parse command line parameter(s) */ Parse Upper Arg infiles dummy If dummy <> "" Then Call Syntax If infiles = "" Then Call Syntax /* Check if file(s) exist */ Call SysFileTree infiles, "infile.", "F" If infile.0 = 0 Then Call Syntax "File not found: "||infiles /* Covert tags in all specified files to uppercase */ Do i = 1 To infile.0 Call CheckTags infile.i End Exit CheckTags: Procedure Expose outfile /* Parse argument(s) */ infile = Arg( 1 ) Parse Value infile With . . size . file file = Strip( file ) Parse Upper Value file With outfile".HTM" outfile = outfile||".UPC" /* Read file */ allstring = CharIn( file, 1, size ) Call LineOut file /* Find all tags and convert them */ newstring = "" convert = 1 Do forever Parse Value allstring With string"<"tag">"allstring If tag = "" Then Do Leave End newtag = ConvertTag( tag ) If newtag = "/SCRIPT" Then convert = 1 If convert = 1 Then tag = newtag Say "Converted tag: <"||tag||">"||"0D0A"X newstring = newstring||string||"<"||tag||">" If left( newtag, 6 ) = "SCRIPT" Then convert = 0 End If allstring <> "" Then newstring = newstring||allstring /* Save results */ Call charout outfile, newstring Call LineOut outfile Return ColorConvert: procedure expose outfile /* Parse argument(s) */ args = Arg( ) string = Arg( 1 ) If string > 1 Then Do i = 2 To args string = string||","||Arg( i ) End /* Check if string is hex color designation */ /* and convert to uppercase if true */ If Length( string ) = 7 Then Do If Left( string, 1 ) = "#" Then Do If DataType( Right( string, 6 ), "X" ) = 1 Then Do string = Translate( string ) End End End Return string ConvertTag: procedure expose outfile /* Parse argument(s) */ args = Arg( ) tag = Arg( 1 ) If args > 1 Then Do i = 2 To args tag = tag||","||Arg( i ) End Say "Original tag: <"||tag||">" /* First, remove line breaks from within tag */ Do Until break = 0 break = Pos( "0D0A"X, tag ) If break > 1 Then Do tag = SubStr( tag, 1, break - 1 )||" "||, SubStr( tag, break + 2 ) End End /* Then, check for literals within tag */ If Pos( '"', tag ) = 0 Then Do newtag = Translate( tag ) End Else Do newtag = "" Do Until qposo = 0 qposo = pos( '"', tag ) If qposo > 1 Then Do newtag = newtag||Translate( SubStr( tag, 1, qposo ) ) tag = SubStr( tag, qposo + 1 ) End qposc = Pos( '"', tag ) If qposc > 1 Then Do qstr = SubStr( tag, 1, qposc - 1 ) newtag = newtag||ColorConvert( qstr )||'"' tag = SubStr( tag, qposc + 1 ) End Else Do If qposc = 1 Then Do newtag = newtag||'"' tag = SubStr( tag, 2 ) End Else Leave End End If tag <> "" Then newtag = newtag||tag End Return newtag Quit: Procedure Expose outfile /* Close output file and end program */ Call LineOut outfile Exit Return Syntax: Procedure Expose outfile Parse arg errmsg If errmsg <> "" Then Say "Error:"||"0D0A"X||errmsg||"0D0A0D0A"X Say "HTMLTags.rex, Version 2.01" Say "Convert HTML tag commands to uppercase for readability and to conform to" Say "original HTML specifications" Say Say "Usage: HTMLTAGS.REX " Say Say 'Result: Converted file with name of HTML file and extension ".UPC"' Say Say "Written by Rob van der Woude" Say "http://www.robvanderwoude.com" Call Quit Return