Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Enhancing Performance
Message
From
20/06/2014 12:26:54
Mike Yearwood
Toronto, Ontario, Canada
 
 
To
20/06/2014 10:21:54
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:
01602138
Views:
89
Hi Harsh

I took the code Fernando Bozzo id for you and I have a few comments to add. Organize your do case in the sequence it will find the pages. See below for more.
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

	*already in BillFile. why select it?
	*SELECT BillFile
	lnCount		= 0

	*already at bottom by append from. why go bottom?
	*GO BOTTOM
	DO WHILE NOT BOF()
		lnCount	= m.lnCount + 1

		lcPOS8 = LEFT(POS,8)
		lcPOS16 = LEFT(POS,16)
		DO CASE
		CASE m.lcPOS8 ='(Page 3)'
			lmultipage=.T.

		CASE m.lcPOS8 ='(Page 2)'
			Insertone=0
			Inserttwo=1

			IF m.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 m.lcPOS8 ='(Page 1)'
			cTextone='<</Duplex false/PageSize  [595 842] /Tumble false /ManualFeed false /MediaPosition 0>>  setpagedevice'
			Insertone=1
			Inserttwo=0

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

		SKIP-1
		
		*-- THIS IS IMPORTANT
		IF MOD(m.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
Previous
Reply
Map
View

Click here to load this message in the networking platform