About end of file (txt)

About end of file (txt)

Postby Wanderson » Mon May 26, 2008 5:26 pm

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.
Wanderson
 
Posts: 332
Joined: Thu Nov 17, 2005 9:11 pm

Postby Jonathan Hodder » Mon May 26, 2008 10:50 pm

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
Jonathan Hodder
 
Posts: 77
Joined: Sun Aug 26, 2007 11:53 pm

Postby Antonio Linares » Mon May 26, 2008 11:04 pm

Wanderson,

This is a real fast way to do it:
Code: Select all  Expand view
    cTxtFile = MemoRead( cRCFile )
      nFrom = 1

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

Antonio Linares
www.fivetechsoft.com
User avatar
Antonio Linares
Site Admin
 
Posts: 41366
Joined: Thu Oct 06, 2005 5:47 pm
Location: Spain

Postby Wanderson » Tue May 27, 2008 3:34 pm

Thanks Antonio and JH.
Wanderson
 
Posts: 332
Joined: Thu Nov 17, 2005 9:11 pm


Return to FiveWin for Harbour/xHarbour

Who is online

Users browsing this forum: No registered users and 29 guests