This seems to work, Thanks to all above.
There could be a better way to copy to new file, but I could not figure out. So I used the old way.
Give a try with your big file. You mentioned sometimes you may want to a different number of records
Here you can enter the number of records to skip.
You could also enter a spot to name the file for new text.
Code: Select all
#include "hmg.ch"
#include "FILEIO.CH"
Function Main()
CRTEMP()
Return
Function CrTemp
Local YOURFILE := 'YOURFILENAME.TXT' //PUT YOUR FILE NAME HERE
Local yourrec := 0 , yourrec1 := 0, c1Line := "", prow := 0
yourrec := val(alltrim(inputbox('Enter Number Of Records To Skip Up From Bottom')))
HB_Fuse(YOURFILE)
c1Line:= HB_FLastRec()-(yourrec-1)
HB_FGoBottom()
if HB_FLastRec() > yourrec
yourrec1:= HB_FlastRec()-yourrec+1
HB_FGoto(yourrec1)
else
HB_FGoTop()
endif
c1Line := HB_FReadLN()
SET PRINTER TO 'NEWFILE.TXT'
SET DEVICE TO PRINT
SET PRINT ON
DO WHILE ! HB_FEof()
@ Prow+1,1 SAY c1Line
HB_FSkip()
c1Line := HB_FReadLN()
Prow:=Prow+1
loop
ENDDO
SET DEVICE TO SCREEN
SET PRINTER TO
HB_FGoBottom()
HB_FUse()
RETURN
Franco