Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Strict Dimension Report
Message
General information
Forum:
Visual FoxPro
Category:
Reports & Report designer
Miscellaneous
Thread ID:
00342403
Message ID:
00343407
Views:
24
Hi Craig

It's pretty difficult to control printers from Fox. Among other things, we sometimes need to choose portrait or landscape orientation. Yes we can decide to use landscape during creation of the report. The problem is that when you send the report off to another user with another printer or you decide to use another printer or your own machine, it's propably not going to work very well. But, as you might know, pretty much everything in fox is a table in one way or another. Including the .frx or report file.
You can do some really interesting things with the .frx file when you open it as a table (make workarounds for the shortcomings of Fox reports, setting different colors than the color-picker let you and very much more).
I will not dig too deep into that now, other than state that we can take advantage of the fact that Fox store some printer-specific information to the tag and tag2 fields in the .frx file at the time you create a report.
I haven't figured out all the information in the two tag-fields yet (you might want to try), but I found what I needed at the time the procedure below was written though.

Before calling the routine we have chosen a report to run (m.rptfil), and we have chosen the orientation of the report (m.nOrient)

When you call this procedure :
-A empty table is created
-A new report is created for the empty table
-The new report is opened as a table
-The tag-fields are copied.
-We replace the character in position 45 with 2 or 1 respectively
-The real report is opened as a table
-The tag-fields in the real report-table is replaced with the values from the temporary file

There are some advantages of doing this. 1. We replace the values that were created on our machine with whatever printerdriver we were using at the time the report was created the first time, with printer information for the current printer and the current user. This is propably better than assuming that the user has the same printer as we do. 2. We now have a opportunity to change other properties as well.

That'll do for now, please let me know if I can be of any assistance.


PROCEDURE getori
**********************************************************
***: Create dummy to get tag og tag2 in order to choose landscape or portrait etc.
**********************************************************
PRIVATE m.tag2, m.tag, Uni, tmpSel
PRIVATE m.ordsel

m.ordsel = SELECT()

m.tag2 = ""
m.tag = ""
uni = SYS(2023) + "\" + SYS(3) &&make unique string
SELECT 0
tmpSel = SELECT()
CREATE TABLE (uni) (dummy D) && create a emtpty table with one field
USE

IF FILE(uni + ".DBF") &&Check to see if creation of table went well
CREATE REPO (uni) FROM (uni + ".DBF") &&Create the dummy report
IF FILE(uni + ".FRX")
USE (uni+".frx") IN 0 ALIAS dumrepo &&use the report as a table
SELECT dumrepo
m.tag2 = tag2 && Get the to tag-fields
m.tag = tag
USE
DELE FILE (uni +".FRX") && and clean up
DELE FILE (uni +".FRT")
SELE (tmpSel)
USE
DELE FILE (uni +".DBF")
ENDIF
ENDIF

**-- Choose landscape or portrait
IF !EMPTY(m.tag2)
IF m.nOrient = 2
**--landscape
m.tag2 = STUFF(m.tag2,45,1,CHR(2))
ELSE
**--portrait
m.tag2 = STUFF(m.tag2,45,1,CHR(1))
ENDIF
ENDIF

**-- replace tag and tag2 in the real report table
IF FILE(rptfil + ".FRX")
USE (rptfil + ".FRX") IN 0 ALIAS rpt
SELECT rpt
GO TOP
REPLACE tag WITH m.tag
REPLACE tag2 WITH m.tag2
USE
ENDIF

SELECT (m.ordsel)

RETURN

************************************************************
Birger G. Thoresen

Pek og Klikk
Previous
Reply
Map
View

Click here to load this message in the networking platform