Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Westi on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Find and replace a specific expression within multiple reports

Status
Not open for further replies.

montypython1

Technical User
Jan 12, 2005
187
US
Greetings,

Is there a quick way to find and replace a specific variable expression within multiple reports?

I would prefer to not have to open 20 different reports (1 at a time), then click REPORT, then click VARIABLES, then select the appropriate variable expression, then update the expression. And repeat 19 more times.

Any ideas?

Thanks,
Dave
 
Since a VFP report is just another form of data table (albeit with an FRX file extension) you can write a little program to search for the expression.

If I were doing this I would first find a report where I KNEW that the expression was present.
Then I would USE MyReport.frx and find the field where the expression 'lives'.
Finally with that knowledge I could create a program which would do an ADIR() to find all of the FRX files and then loop through them looking for the expression and make the needed change in the report's table.

Good Luck,
JRB-Bldr
 
Thanks JRB-Bldr,

That may be a little out of my comfort zone, but I will give it a try when I get back to my office tomorrow.

Thank you for the quick response.

Dave
 

Dave,

First, make a copy of your report (both files, .FRX and .FRT) before you open it as a table.

Second, study your table thoroughly (say, make a note that ObjType for report variables should be 18, the variables' names are stored in the memo field Name, and the expressions are stored in the memo field Expr, etc.).

Third, make sure you know what to do so the results of your changes would be valid (in size, style, etc.)

I once had a somewhat similar task. I had several columns (not only detail, but also group footers, many rows of summary, etc.) that contained a year-to-year change, some in absolute numbers, and some percentage-wise. The request I got was, in addition to showing the negative sign where the numbers went down (which, as you understand, was showing automatically), to show also the positive sign where the numbers went up.

For that, I had to change formats and expressions of the appropriate columns. It didn't help that the columns in question didn't have any particular expression to search for, but it did help that I knew for sure where they were located. So I opened the report as a table and studied it thoroughly to understand what fields exactly I needed to change and in what way. The result of this was the following little program:
Code:
rptName=[C:\myPath\myReport.frx]
nColumns=4

DIMENSION arColumn(nColumns), arFormat(nColumns)

arColumn(1)=33854.167
arColumn(2)=42187.500
arColumn(3)=64062.500
arColumn(4)=71354.167

arFormat(1)=[999,999,999]
arFormat(2)=[9999.9]
arFormat(3)=[999,999,999]
arFormat(4)=[9999.9]

cPart1=[IIF(]
cPart2=[>0,'+','')+ALLT(TRAN(]
cPart3=[,"]
cPart4=["))]

*==========================================

USE (rptName) IN 0 EXCLUSIVE ALIAS Report

SELECT Report

FOR i=1 TO nColumns
   REPLACE   Picture      WITH "", ;  
             FillChar     WITH "C", ;
             Offset       WITH 1, ;
             Expr         WITH cPart1+ALLTRIM(Expr)+ ;
                   cPart2+ALLTRIM(Expr)+cPart3+arFormat(i)+cPart4 ;
      FOR ObjType=8 AND hPos=arColumn(i) AND ('9'$Picture OR '#'$Picture) AND ;
          !"TRAN"$UPPER(Expr)

	&& With this, we replace the numeric expression with a character one, 
	&&	blank out the numeric format, and set up right justification.

NEXT

I faced some problems, though.
VFP (at least, the version 6 we still use) has a limit on the length of a report expression - 254 symbols. If you change the expressions interactively, the expression dialog invoked by the report designer wouldn't let you go beyond that. But if you open the report as a table, expression fields are, in fact, memo fields, and you can put there anything you want - but you might get an error once you try to open the file as a report, not a table. So after the change, some of the expressions have gone over the limit slightly. I had to think of a way to fix it. For example, I had to create memory variable to store format expressions (like "999,999,999.99") for the TRANSFORM() function, and to use them instead.
 
Check GoFish.app v3.1 Global String Search/Edit/Replace
I really don't know what I could do w/o it.
BTW in VFP 9 you have "Code reference" tool under Tools menu. That could do the same thing.

Borislav Borissov
VFP9 SP2, SQL Server 2000/2005.
Microsoft MVP VFP
 
Hi Dave,

Do you have VFP9? If so, as Borislav says, it's a simple matter to do a search and replace using Tools -> Code References -> Search -> Replace.

Jim
 
Thank you all for your suggestions ... and my humble apologies for not responding ... I was out of town this past week and just returned.

I am trying your suggestions this evening and will let you know how everything turned out.

Thanks again.
Dave

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top