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