home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 35 Internet / 35-Internet.zip / www2htm1.zip / we2htm.cmd < prev   
OS/2 REXX Batch file  |  1997-09-05  |  5KB  |  195 lines

  1. /* we2htm.cmd */
  2. /* by Jerry L. Rowe Copyright 1997 */
  3. /* jlrowe@iquest.net */
  4. /* Thursday - 09/04/97 10:55pm */
  5.  
  6. /* reads the Webexplorer INI file and generates an HTML page from the Quicklist */
  7. /* Suitable for cut and paste to your own web page */
  8. /*  */
  9. Call RxFuncAdd 'SysLoadFuncs','REXXUTIL','SysLoadFuncs';
  10. Call SysLoadFuncs;
  11.  
  12. we_ini = 'explore.ini'
  13. html = 'we2htm.htm'
  14.  
  15. html_top.0=12
  16. html_top.1='<!DOCTYPE HTML PUBLIC "-//W3 Organization//DTD W3 HTML 2.0//EN">'
  17. html_top.2='<html>'
  18. html_top.3='<head>'
  19. html_top.4='<title>Webexplorer Quicklist to HTML Conversion'
  20. html_top.5='</title>'
  21. html_top.6='</head>'
  22. html_top.7='<body>'
  23. html_top.8='<h1><center>'
  24. html_top.9='WebExplorer to HTML Conversion'
  25. html_top.10='</center></h1>'
  26. html_top.11='<hr>Generated: '||date('N') ||' -- ' || time('C')|| '<hr>' 
  27. html_top.12='<UL>'
  28.  
  29. html_bot.0=4
  30. html_bot.1='</UL>'
  31. html_bot.2='<hr><ADDRESS>Program by: <A HREF="mailto:jlrowe@iquest.net"><I>Jerry L. Rowe</I></A></address><hr>'
  32. html_bot.3='</body>'
  33. html_bot.4='</html>'
  34.  
  35.  
  36. /* Locate explore.ini file */
  37.  
  38. env = 'OS2ENVIRONMENT'
  39. etc = value('etc',,env)
  40. if etc = '' then
  41. do
  42.   say 'Error: The TCP/IP etc environment variable is not set.'
  43.   exit
  44. end
  45. we_inifile = etc || '\' || we_ini
  46. html_file = etc || '\' || html
  47.  
  48. do forever
  49.   dump = linein(we_inifile);
  50.   if dump = "[quicklist]" then
  51.     leave
  52. end
  53.  
  54. part.1='<LI><A HREF="'
  55. part.2='">'
  56. part.3='</A>'
  57.  
  58. cmd='@del ' || html_file
  59. cmd
  60. rc=lineout(html_file,,1)
  61. do n=1 to html_top.0
  62.    rc=lineout(html_file,html_top.n)
  63. end /* do */
  64.  
  65. cnt=1
  66. do forever
  67.   ql.title.cnt = ""
  68.   ql.title.cnt = linein(we_inifile);
  69.   ql.url.cnt   = linein(we_inifile);
  70.  
  71.   if strip(ql.title.cnt) = "" then do
  72.      cnt=cnt-1
  73.      leave
  74.   end /* do */
  75.  
  76.   parse var ql.title.cnt 'quicklist= ' ql.title.cnt
  77.  
  78.   say cnt ql.title.cnt ql.url.cnt
  79.  
  80.   cnt=cnt+1
  81.  
  82. end /* do */
  83.  
  84.  
  85. /* write unsorted list to file */
  86.  
  87. rc=lineout(html_file,'<A NAME="unsort"><h2>Unsorted Listing</h2>')
  88. rc=lineout(html_file,'<A HREF="we2htm.htm#unsort">[Unsorted]-</a><A HREF="we2htm.htm#urlsort">[URL sorted]-</a><A HREF="we2htm.htm#titlesort">[Title sorted]</a>')
  89. rc=lineout(html_file,'<p>')
  90.  
  91. do nn=1 to cnt
  92.   url_line=part.1||ql.url.nn||part.2||ql.title.nn||part.3
  93.   say url_line
  94.   rc=lineout(html_file,url_line)
  95. end /* do */
  96.  
  97.  
  98. rc=lineout(html_file,'<p>')
  99. rc=lineout(html_file,'<A NAME="urlsort"><h2>Sorted by URL</h2>')
  100. rc=lineout(html_file,'<A HREF="we2htm.htm#unsort">[Unsorted]-</a><A HREF="we2htm.htm#urlsort">[URL sorted]-</a><A HREF="we2htm.htm#titlesort">[Title sorted]</a>')
  101. rc=lineout(html_file,'<p>')
  102.  
  103.  
  104. /* Sort by URL */
  105. Do i = 1 to cnt
  106.         var1.i=ql.url.i
  107.         var2.i=ql.title.i
  108.         End
  109.  
  110. Say
  111. Say 'Sorting ...'
  112.  
  113. Call BubbleSort 
  114. /* and display the sorted array */
  115.  
  116. Do i = 1 to cnt
  117.         ql.url.i=var1.i
  118.         ql.title.i=var2.i
  119.         url_line=part.1||ql.url.i||part.2||ql.title.i||part.3
  120.         say url_line
  121.         rc=lineout(html_file,url_line)
  122.         url_line='<br>___'||ql.url.i
  123.         rc=lineout(html_file,url_line)
  124.         End
  125.  
  126.  
  127. rc=lineout(html_file,'<p>')
  128. rc=lineout(html_file,'<A NAME="titlesort"><h2>Sorted by Title</h2>')
  129. rc=lineout(html_file,'<A HREF="we2htm.htm#unsort">[Unsorted]-</a><A HREF="we2htm.htm#urlsort">[URL sorted]-</a><A HREF="we2htm.htm#titlesort">[Title sorted]</a>')
  130. rc=lineout(html_file,'<p>')
  131.  
  132.  
  133. /* Sort by Title */
  134.  
  135. Do i = 1 to cnt
  136.         var2.i=ql.url.i
  137.         var1.i=ql.title.i
  138.         End
  139.  
  140. Say
  141. Say 'Sorting ...'
  142.  
  143. Call BubbleSort 
  144.  
  145. Do i = 1 to cnt
  146.         ql.url.i=var2.i
  147.         ql.title.i=var1.i
  148.         url_line=part.1||ql.url.i||part.2||ql.title.i||part.3
  149.         say url_line
  150.         rc=lineout(html_file,url_line)
  151.         End
  152.  
  153.  
  154. rc=lineout(html_file,'<p>')
  155. rc=lineout(html_file,'<A HREF="we2htm.htm#unsort">[Unsorted]-</a><A HREF="we2htm.htm#urlsort">[URL sorted]-</a><A HREF="we2htm.htm#titlesort">[Title sorted]</a>')
  156.  
  157. /* Write bottom of file */
  158. do n=1 to html_bot.0
  159.    rc=lineout(html_file,html_bot.n)
  160. end /* do */
  161.  
  162. rc=lineout(html_file)
  163. rc=lineout(we_inifile)
  164.  
  165. say
  166. say 'Wrote ' cnt ' URLs to ' html_file
  167.  
  168. return   /*    the program        */
  169.  
  170. /* ==================================================================== */
  171.  
  172. /* ========================================== */
  173. BubbleSort: procedure expose cnt var1. var2.
  174.  
  175. say cnt var1.1 var2.1
  176. Do i = 1 to cnt
  177.         Do j = i+1 to cnt
  178.                 IF var1.i > var1.j Then Call Swap i j var1. var2.
  179.                 
  180.         End
  181. end
  182. Return
  183.  
  184. Swap: procedure expose i j var1. var2.
  185.  
  186. /* Say 'Swapping var1.'i '('var1.i') and var1.'j '('var1.j')' */
  187. tmp = var1.i
  188. tmp2= var2.i
  189. var1.i = var1.j
  190. var2.i=var2.j
  191. var1.j = tmp
  192. var2.j=tmp2
  193. Return
  194.  
  195.