Alternative to memoline()

Alternative to memoline()

Postby hua » Mon Apr 27, 2015 6: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
hua
 
Posts: 1038
Joined: Fri Oct 28, 2005 2:27 am

Re: Alternative to memoline()

Postby Gale FORd » Mon Apr 27, 2015 1:43 pm

Check out ttxtfile class.
Example in samples folder testfile.prg
Gale FORd
 
Posts: 663
Joined: Mon Dec 05, 2005 11:22 pm
Location: Houston

Re: Alternative to memoline()

Postby hua » Tue Apr 28, 2015 1: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
hua
 
Posts: 1038
Joined: Fri Oct 28, 2005 2:27 am

Re: Alternative to memoline()

Postby Gale FORd » Tue Apr 28, 2015 3:36 am

if you look at ttxtfile it works very nice. very easy to open file. skip through file and read each line/record.
Gale FORd
 
Posts: 663
Joined: Mon Dec 05, 2005 11:22 pm
Location: Houston

Re: Alternative to memoline()

Postby nageswaragunupudi » Tue Apr 28, 2015 4: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
User avatar
nageswaragunupudi
 
Posts: 10248
Joined: Sun Nov 19, 2006 5:22 am
Location: India

Re: Alternative to memoline()

Postby hua » Tue Apr 28, 2015 4:33 am

Thank you both of you :D
FWH 11.08/FWH 19.12
BCC5.82/BCC7.3
xHarbour/Harbour
hua
 
Posts: 1038
Joined: Fri Oct 28, 2005 2:27 am


Return to FiveWin for Harbour/xHarbour

Who is online

Users browsing this forum: cmsoft and 67 guests