home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: Java / Java.zip / convert.cmd < prev    next >
OS/2 REXX Batch file  |  1998-11-28  |  4KB  |  161 lines

  1. /**/
  2.  
  3.   call RxFuncAdd 'SysLoadFuncs', 'RexxUtil', 'SysLoadFuncs'
  4.   call SysLoadFuncs
  5.  
  6.   say'A utility to convert ALLNames.html to small separate files.'
  7.   say''
  8.   say'This script is hard coded for the ALLNames.html file as delivered with'
  9.   say'the JDK 117ga release.'
  10.   say''
  11.  
  12.   if stream('allnames.html','c','query exists') == '' then do
  13.     say"Can't find ALLNames.html to convert!"
  14.     say''
  15.     say'You must run this rexx script from the \java11\docs\api directory!'
  16.     say''
  17.     exit
  18.     end
  19.  
  20. /* Backup ALLNames.html to ALLNames.html.original */
  21.  
  22.   'copy ALLNames.html ALLNames.html.original'
  23.  
  24. /* Set up anchors */
  25.  
  26.   anchor.1='<a name="Thumb-$"><b> $ </b></a>'
  27.   anchor.2='<a name="Thumb-_"><b> _ </b></a>'
  28.  
  29.   do index = 3 to 28
  30.     anchor.index = '<a name="Thumb-'||d2c(index+62)||'"><b> '||d2c(index+62)||' </b></a>'
  31.     end /* do index */
  32.  
  33. /* Read in ALLNames.html */
  34.  
  35.   if stream('allnames.html','c','query exists') == '' then do
  36.     say"Can't find ALLNames.html to convert!"
  37.     say''
  38.     say'You must run this rexx script from the \java11\docs\api directory!'
  39.     say''
  40.     exit
  41.     end /* if stream */
  42.  
  43.   say'Reading ALLNames.html into memory...'
  44.   say''
  45.  
  46.   an.0=0
  47.   index=0
  48.  
  49.   do while lines('ALLNames.html') > 0
  50.     index=index+1
  51.      an.index=linein('ALLNames.html')
  52.      end /* do while */
  53.  
  54.   an.0 = index
  55.  
  56.   rc = stream('allnames.html','c','close')
  57.  
  58. /* create header */
  59.  
  60.   say'Creating header...'
  61.  
  62.   do index = 1 to an.0
  63.  
  64.     if pos('</h1>', an.index) > 0 then do
  65.       headerstart = 1
  66.       headerend   = index
  67.       leave
  68.       end
  69.   end /* do index */
  70.  
  71. /* modify header */
  72.  
  73.   say'Modifying header...'
  74.  
  75.   do index = headerstart to headerend
  76.  
  77.     pointer =pos('<a href="#Thumb-', an.index)
  78.  
  79.     if pointer > 0 then do
  80.       temp1 =  '<a href="'
  81.       temp2 = substr(an.index, 17,1)
  82.       temp3 = right(an.index, length(an.index)-18)
  83.       an.index = temp1||temp2||'.html"'||temp3
  84.       end /* if pointer */
  85.  
  86.   end /* index */
  87.  
  88.   say'Processing the ALLNames.html file into smaller files...'
  89.   say''
  90.  
  91.   start       = 1
  92.   writefile   = 0
  93.   writeheader = 0
  94.  
  95.   do index = 1 to 28
  96.  
  97.     do allname = start to an.0
  98.  
  99.       if pos(anchor.index, an.allname) > 0 then do
  100.         say an.allname
  101.         writefile   = 1
  102.         writeheader = 0
  103.         end /* if pos */
  104.  
  105.       if writefile = 1 then do
  106.  
  107.         if writeheader = 0 then do
  108.           do header = headerstart to headerend
  109.             call lineout d2c(index+62)||'.html', an.header
  110.             end /* do header */
  111.             end /* if writeheader */
  112.  
  113.         writeheader = 1
  114.  
  115.         if pos('<a name="Thumb-', an.allname) > 0 then do
  116.           letter = substr(an.allname,16,1)
  117.           an.allname='<h2> With names begining with the letter "'||letter||'" </h2>'
  118.           end /* if pos */
  119.  
  120.         call lineout d2c(index+62)||'.html', an.allname
  121.  
  122.           if pos('</dl>', an.allname) > 0 then do
  123.             call lineout d2c(index+62)||'.html'
  124.             writefile = 2
  125.             start = allname
  126.             end /* if pos */
  127.  
  128.       end /* if writefile */
  129.  
  130.       if writefile = 2 then do
  131.         writefile=0
  132.         call lineout d2c(index+62)||'.html', '</body>'
  133.         call lineout d2c(index+62)||'.html', '</html>'
  134.         call lineout d2c(index+62)||'.html'
  135.         leave /* do allname */
  136.         end /* if writefile */
  137.  
  138.     end /* allname */
  139.  
  140.   end /* index */
  141.  
  142.   say'Writing new ALLNames.html file'
  143.   say''
  144.  
  145.   'del ALLNames.html'
  146.  
  147.   do index = headerstart to headerend
  148.     call lineout 'ALLNames.html', an.index
  149.     end /* do index */
  150.  
  151.   call lineout 'ALLNames.html', '</body>'
  152.   call lineout 'ALLNames.html', '</html>'
  153.   call lineout 'ALLNames.html'
  154.  
  155.   say''
  156.   say'Finished!'
  157.   say''
  158.  
  159. exit
  160.  
  161.