home *** CD-ROM | disk | FTP | other *** search
/ Merciful 1 / Merciful - Disc 1.iso / software / r / rexx_plus_compiler / rexxpluscompiler2.dms / in.adf / Examples / lstsrc.rexx < prev    next >
Encoding:
OS/2 REXX Batch file  |  1991-08-28  |  3.5 KB  |  192 lines

  1. /* generate list of a any source file */
  2. trace off
  3.  signal on BREAK_C
  4.  say 'time='time('e')
  5.  parse arg srcnam '\' optn
  6.  
  7.  parse upper value optn with 'PITCH='pitch .
  8.  if pitch = '' then pitch = '0f'
  9.  pitch = x2c(pitch)
  10.  
  11.  parse upper value optn with 'SPACE='space .
  12.  if space = '' then space = 1
  13.  
  14.  parse upper value optn with 'MARGIN='margin .
  15.  if space = '' then margin = 0
  16.  
  17.  parse upper value optn with 'LINES='parm1 .
  18.  if datatype(parm1,'N') = 0
  19.  then do
  20.     parm1 = 50
  21.     end
  22.  
  23.  parse value optn with '>'parm2 .
  24.  if parm2 = ''
  25.  then parm2 = 'prt:'
  26.  
  27.  srcnam = trim(srcnam)
  28.  
  29.  date = date('W') date('U') time()
  30.  
  31.  call open('list',parm2,'W')
  32.  call writech('list','1b7703'x) 
  33.   
  34.  openstat =  open('srctxt',srcnam,'R')
  35.  if openstat = 0
  36.    then do 
  37.      say 'FILE NOT FOUND ('srcnam')'
  38.      exit 
  39.    end
  40.  
  41.    say srcnam
  42.    linect = 0
  43.    pagect = 0
  44.  
  45.    hd1 = ''
  46.    hd2 = ''
  47.    hd3 = ''
  48.  
  49.    call sethd
  50.  
  51.    do forever
  52.      if eof('srctxt') then leave
  53.  
  54.      if linect = 0
  55.        then do
  56.           pagect = pagect + 1
  57.       srcnam = substr(srcnam,1,30)
  58.           call writech('list','12'x) 
  59.           prtline = 'FILE: 'srcnam 'DATE: 'date'     PAGE: 'pagect
  60.           call writeln('list',prtline)
  61.           call writeln('list',prtline)
  62.       call writech('list',pitch) 
  63.       if hd1 ~= ''
  64.       then do
  65.         call writeln('list',' ')
  66.         call writeln('list',hd1)
  67.         call writeln('list',' ')
  68.         linect = linect + 3
  69.         end
  70.       if hd2 ~= ''
  71.       then do
  72.         call writeln('list',hd2)
  73.         linect = linect + 1
  74.         end
  75.       if hd3 ~= ''
  76.       then do
  77.         call writeln('list',hd3)
  78.         linect = linect + 1
  79.         end
  80.           call writeln('list',' ')
  81.           call writeln('list',' ')
  82.        end   
  83.  
  84.      linect = linect + 1
  85.      call writeln('list',record)
  86.      do space-1
  87.     linect = linect + 1
  88.     call writeln('list','')
  89.     end
  90.  
  91.      if linect > parm1
  92.      then do 
  93.        linect = 0
  94.        call writech('list','0c'x) 
  95.        end 
  96.  
  97.      call sethd
  98.  
  99.    end 
  100.    if linect > 0
  101.    then do 
  102.      call writech('list','0c'x) 
  103.      end 
  104.  
  105.    call writech('list','12'x) 
  106.    call close('srctxt')
  107.    call close('list')
  108.    say 'time='time('e')
  109.    exit
  110.  
  111. sethd:
  112.  signal on break_c
  113.    do forever
  114.     record = readln('srctxt')
  115.     parse value record with op h a v
  116.     parse value record with ':'opc'.'.
  117.     select
  118.         when op = '.set'
  119.         then do
  120.             if a ~= '=' then return
  121.             if h = 'hd1' then hd1 = v
  122.             if h = 'hd2' then hd2 = v
  123.             if h = 'hd3' then hd3 = v
  124.             end
  125.         when op = '.cp'
  126.         then do
  127.             if h = '' then h = parm1
  128.             if parm1 - linect  - h <= 0
  129.             then do
  130.                 linect  = 0
  131.                 call writech('list','0c'x) 
  132.                 end
  133.             end
  134.         when op = '.df'
  135.         then do
  136.             parse value record with '.df' font data
  137.             df.font = data
  138.             end
  139.         when op = '.bf'
  140.         then do
  141.             parse value record with '.bf' font .
  142.             if df.font = 'DF.'font
  143.             then 
  144.                 say 'Font' font 'not defined.'
  145.             else
  146.                 call writech('list',df.font)
  147.             end
  148.         when opc = 'ol'
  149.         then do
  150.             if ol = 'OL' then ol = 0
  151.             ol = ol + 1
  152.             ol.ol = 0
  153.             end
  154.         when opc = 'ul'
  155.         then do
  156.             if ol = 'OL' then ol = 0
  157.             ol = ol + 1
  158.             ol.ol = substr('o+*-',ol,1)
  159.             end
  160.         when opc = 'li'
  161.         then do
  162.             parse value record with ':'opc'.'record
  163.             if ol.ol = 'OL.'ol
  164.             then say not within list
  165.             else do
  166.                 if datatype(ol.ol,'n')
  167.                 then do
  168.                     ol.ol = ol.ol+1
  169.                     record = ol.ol'). 'record
  170.                     end
  171.                 else
  172.                     record = ol.ol'   'record
  173.                 end
  174.             return
  175.             end
  176.         when opc = 'eol' | opc = 'eul'
  177.         then do
  178.             drop ol.ol
  179.             if ol = 'OL' then ol = 0
  180.             ol = ol - 1
  181.             if ol < 0 then say eol error
  182.             end
  183.         otherwise
  184.             return
  185.         end
  186.        if eof('srctxt') then return
  187.     end
  188.     return
  189.  
  190. BREAK_C:
  191.     exit
  192.