Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Enhancing Performance
Message
From
20/06/2014 08:25:28
 
 
To
20/06/2014 07:40:56
General information
Forum:
Visual FoxPro
Category:
Coding, syntax & commands
Environment versions
Visual FoxPro:
VFP 9 SP2
OS:
Windows 7
Network:
Windows XP
Database:
Visual FoxPro
Application:
Desktop
Miscellaneous
Thread ID:
01602118
Message ID:
01602121
Views:
119
Hi Harsh:

This is just a quick optimization, because there are few things you haven't explained, as if it is necessary to scan in reverse order or what do the external SCAN is for.
LOCAL lnRecord, lnCount
Insertone=0
Inserttwo=0
lmultipage=.F.

SCAN
	Newpath=Newpath
	*WAIT WINDOW m.Newpath NOWAIT
	*CREATE CURSOR BillFile (POS VARCHAR(254))	&& IF YOU ARE USING THE REAL VARCHAR, YOU ARE USING A MEMO FIELD, WHICH IS SLOOOOWWW
	CREATE CURSOR BillFile (POS C(254))
	APPEND FROM (m.Newpath) SDF

	SELECT BillFile
	lnCount		= 0

	GO BOTTOM
	DO WHILE NOT BOF()
		lnCount	= lnCount + 1

		DO CASE
		CASE LEFT(POS,8)='(Page 1)'
			cTextone='<</Duplex false/PageSize  [595 842] /Tumble false /ManualFeed false /MediaPosition 0>>  setpagedevice'
			Insertone=1
			Inserttwo=0

		CASE LEFT(POS,8)='(Page 3)'
			lmultipage=.T.

		CASE LEFT(POS,8)='(Page 2)'
			Insertone=0
			Inserttwo=1

			IF lmultipage=.T.
				cTexttwo='<</Duplex true /PageSize [595 842]/Tumble false /ManualFeed false /MediaPosition 2>> setpagedevice'
			ELSE
				cTexttwo='<</Duplex false /PageSize [595 842]/Tumble false /ManualFeed false /MediaPosition 2>> setpagedevice'
			ENDIF
			lmultipage=.F.

		CASE LEFT(POS,16)='%%BeginPageSetup'
			IF Insertone=1
				*INSERT BLANK
				*REPLACE POS WITH cTextone
				*SKIP-2
				lnRecord	= RECNO()
				INSERT INTO BillFile (POS) VALUES (cTextone)
				GOTO (lnRecord)
				*--
				Insertone=0
				Inserttwo=0
			ENDIF

		CASE LEFT(POS,16)='%%BeginPageSetup'
			IF Inserttwo=1
				*INSERT BLANK
				*REPLACE POS WITH cTexttwo
				*SKIP-2
				lnRecord	= RECNO()
				INSERT INTO BillFile (POS) VALUES (cTexttwo)
				GOTO (lnRecord)
				*--
				Insertone=0
				Inserttwo=0
			ENDIF
		ENDCASE


		SKIP-1
		
		*-- THIS IS IMPORTANT
		IF MOD(lnCount, 100) = 0
			WAIT WINDOW 'Remaining Records...'+ALLTRIM(STR(RECNO())) NOWAIT
		ENDIF
	ENDDO

	WAIT WINDOW 'Remaining Records...'+ALLTRIM(STR(RECNO())) NOWAIT
	SET TEXTMERGE ON
	SET TEXTMERGE TO (m.Newpath) NOSHOW

	SCAN
\\<< TRIM(POS) >>
\
	ENDSCAN

	SET TEXTMERGE TO
	SET TEXTMERGE OFF
	FLUSH
	SELECT New_bills
ENDSCAN
Best regards!
Fernando D. Bozzo
Madrid / Spain
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform