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 gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Which reports in your project have got "Printer Environment" ticked? 1

Status
Not open for further replies.

Mike Lewis

Programmer
Jan 10, 2003
17,516
Scotland
Over in thread184-1813451, we fount that a particular report problem arose because the report had the "Printer Environment" setting ticked (in the Report menu). This is usually undesirable. So the question arose of whether there was some automatic way of checking for this.

With that in mind, I put together this very simple program.

Code:
* List the report files within the active project, with an indication
* of whether "Printer Environment" was ticked.

* NOTE: Absolutely no guarantee that this will work 100% of the time. It is based
* only on my attempts to understand the FRX structure, not on any
* documented behaviour. -- M.L. Jan '22.

* Create a cursor to store the results
CREATE CURSOR RepFiles (RepName c(32), EnvClear L)

oProj = _vfp.ActiveProject
FOR EACH oFile IN oProj.Files
  IF oFile.Type = "R"
    * This is a report file
    USE (oFile.Name) IN 0 ALIAS CurRep
    SELECT CurRep
    llClear = (EMPTY(Tag) AND EMPTY(Tag2) AND AT("DEVICE", UPPER([highlight #FCE94F]Expr[/highlight])) = 0)
    INSERT INTO RepFiles (RepName, EnvClear) VALUES (JUSTSTEM(oFile.Name), llClear)
    USE IN CurRep
  ENDIF 
ENDFOR

* In the resulting cursor, EnvClear will be .F. if Printer Environment
* is ticked.
SELECT RepFiles
BROWSE NOWAIT

Please note the comment about it not guaranteed to be 100% correct. If anyone can improve it, please do so - in particular the line that begins with [tt]llClear =[/tt]

EDIT:
I just noticed a possible mistake in the above code, which I have now fixed (indicated by the yellow highlight).

Mike

__________________________________
Mike Lewis (Edinburgh, Scotland)

Visual FoxPro articles, tips and downloads
 
Hi Mike

Having been introduced to VFP in version 3, I think that was not an option - it was the default situation. So, along with removing
(well obscuring) references to potentially existing databases from data environments, I started running a bit of code before each compile
which managed the print environment to suit me... not very pretty, but it has served me well through 3, 5, 7 and 9 (no doubt some posters will
just think it lazy or unnecessary, but it works very well).

Code:
*:   FIXPRNT
PRIVATE m.FLG, m.STRING1,m.STRING2,m.ORIENTATION,m.DUPLEX
SET TALK OFF
CRLF = CHR(13)+CHR(10)
m.STRING1 = "DRIVER=WINSPOOL"+CRLF
m.STRING2 = "PAPERSIZE=9"+CRLF
m.STRING2 = m.STRING2 + "DEFAULTSOURCE=7"+CRLF
m.STRING2 = m.STRING2 + "PRINTQUALITY=600"+CRLF
m.STRING2 = m.STRING2 + "YRESOLUTION=600"+CRLF
m.STRING2 = m.STRING2 + "TTOPTION=1"+CRLF
m.PROJNAME = LEFT("MyProject"+SPACE(50),50)
m.PROJDIR = LEFT("d:\dev\MyProject"+SPACE(50),50)
CLEAR
@ 10,10 SAY "Project Main File"
@ 10,30 GET m.PROJNAME PICTURE "@!"
@ 11,10 SAY "Project Directory"
@ 11,30 GET m.PROJDIR PICTURE "@!"
READ
CLEAR GETS
IF LASTKEY() <> 27
	CLOSE ALL
	USE (TRIM(m.PROJDIR)+"\"+TRIM(m.PROJNAME)+".PJX") ALIAS PROJNAME EXCLUSIVE
	GO TOP
	DO WHILE .NOT. EOF()
		DO CASE
		CASE TYPE= "R" .AND. UPPER(PROJNAME.KEY) <> "DTAFILES"
			? PROJNAME.KEY
			SELECT 0
			USE (TRIM(m.PROJDIR)+"\"+TRIM(PROJNAME.KEY)+".FRX") ALIAS REPTNAME EXCLUSIVE
			DO CASE
			CASE "ORIENTATION=0"$UPPER(REPTNAME.EXPR)
				m.ORIENTATION="0"
			CASE "ORIENTATION=1"$UPPER(REPTNAME.EXPR)
				m.ORIENTATION="1"
			OTHERWISE
				m.ORIENTATION="0"
			ENDCASE
			DO CASE
			CASE "DUPLEX=1"$UPPER(REPTNAME.EXPR)
				m.DUPLEX="1"
			CASE "DUPLEX=2"$UPPER(REPTNAME.EXPR)
				m.DUPLEX="2"
			OTHERWISE
				m.DUPLEX="0"
			ENDCASE
			REPLACE REPTNAME.EXPR WITH m.STRING1+"ORIENTATION="+m.ORIENTATION+CRLF+"DUPLEX="+m.DUPLEX+CRLF+m.STRING2
			REPLACE REPTNAME.TAG WITH ""
			REPLACE REPTNAME.TAG2 WITH ""
			PACK
			USE
		CASE TYPE= "B" .AND. UPPER(PROJNAME.KEY) <> "DTAFILES"
			? PROJNAME.KEY
			SELECT 0
			USE (TRIM(m.PROJDIR)+"\"+TRIM(PROJNAME.KEY)+".LBX") ALIAS LABLNAME EXCLUSIVE
			DO CASE
			CASE "ORIENTATION=0"$UPPER(LABLNAME.EXPR)
				m.ORIENTATION="0"
			CASE "ORIENTATION=1"$UPPER(LABLNAME.EXPR)
				m.ORIENTATION="1"
			OTHERWISE
				m.ORIENTATION="0"
			ENDCASE
			REPLACE LABLNAME.EXPR WITH m.STRING1+"ORIENTATION="+m.ORIENTATION+CRLF+m.STRING2
			REPLACE LABLNAME.TAG WITH ""
			REPLACE LABLNAME.TAG2 WITH ""
			PACK
			USE
		ENDCASE
		SELECT PROJNAME
		SKIP
	ENDDO
	SELECT PROJNAME
	PACK
	USE
ENDIF

CLOSE ALL

Regards

Griff
Keep [Smile]ing

There are 10 kinds of people in the world, those who understand binary and those who don't.

I'm trying to cut down on the use of shrieks (exclamation marks), I'm told they are !good for you.
 
Having been introduced to VFP in version 3, I think that was not an option - it was the default situation.

If I remember rightly, Griff, the default (before VP 9.0) was to not save the printer settings in the report, unless you explicitly changed them.

In other words, if you were in the report designer, and you then went to File -> Page Setup -> Print Setup, and you changed the settings (page size, source and orientation), then VFP would save all the printer settings with the report and the user would not be able to override them at run time (equivalent to ticking "Printer Environment" in the report designer).

But if you stayed away from the printer settings in the report designer, then everything would work as expected.

At least, that's how I remember it. I might be wrong.

Either way, I can see what you are doing in the code that you posted. I think that nowadays you could probably achieve the same result simply by setting Expr, Tag and Tag2 to an empty string, but correct me if I am wrong.

Mike

__________________________________
Mike Lewis (Edinburgh, Scotland)

Visual FoxPro articles, tips and downloads
 
You are probably right, I think that is why I wrote it - on the advice (I *think*, it was a few years ago 1996-97?) of the M$ support line.

Likewise the snippet that refers all data environments to a 'very unlikely' folder - because VFP used to 'remember' where
the data was in the dev environment, and go there by preference (unless it did not exist) in the production one.





Regards

Griff
Keep [Smile]ing

There are 10 kinds of people in the world, those who understand binary and those who don't.

I'm trying to cut down on the use of shrieks (exclamation marks), I'm told they are !good for you.
 
Hi,

In all my reports (I have hundreds of them…) the printer environment is allways diabled. I have a tool somewhere that checks the setting for all files if needed.

I have built a form editor for endusers of my VFP applications and the printer environment for new reports is off by default.

Regards, Gerrit
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top