home *** CD-ROM | disk | FTP | other *** search
/ Liren Large Software Subsidy 5 / 05.iso / a / a040 / 2.ddi / SHRWARE4.ARC / REPUTIL.INC < prev    next >
Encoding:
Text File  |  1988-06-03  |  2.4 KB  |  108 lines

  1. <<* REPUTIL.INC *>>
  2. <<#
  3.  
  4. procedure GenReportFile
  5. string  lastals
  6. integer lastrow,lastcol
  7.  
  8.  
  9. procedure GenReportFld
  10. integer row,col
  11. string  picstrg,thename
  12. begin
  13.   if fldhor
  14.     row := (fldpag - 1) * 20 + fldrow
  15.   else
  16.     row := (fldpag - 1) * 20 + fldrow + 1
  17.   endif
  18.   col := fldcol
  19.   if fldhor
  20.     col := col + len( fldlab )
  21.   endif
  22.   lastcol := col  <<*Determines last printed col*>>
  23.   gen( '@ ',str( row,2 ),',',str( col,2 ),' SAY ' )
  24.  
  25.     if fldals = 'M'
  26.       thename := fldnam
  27.     else
  28.       thename := fldals + '->' + fldnam
  29.     endif
  30.   if fldtyp = 'C'
  31.     gen( 'TRIM(',thename,')' )
  32.   else
  33.     gen( thename )
  34.   endif
  35.  
  36.   if fldpic
  37.     gen( ' PICTURE "',fldpic,'"' )
  38.   elsif (fldpic = '') and (fldtyp = 'N')
  39.     picstrg := replicate( '9',fldwid )
  40.     if (flddec <> 0)
  41.       picstrg[ fldwid-flddec ] := '.'
  42.     endif
  43.     gen( ' PICTURE "',picstrg,'"' )
  44.   endif
  45.   genln  <<*Send CR/LF*>>
  46. end <<*GenReportFld*>>
  47.  
  48.  
  49. function ScanBuf( startrow,stopcol : integer ) : string
  50. integer len1,len2
  51. string  strg
  52. begin
  53.   strg := substr( textline( startrow ),lastcol+1,stopcol - lastcol )
  54.   strg := rtrim( strg )   <<*if all blanks*>>
  55.   if strg
  56.     len1 := len( strg )
  57.     strg := ltrim( strg )  <<*remove leading blanks*>>
  58.     len2 := len( strg )
  59.     lastcol := lastcol + (len1 - len2)
  60.   endif
  61.   RETURN strg
  62. end <<*ScanBuf*>>
  63.  
  64.  
  65. procedure genTEXT( frow,fcol,fpag : integer )
  66. integer row,offset
  67. string strg
  68. begin
  69.   OFFSET := 20   <<*Offset value to increment 'ROW()' on subsequent pages*>>
  70.   if lastrow < frow   <<*Print text beforehand*>>
  71.     for row := lastrow to (frow - 1)
  72.       strg := ScanBuf( row,80 )  <<*Scan entire line*>>
  73.       if strg
  74.         GenSay( (fpag-1) * OFFSET + row,lastcol,strg )
  75.       endif
  76.       lastcol := 0
  77.     endfor
  78.   endif
  79.   strg := ScanBuf( frow,fcol )
  80.   if strg
  81.     GenSay( (fpag-1) * OFFSET + frow,lastcol,strg )
  82.   endif
  83.   lastrow := frow
  84. end <<*genTEXT*>>
  85.  
  86.  
  87. begin <<*GenReportFile*>>
  88.   lastals := 'A'
  89.   select all
  90.   forall pages
  91.     lastrow := 0
  92.     lastcol := 0
  93.     inittext
  94.     forall (fldtyp $ 'CDLNM') and (fldsay or fldget)  <<*Now, gen @/SAYs*>>
  95.       if fldhor
  96.         genTEXT( fldrow,fldcol + len( fldlab ),fldpag )
  97.       else
  98.         genTEXT( fldrow+1,fldcol,fldpag )
  99.       endif
  100.       GenReportFld
  101.     endfor
  102.     genTEXT( 25,80,pagcount )  <<*Flush the screen buffer*>>
  103.   endfor
  104. end <<*GenReportFile*>>
  105.  
  106. <<* EOF: REPUTIL.INC *>>
  107. #>>
  108.