Retail POS

www.pcland.com.pk

Saturday 5 April 2014

Clear Printer "Saved Environment" in VFP FRX Programatically

Visual Fox pro Report Designer 

Microsoft Visual Foxpro 9 Report Designer  has a new feature  to "Save Printer Environment" at report Design time. This feature was not available in previous versions of Visual Fox pro i.e VFP6,7,8

Application Implementation: 

Many of VFP developers face problem when they launch their developed Desktop application project on client machine due to difference of Printer model.

 There might be several reasons but most common/major reason are :

  • Different Printer Model availability  at client premises which is not compatible with Printer driver selected  at report design time.
  • By developers  mistake Wrong Selection of Printer model at Report Design time.

Regenrate Project & Generate New EXE
 :

Ultimately they have to regenerate their application  from source code & amend the FRX, save & re-compile the project to generate new app/exe. This makes wastage of time and today's era time is the money.

Solution:
Resting value of "Save Printer Environment" in  a few reports will be easy but in bulk number will be a quite difficult and time consuming. so how can we reduce this time by programmatically, i have written bellow code which we can use to reset to default (do not save printer environment) of all reports in few seconds.
***********************************************
**  Reset_frxenv.prg
**  clear flag of 'save Printer Environment' 
**  Used in FRX files
**  Programmed : Zia Mughal
**  Copy Right (R) Pcland Software Inc.Pakistan
**
************************************** 
CLOSE DATABASES
=adir(frxlist,"*.frx")
create table frxname ( fname c(30))
index on fname tag fname
USE
IF ! USED("frxname.dbf")
USE frxname ALIAS frxname again IN 11
ENDIF

SELECT frxname
append from array frxlist
IF ! BOF()
GO top
ENDIF

SCAN
SELECT frxname
if rest_prn_env(fname)= .f.
MESSAGEBOX('Error Reseting Environment in report file: ' +fname,0+16,;
"Pcland.com.pk")
ENDIF
ENDSCAN

MESSAGEBOX('All files converted Successfully: ',0+64,"Pcland.com.pk")

RETURN

**************************************
FUNCTION rest_prn_env
************************************** 
PARAMETERS lcfrxfile
LOCAL lcstatus, lCstring, lfile

STORE .f. TO lcstatus
lcstring = 'ORIENTATION=0' +CHR(13) + 'PAPERSIZE=9';
 + CHR(13) + 'COLOR=1'
IF ! FILE(lcfrxfile)
RETURN lcstatus
ENDIF

IF ! USED(lcfrxfile)
USE &lcfrxfile ALIAS rstfrx IN 1
ENDIF

SELECT rstfrx
IF ! BOF()
GO top
ENDIF

REPLACE [expr] WITH lcstring
replace [tag] WITH ''
replace [tag2] WITH ''
STORE .t. TO lcstatus

SELECT rstfrx
USE &lcfrxfile
RETURN lcstatus
ENDFUNC 
************************************************ 

Hope this will help Programmers to save their valuable time.
cheers!

Mr Jun Tangunan had briefly explained in his blog on the topic "when to save and when not to!"
http://sandstorm36.blogspot.com.au/2014/01/printer-environment-on-report-when-to.htm

No comments:

Post a Comment