home *** CD-ROM | disk | FTP | other *** search
/ Liren Large Software Subsidy 5 / 05.iso / a / a070 / 3.ddi / FOXPRO / TEMPLGEN / REPUTIL.INC < prev    next >
Encoding:
Text File  |  1988-02-11  |  2.5 KB  |  112 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 AutoMem
  26.     thename := fldprefix + left( fldnam,10-len(fldprefix) )
  27.   else          
  28.     if fldals = 'M'
  29.       thename := fldnam
  30.     else
  31.       thename := fldals + '->' + fldnam
  32.     endif
  33.   endif
  34.   if fldtyp = 'C'
  35.     gen( 'TRIM(',thename,')' )
  36.   else
  37.     gen( thename )
  38.   endif
  39.  
  40.   if fldpic
  41.     gen( ' PICTURE "',fldpic,'"' )
  42.   elsif (fldpic = '') and (fldtyp = 'N')
  43.     picstrg := replicate( '9',fldwid )
  44.     if (flddec <> 0)
  45.       picstrg[ fldwid-flddec ] := '.'
  46.     endif
  47.     gen( ' PICTURE "',picstrg,'"' )
  48.   endif
  49.   genln  <<*Send CR/LF*>>
  50. end <<*GenReportFld*>>
  51.  
  52.  
  53. function ScanBuf( startrow,stopcol : integer ) : string
  54. integer len1,len2
  55. string  strg
  56. begin
  57.   strg := substr( textline( startrow ),lastcol+1,stopcol - lastcol )
  58.   strg := rtrim( strg )   <<*if all blanks*>>
  59.   if strg
  60.     len1 := len( strg )
  61.     strg := ltrim( strg )  <<*remove leading blanks*>>
  62.     len2 := len( strg )
  63.     lastcol := lastcol + (len1 - len2)
  64.   endif
  65.   RETURN strg
  66. end <<*ScanBuf*>>
  67.  
  68.  
  69. procedure genTEXT( frow,fcol,fpag : integer )
  70. integer row,offset
  71. string strg
  72. begin
  73.   OFFSET := 20   <<*Offset value to increment 'ROW()' on subsequent pages*>>
  74.   if lastrow < frow   <<*Print text beforehand*>>
  75.     for row := lastrow to (frow - 1)
  76.       strg := ScanBuf( row,80 )  <<*Scan entire line*>>
  77.       if strg
  78.         GenSay( (fpag-1) * OFFSET + row,lastcol,strg )
  79.       endif
  80.       lastcol := 0
  81.     endfor
  82.   endif
  83.   strg := ScanBuf( frow,fcol )
  84.   if strg
  85.     GenSay( (fpag-1) * OFFSET + frow,lastcol,strg )
  86.   endif
  87.   lastrow := frow
  88. end <<*genTEXT*>>
  89.  
  90.  
  91. begin <<*GenReportFile*>>
  92.   lastals := 'A'
  93.   select all
  94.   forall pages
  95.     lastrow := 0
  96.     lastcol := 0
  97.     inittext
  98.     forall (fldtyp $ 'CDLNM') and (fldsay or fldget)  <<*Now, gen @/SAYs*>>
  99.       if fldhor
  100.         genTEXT( fldrow,fldcol + len( fldlab ),fldpag )
  101.       else
  102.         genTEXT( fldrow+1,fldcol,fldpag )
  103.       endif
  104.       GenReportFld
  105.     endfor
  106.     genTEXT( 25,80,pagcount )  <<*Flush the screen buffer*>>
  107.   endfor
  108. end <<*GenReportFile*>>
  109.  
  110. <<* EOF: REPUTIL.INC *>>
  111. #>>
  112.