Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Share my bitter experience...
Message
 
 
To
All
General information
Forum:
Visual FoxPro
Category:
Reports & Report designer
Title:
Share my bitter experience...
Miscellaneous
Thread ID:
00456312
Message ID:
00456312
Views:
70
Hi everybody,

As some of us can see from several recent threads, I was struggling with VFP Report Writer recently trying to produce ASCII file from quite complicated report. Well, this battle won Report Writer and I'm defeated... But, not completely. I found my work around this problem. Basically, the problem is:
if you have multiple entries in any of the band (detail, footer, group footer, etc.), the ASCII file would insert additional blank lines, truncate words, do other "bad" things and there is nothing you can do about it regardless of different _asciirows, _asciicols settings (or at least I could not find this magic combination). The answer is: either redesign your Report again, say, in DOS FPD (VFP can run it, I was told) or use another Report Writer (I don't know, does Crystall support ASCII clause properly) or do it programmatically (the way I finally choose). Therefore this is a program, which would convert your report into prg file. Well, you still then need to work a little on this program manually, but the most work is already done.
*******************************************************************************************
*  Description.......: ReportToAscii - this program uses ReportFile as Input Table 
*                      and results a program to produce the same Output (as Report should produce)
*  Calling Samples...: ReportToAscii("Galley","g:\redp\appl\Special\Progs\GalleyRpt.prg")
*  Parameter List....: tcReportFile, tcProgramFile
*  Created by........: Nadya Nosonovsky 12/22/2000 10:09:26 AM 
*  Modified by.......: 
********************************************************************************************
lparameters tcReportFile, tcProgramFile
local lcReportName, lcProgramName, lnAnswer
if empty(tcReportFile) or vartype(tcReportFile)<>'C'
    lcReportName='Galley.frx'
else
    lcReportName=forceext(tcReportFile,"frx")
endif        
if !file(lcReportName) && Report file doesn't exis
    =messagebox("File "+lcReportName+" is not found!",48,"Error")
    return .f.
endif
if empty(tcProgramFile) or vartype(tcProgramFile)<>'C'
    lcProgramName='Galley.prg'
else
    lcProgramName=forceext(tcProgramFile,"prg")
endif        
if file(lcProgramName)
   lnAnswer=messagebox("File "+lcProgramName+ " already exists. Do you want to re-create it?",36,"File exists")
   if lnAnswer=7 && No
      return .f.
   else
      erase (lcProgramName)   
   endif
endif      
local lcStr, lcHeader, lcBegin, lcEnd
select expr, supexpr, vpos, hpos from (lcReportName) ;
into cursor curReport where inlist(objtype,5,8) order by 3,4 
#define LCRF chr(10)
lcStr=''
lcHeader="#define LCRF chr(10)"+LCRF+"local lcStr"+LCRF+"* Open table here, then scan ... endscan ..."+LCRF
lcBegin="lcStr=lcStr+"
lcEnd="+LCRF"
scan 
  if not empty(supexpr)
     lcStr=LcStr+"if "+alltrim(supexpr)+LCRF+ ;
     space(6)+lcBegin+alltrim(expr)+lcEnd+LCRF+"endif"+LCRF
  else
     lcStr=LcStr+lcBegin+alltrim(expr)+lcEnd+LCRF
  endif
endscan
*=messagebox(lcStr)
=strtofile(lcHeader+lcStr,lcProgramName)
If it's not broken, fix it until it is.


My Blog
Next
Reply
Map
View

Click here to load this message in the networking platform