Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
When to Remove Contents of EXPR, TAG and TAG2
Message
From
17/01/2003 15:49:43
 
General information
Forum:
Visual FoxPro
Category:
Reports & Report designer
Miscellaneous
Thread ID:
00742756
Message ID:
00743020
Views:
30
Hi Allan,
When I do this REPORT PATCH, I update the .FRX, build the project and then build the compile.
A friend and I developed a PRG to help do this task.
It is not perfect, but meets my needs.
(1.) Before using this PRG, I copy all of the .FRX / .FRT files and
RPT_PATCH.PRG to C:\MY_TEMP folder.
(2.) I open the Visual FoxPro and run
CD C:\MY_TEMP
(3.) Next, I run
DO RPT_PATCH
(4.) You will be given a chance to select C:\MY_TEMP, so do that.
(5.) It will show you the number of reports it is about to process.
Press the ENTER KEY. All of the reports in this folder will
be processed.
(6.) Copy all of the .FRX / .FRT files back to the project folder.
(7.) Job done!

* Note, the only reason the .FRX / .FRT files are copied to the
C:\MY_TEMP folder is that a DBF of the same name as one
of the reports may exist and it would interfere.
--------------------------------------------------
Here is the PRG:
--------------------------------------------------


*******************************************************************************
* RPT_PATCH.PRG
* Name: Report Patcher
* Function: To remove the printer's information in report files (.FRX and .FRT)
* in a user selected folder.
* Authors: George Liu and Terry Harris
* Date: Oct 19, 2001
* Remark: All the reports in the selected folder must not be opened and
* used by another program.
*******************************************************************************

** BEGIN OF PROGRAM ***********************************************************

DEACTIVATE WINDOW "Project Manager - Njatc"

ON ERROR

* Let the user select the folder to work on
cpath = GETDIR()

IF LEN(cpath) > 0 && If user cancels the selection, the program will end.
CHDIR(cpath) && Change current directory to the user selected folder
* Create an array to contain the list of all reports.
nnumberofreports = ADIR(areportarray, "*.FRX")
IF nnumberofreports = 0 then
= MESSAGEBOX("No report files found in " + cpath + ".")
ELSE
CLEAR
* Give the Operator some visual feedback.
? "Number of Reports: ", nnumberofreports
? " "
WAIT
* Work on reports one by one.
FOR i = 1 TO nnumberofreports
* Get the file name and trim the extension.
sfile = LEFT(ALLTRIM(areportarray(i,1)), ;
LEN(ALLTRIM(areportarray(i,1)))-4)

CLEAR
? "FILE NUMBER AND NAME: ", i, sfile
? " "

* Convert files.
* Make sure DBF file DOES NOT EXIST before doing a RENAME.
IF FILE(sfile + ".DBF")
CLEAR
? "FILE ALREADY EXISTS!: ", sfile + ".DBF"
? " "
WAIT
ELSE
* "File does not exist..."
* Change report file to table file.
commandstring = sfile + ".FRX TO " + sfile + ".DBF"
RENAME &commandstring
ENDIF

* Make sure that the FRT exists before doing a RENAME.
IF FILE(sfile + ".FRT")
* "File exists..."
* Change report memo file to table memo file.
commandstring = sfile + ".FRT TO " + sfile + ".FPT"
RENAME &commandstring
* Work on the file.
* Open the file.
commandstring = sfile + " EXCLUSIVE" && File opened exclusively
USE &commandstring
LOCATE FOR objtype = 1 && Locate the record for report info

IF FOUND()
* Store certain info in the EXPR MEMO field to MVARS.
aa = MLINE(EXPR,ATCLINE("ORIENTATION",EXPR))
bb = MLINE(EXPR,ATCLINE("PAPERSIZE",EXPR))
cc = MLINE(EXPR,ATCLINE("PAPERLENGTH",EXPR))
dd = MLINE(EXPR,ATCLINE("PAPERWIDTH",EXPR))

** Note, if "PAPERSIZE" (or any other search string)
* is not in the EXPR MEMO field, the MVAR (aa, bb,...)
* will be formed in memory and will be set to the
* empty string "".

* Remove the Printer specific info from these MEMO fields.
REPLACE EXPR WITH aa + CHR(13) + bb + CHR(13) + cc + CHR(13) + dd
REPLACE TAG WITH ""
REPLACE tag2 WITH ""

* Pack and Close the file.
PACK && Make sure the info was removed completely.
ELSE
CLEAR
? "OBJTYPE = 1 NOT FOUND IN FILE: ", sfile
? " "
WAIT
ENDIF

USE IN &sfile && Close the file

* Convert files.
* Change table file back to report file.
commandstring = sfile + ".DBF TO " + sfile + ".FRX"
RENAME &commandstring
* Change table memo file back to report memo file
commandstring = sfile + ".FPT TO " + sfile + ".FRT"
RENAME &commandstring
ELSE
? "File DOES NOT exist: ", sfile + ".FRT"
? " "
WAIT
ENDIF
ENDFOR
= MESSAGEBOX("All files were processed successfully.")
ENDIF
ELSE
= MESSAGEBOX("Action Canceled by the user.")
ENDIF

** END OF PROGRAM *************************************************************


Feel free to use this code anyway you like.
If you improve on it, I would like to see it.
Thanks,
Terry Harris
terryyy@yahoo.com



>Cindy & Don,
>
>The page size is letter and I did not remove the settings in the previous version of the software. None of the end-users had any problems (that I know of).
>This .exe is going out in BETA to another end-user followed soon by more installations (again to new end-users). I would like to take whatever steps I can to minimize the support calls but I also don't want to create any problems where there were not any previously.
>So, given the above, do I update the .FRX, build the project and then build the compile?
>TIA.
>
>>>I am in the process of distributing an application as an .exe.
>>>Should the contents of the EXPR, TAG and TAG2 fields in the FRX files of reports be deleted prior to the compiliation?
>>>If so, why (or why not)?
>>
>>If the printers your users have are very different from the one you are using the printer-specific information in the reports could cause problems. That's the purporse for the deletions. However, you should delete only the printer-specific information. That means everything in Tag1 and Tag2, but the Expr field is a different story. Here's one I have:
>>
>>DRIVER=winspool
>>DEVICE=\\NetworkPrinterNameHere
>>OUTPUT=\\NDPS01
>>ORIENTATION=0
>>PAPERSIZE=9
>>COPIES=1
>>DEFAULTSOURCE=1
>>PRINTQUALITY=600
>>COLOR=1
>>YRESOLUTION=600
>>TTOPTION=2
>>
>>You would probably want to keep the Orientation, Papersize, and Copies lines. You can find project hook routines to clear this stuff when you build your project.
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform