Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Parameters Command Giving .F
Message
From
05/02/2014 12:19:35
 
 
To
03/02/2014 11:49:48
Mike Yearwood
Toronto, Ontario, Canada
General information
Forum:
Visual FoxPro
Category:
Coding, syntax & commands
Environment versions
Visual FoxPro:
VFP 9 SP2
OS:
Windows XP
Network:
Windows XP
Database:
Visual FoxPro
Application:
Desktop
Miscellaneous
Thread ID:
01592937
Message ID:
01593294
Views:
36
Sir Thank you very much for the detail explaination. I will make changes accordingly. However perhaps I will have to Recreate BILLCOMPRESS Cursor each time for Each file because I am taking Text inside File in Cursor , EDITING it and RE WRITING the same.

Using a Single cursor for all the Files and Rewrting the entire file at once may create complication in Editing. Moreover since the number of text files to be edited are in millions, the VFP may give 2 GB error also.

What do You say. Here is a Part of My code
Select NEW_BILLS
LOCAL iPSFILE       as Character
LOCAL oPSFILE      as Character
Scan  && Scans for New_bills up to EOF()
*Define Variables
	iPSFILE=Alltrim(Fullpath)
	LSPECIALTHREE=.T.
	DINVOICEDATE=Ctod('15/08/2100')
	oPSFILE=Alltrim(NEWPATH)
DO Compr WITH iPSFILE,oPSFILE
ENDSCAN
*********************************************************************************************************************************************************************************************************************************************************
Update Final Page Calculation in New_bills
Replace All MP_ORG With 1,;
	SP_ORG With TP_ORG-1,;
	MP_CHG With 1,;
	SP_CHG With TP_CHG-1;
	,SAVINGS With TP_ORG-TP_CHG
Sum MP_ORG To MPCOUNT
Sum SP_ORG To SPCOUNT_ORG
Sum SP_CHG To SPCOUNT_CHG
Wait Clear
*********************************************************************************************************************************************************************************************************************************************************
PROCEDURE Compr
PARAMETERS iPSFILE,oPSFILE
Create Cursor BILLCOMPRESS (POS C(254))  && Create Temporary Cursor Billcompress to Check Page Numbers,Compressed File and Invoice Date.
Select BILLCOMPRESS
Append From (m.iPSFILE) Sdf && Appends in Standard Data Format
*Count Number of Pages in PS File
	Go 4
	LNPAGECOUNT = Val(Getwordnum(POS, Getwordcount(POS) - 0)) && Counts the Number of Initial Pages in PS File
**********************************************************************************************************************************************************************************************************************************************************
*Check Whether The user is Licensed Holder or Not
	Locate For Alltrim(Strextract(POS,'(',')'))='Bhopal  Telecom  District' && Locates that whether Bhopal Telecom District is in the Bill or Not
	If Found()
		CLICENSEHOLDER=.T. && The User is a Valid License Holder
	Else
		CLICENSEHOLDER=.F.&& The User is a Not a Valid License Holder
	Endif
**********************************************************************************************************************************************************************************************************************************************************
*Check For The Invoice Date. It will Be Used to Give DEMO Version of The Software For Limited Period
	Locate For Left(Strextract(POS,'(',''),12)='Invoice Date' && Locates for Text Invoice Date
	If Found()
		DINVIOCEDATE=Ctod(Right(Strextract(POS,'(',')'),10))
		If  DINVIOCEDATE<Ctod('31/08/2013')
			LDATE=.T.
		Else
			LDATE=.F.
		Endif
	Else
		LDATE=.F.
	Endif
**********************************************************************************************************************************************************************************************************************************************************
	Use In BILLCOMPRESS && De Select Billcompress
**********************************************************************************************************************************************************************************************************************************************************
*PROGRAM RE-STARTS FORM HERE
**********************************************************************************************************************************************************************************************************************************************************
	CLICENSEHOLDER=.T.  && Temporary
	LDATE=.T.

	If m.LDATE=.T. And m.CLICENSEHOLDER=.T. && IF the file not compressed and Date is Valid than we Can Start Compression
		Select NEW_BILLS
*For Page Equal to One
		If LNPAGECOUNT=1
			Create Cursor BILLCOMPRESS (PS C(254))
			Append From (m.iPSFILE) Sdf
			Locate For Alltrim(PS)='%%Page: 1 1'
			If Found()
			Skip
			Replace PS With '<</Duplex false>> setpagedevice'
			Insert Blank
			Replace PS With '<</Duplex false /PageSize  [595 842] /Tumble false>> statusdict begin 0 setpapertray end'
			Endif
			Set Textmerge On
			Set Textmerge To (m.oPSFILE) Noshow
			Scan
\\<< TRIM(PS) >>
\
			Endscan
			Set Textmerge To
			Set Textmerge Off
			Select NEW_BILLS
			Replace TP_ORG With 1, TP_CHG With 1 && Replace Total Number of Pages (Original) In Cursor New_bills
		Endif
*************************************************************************************************************************************************************
>Hi Harsh
>
>LOCAL variables are restricted to the current code. That is the best way to go. I congratulate your choice. Because they are restricted you must pass them to called routines/modules/components. Others might suggest you use PRIVATE so they would be visible to the called module. That is a riskier approach. You should aim to make your routines encapsulated.
>
>You could do this...
>
>
LOCAL lcPSFILEPATH, lcNEWPATH
>Select NEW_BILLS
>Scan  && Scans for New_bills up to EOF()
>lcPSFILEPATH=Alltrim(NEW_BILLS.oldpath)
>lcNEWPATH=Alltrim(NEW_BILLS.NEWPATH)
>
>DO Compress with m.lcPSFILEPATH, m.lcNEWPATH
>
>ENDSCAN
>
>Use LPARAMETERS not PARAMETERS
>Change the variable names to indicate they are received in this routine
>and are not the same ones DEFINED in the calling program.
>The reason is the compress module is then completely self-contained - "encapsulated".
>
>
PROCEDURE Compress
>LPARAMETERS m.tcPSFILEPATH,m.tcNEWPATH
>Create Cursor BILLCOMPRESS (POS C(254))  && Create Temporary Cursor Billcompress to Check Page Numbers,Compressed File and Invoice Date.
>Select BILLCOMPRESS
>WAIT WINDOW m.tcPSFILEPATH
>WAIT WINDOW m.tcNEWPATH
>Append From (m.tcPSFILEPATH) Sdf  && Nothing is appeneded as I get .F. as value for m.tcPSFILEPATH
>ENDPROC
>
>
>BUT - I would have created cursor billcompress in the calling code. Your compress routine is not doing anything significant yet. It will be slow. The cursor is destroyed and recreated as the scan runs. This is what I have been asking you to do. Explain what you want to do then we can show you a more complete example which will be fast, efficient. The append from is not really part of the work of compressing the sdf.
>
>I am going to assume you intend to do something with the SDF file - maybe drop some stuff from it, so it is smaller (compressed - which is the name of the called routine).
>
>
>Here's what I'd do...
>
>
>LOCAL m.lcPSFILEPATH, m.lcNEWPATH
>Create Cursor BILLCOMPRESS (POS C(254))  && Create Temporary Cursor Billcompress to Check Page Numbers,Compressed File and Invoice Date.
>Select NEW_BILLS
>Scan
>  lcPSFILEPATH=Alltrim(NEW_BILLS.oldpath)
>  lcNEWPATH=Alltrim(NEW_BILLS.NEWPATH)
>  SELECT BILLCOMPRESS
>  Append From (m.lcPSFILEPATH) Sdf
>  DO Compress with m.lcPSFILEPATH, "BILLCOMPRESS", RECNO("BILLCOMPRESS")
>ENDSCAN
>
>PROCEDURE Compress
>LPARAMETERS m.tcPSFILEPATH, m.tcAlias, m.tnRec
>SELECT (m.tcAlias)
>GO m.tnRec
>*Process the POS field.
>ENDPROC
>
>OR!
>
>You could do the appends in the calling code and then do the compressing on all the appended records. I'm separating the processing into clear logical blocks. Each module does one thing clearly.
>
>
>LOCAL m.lcPSFILEPATH, m.lcNEWPATH
>Create Cursor BILLCOMPRESS (POS C(254))  && Create Temporary Cursor Billcompress to Check Page Numbers,Compressed File and Invoice Date.
>Select NEW_BILLS
>Scan
>  lcPSFILEPATH=Alltrim(NEW_BILLS.oldpath)
>  lcNEWPATH=Alltrim(NEW_BILLS.NEWPATH)
>  SELECT BILLCOMPRESS
>  Append From (m.lcPSFILEPATH) Sdf
>ENDSCAN
>DO Compress with m.lcPSFILEPATH, "BILLCOMPRESS"
>
>PROCEDURE Compress
>LPARAMETERS m.tcPSFILEPATH, m.tcAlias
>SELECT (m.tcAlias)
>SCAN
>*Process the POS field.
>ENDSCAN
>ENDPROC
>
>
>
>
>>I am using the following code. I am not getting the value for cPSFILEPATH,cNEWPATH in my compress procedure. Instead I am getting .F.
>>
>>What is the correct code. Kinldy Advice.
>>
>>
>>
>>Select NEW_BILLS
>>LOCAL cPSFILEPATH as Character
>>LOCAL cNEWPATH as Character
>>
>>Scan  && Scans for New_bills up to EOF()
>>*Define Variables
>>cPSFILEPATH=Alltrim(oldpath)
>>cNEWPATH=Alltrim(NEWPATH)
>>DO Compress
>>ENDSCAN
>>
>>PROCEDURE Compress
>>PARAMETERS cPSFILEPATH,cNEWPATH
>>Create Cursor BILLCOMPRESS (POS C(254))  && Create Temporary Cursor Billcompress to Check Page Numbers,Compressed File and Invoice Date.
>>Select BILLCOMPRESS
>>WAIT WINDOW cPSFILEPATH
>>WAIT WINDOW cNEWPATH
>>Append From (m.cPSFILEPATH) Sdf  && Nothing is appeneded as I get .F. as value for cPSFILEPATH
>>ENDPROC
>>
>>
Harsh
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform