LOCAL lnRecord, lnCount Insertone=0 Inserttwo=0 lmultipage=.F. SET STEP ON CREATE CURSOR newbills (newpath c(20)) INSERT INTO newbills (newpath) VALUES ('test.txt') SCAN Newpath=Newpath CREATE CURSOR BillFile (POS C(254),nSequence n(10,4)) APPEND FROM (m.Newpath) SDF REPLACE ALL nSequence WITH RECNO() INDEX ON nSequence TAG xSeq DESCENDING lnCount = 0 *already at bottom by replace *already in descending order by index SCAN && 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() lnSeq1 = nSequence SKIP lnSeq2 = nSequence INSERT INTO BillFile (POS,nSequence) VALUES (m.cTextone,m.lnSeq1 + ((m.lnSeq2-m.lnSeq1)/2)) GOTO m.lnRecord *-- Insertone=0 Inserttwo=0 ENDIF ENDCASE *-- THIS IS IMPORTANT IF MOD(m.lnCount, 100) = 0 WAIT WINDOW 'Remaining Records...'+ALLTRIM(STR(RECNO())) NOWAIT ENDIF ENDSCAN 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 ENDSCAN>Yes Sir it was a repeatation. I corrected it. Thanks a lot.