About end of file (txt)

Post Reply
Wanderson
Posts: 332
Joined: Thu Nov 17, 2005 9:11 pm

About end of file (txt)

Post by Wanderson »

Hello

Look that code please

Resp := LOpen("TEXTO.TXT",0)
Do While .t.
Resp1 := cFReadLine(Resp)

========> why i can test end of file to abort this while?

Loop
Enddo

Thanks
Wanderson.
Jonathan Hodder
Posts: 77
Joined: Sun Aug 26, 2007 11:53 pm

Post by Jonathan Hodder »

I modify incoming formats this way

getcFile := cGetFile32("Print Files (*.ofx; *.ofc)| *.ofx; *.ofc |" ,"Please select a file",1)

nBinary := FOPEN(getcFile)
IF (nError := FERROR()) # 0
MsgInfo('Cannot open '+getcFile+CRLF+::FError(nError))
ELSE
MEMORY(-1) // Maybe not necessary now
IF FREADln(nBinary, @cBuffer, 32768, CHR(0))
// CR & LF is stripped out and LF placed in the correct position
// STRTRAN( <cString>, <cLocString>, <cRepString>, <nPos>, <nOccurences> ) --> cReturn
cBuffer := STRTRAN(cBuffer, CHR(13)) //replace CR with Null
cBuffer := STRTRAN(cBuffer, CHR(10)) //replace LF with Null
cXML := STRTRAN(cBuffer, '<', CHR(10)+'<') //replace < with <LF
ENDIF
FCLOSE(nBinary)

// then saved to a new file
cXMLBnkStment := SUBSTR(getcFile,1,RAT('\',getcFile))+'BNKSTMT.XML'
nHandle:=FCREATE(cXMLBnkStment)
FWRITE(nHandle, cXML)
FCLOSE(nHandle)

It's very fast with xHarbour
Hope this helps

JH
User avatar
Antonio Linares
Site Admin
Posts: 37481
Joined: Thu Oct 06, 2005 5:47 pm
Location: Spain
Contact:

Post by Antonio Linares »

Wanderson,

This is a real fast way to do it:

Code: Select all

    cTxtFile = MemoRead( cRCFile ) 
      nFrom = 1 

      while nFrom < Len( cTxtFile ) 
         cLine = ExtractLine( cTxtFile, @nFrom ) 
         ... 
         SysRefresh() 
      end 
regards, saludos

Antonio Linares
www.fivetechsoft.com
Wanderson
Posts: 332
Joined: Thu Nov 17, 2005 9:11 pm

Post by Wanderson »

Thanks Antonio and JH.
Post Reply