FiveTech Support Forums

FiveWin / Harbour / xBase community
Board index FiveWin for Harbour/xHarbour Alternative to memoline()
Posts: 1096
Joined: Fri Oct 28, 2005 02:27 AM
Alternative to memoline()
Posted: Mon Apr 27, 2015 06:54 AM

I need to parse a tab-delimited text file so I use the usual memoread() and memoline().

But I just realized memoline() convert tabs into spaces. Is there any alternative to it?

TIA

FWH 11.08/FWH 19.12

BCC5.82/BCC7.3

xHarbour/Harbour
Posts: 663
Joined: Mon Dec 05, 2005 11:22 PM
Re: Alternative to memoline()
Posted: Mon Apr 27, 2015 01:43 PM

Check out ttxtfile class.
Example in samples folder testfile.prg

Posts: 1096
Joined: Fri Oct 28, 2005 02:27 AM
Re: Alternative to memoline()
Posted: Tue Apr 28, 2015 01:39 AM

Thanks Gale!

I was hoping for an alternative to memoline() so that don't have to resort to low level file manipulation. I am under the impression reading the whole file using memoread() and then extracting the lines from it would be faster

FWH 11.08/FWH 19.12

BCC5.82/BCC7.3

xHarbour/Harbour
Posts: 663
Joined: Mon Dec 05, 2005 11:22 PM
Re: Alternative to memoline()
Posted: Tue Apr 28, 2015 03:36 AM

if you look at ttxtfile it works very nice. very easy to open file. skip through file and read each line/record.

Posts: 10733
Joined: Sun Nov 19, 2006 05:22 AM
Re: Alternative to memoline()
Posted: Tue Apr 28, 2015 04:00 AM

TTxtFile is good.

Another alternative is :

cText := MemoRead( "myfile.txt" )
aLines := HB_ATokens( StrTran( cText, CRLF, Chr( 10 ) ), Chr( 10 ) )

Regards



G. N. Rao.

Hyderabad, India
Posts: 1096
Joined: Fri Oct 28, 2005 02:27 AM
Re: Alternative to memoline()
Posted: Tue Apr 28, 2015 04:33 AM

Thank you both of you :D

FWH 11.08/FWH 19.12

BCC5.82/BCC7.3

xHarbour/Harbour

Continue the discussion