Rob van der Woude's Scripting Pages
Powered by GeSHi

Source code for alphabet.rex

(view source code of alphabet.rex as plain text)

  1. /* Create an alphabet for HTML files */
  2.  
  3. /* Display blank line */
  4. Say
  5.  
  6. /* Initialize RexxUtil library */
  7. if RxFuncAdd( 'sysloadfuncs', 'RexxUtil', 'sysloadfuncs' ) = 0 then do
  8. 	call sysloadfuncs
  9. end
  10. else do
  11. 	call Syntax "Could not initialize RexxUtil."
  12. end
  13.  
  14. /* Check command line parameter */
  15. Parse Arg html dummy .
  16. If dummy <> "" Then Call Syntax "Please specify only 1 HTML file."
  17. If html  =  "" Then Call Syntax "Please specify an HTML file."
  18. If Pos( "?", html ) > 0 Then Call Syntax
  19.  
  20. /* Check if file exists */
  21. Call SysFileTree html, files.
  22. If files.0 = 1 Then Do
  23. 	Parse Value files.1 with . . size . html
  24. 	html = Strip( html )
  25. End
  26. Else Do
  27. 	Call Syntax "Specified file not found."
  28. End
  29.  
  30. /* Check extension of specified file */
  31. lmth = Reverse( html )
  32. Parse Upper Value lmth With txe"."eman"\".
  33. If Right( txe, 3 ) <> "MTH" Then Call Syntax "Please specify HTML files only."
  34.  
  35. /* Define output file name */
  36. alph = Reverse( eman )||".SRC"
  37.  
  38. /* Check if file exists */
  39. Call SysFileTree alph, files.
  40. If files.0 <> 0 Then Call Syntax "Output file already exists."
  41.  
  42. /* Create output file */
  43. Call LineOut alph, ""
  44.  
  45. /* Check if file exists */
  46. Call SysFileTree alph, files.
  47. If files.0 <> 1 Then Call Syntax "Error creating output file."
  48.  
  49. /* Read HTML file into 1 single string */
  50. strHTML = CharIn( html, 1, size )
  51.  
  52. /* Create table header */
  53. Call LineOut alph, '<TABLE BORDER="0" WIDTH="100%">'
  54. Call LineOut alph, '<TR>'
  55.  
  56. /* Create entries for numbers and for each letter of the alpabet */
  57. Call Entry "0", "0..9"
  58. Call Separator
  59. Do i = 65 By 1 To 89
  60. 	Call Entry D2C( i )
  61. 	Call Separator
  62. End
  63. Call Entry "Z"
  64.  
  65. /* Close table */
  66. Call LineOut alph, '</TR>'
  67. Call LineOut alph, '</TABLE>'
  68.  
  69. /* Close output file */
  70. Call LineOut alph
  71.  
  72. /* Done */
  73. EXIT 0
  74.  
  75.  
  76. Entry:
  77. 	Parse Arg link, descr
  78. 	If descr = "" Then descr = link
  79. 	strChk = '<A NAME="'||link||'">'
  80. 	resChk = Pos( strChk, strHTML )
  81. 	if resChk = 0 Then Do
  82. 		Call LineOut alph, '    <TD><FONT COLOR="Gray">'||link||'</FONT></TD>'
  83. 	End
  84. 	Else Do
  85. 		Call LineOut alph, '    <TD><A HREF="#'||link||'">'||descr||'</A></TD>'
  86. 	End
  87. Return
  88.  
  89.  
  90. Separator:
  91. 	Call LineOut alph, '    <TD><FONT SIZE="+6">|</FONT></TD>'
  92. Return
  93.  
  94.  
  95. Syntax:
  96. 	Parse Arg error
  97. 	If error <> "" Then Do
  98. 		Say error
  99. 		Say
  100. 	End
  101. 	Say "Alphabet.rex,  Version 1.01"
  102. 	Say "Create an HTML table to navigate a specified HTML file alphabetically"
  103. 	Say
  104. 	Say "Usage:    <REXX>  ALPHABET.REX  html_file"
  105. 	Say
  106. 	Say 'Where:    "<REXX>" is your Rexx interpreter:'
  107. 	Say "                   - Windows:  REGINA.EXE with RexxUtil installed"
  108. 	Say "                               (RexxUtil is not compatible with REXX.EXE)"
  109. 	Say "                   - OS/2:     no need to specify, just rename script to *.cmd"
  110. 	say
  111. 	Say "Output:   HTML table code in a file with name of HTML file and"
  112. 	Say '          extension ".SRC", located in current directory.'
  113. 	say
  114. 	Say "Written by Rob van der Woude"
  115. 	Say "http://www.robvanderwoude.com"
  116.  
  117. 	EXIT 1
  118. Return
  119.  

page last modified: 2024-04-16; loaded in 0.0050 seconds