Hi,
Does anyone know of a superfast way of counting the number of lines in a text file?
The largest file I have so far is about 40kb, so the files are not too large
Is there an API call to do this that I don't know about?
Cheers,
Brian
The quickest way I can think of is to create a richedit control then
load the richedit with:
QuoteCONTROLCMD (window | dialog, ID, @RTLOAD, FILE | STRING, type)
then get the line count with:
Quotecount = CONTROLCMD ( window | dialog, ID, @RTGETLINECOUNT)
when you create the richedit create it offscreen so the user can't see it.
with coordinates like -1000,0,100,100
LarryMc
Yes this would be fast enough and
maybe this:
IF( Openfile(hFile,filename,"R") = 0)
hsize=0
hsize = Len(hFile)
Allocmem htext,hsize,1
hzero=0
Writemem htext,hsize,hzero
Read hFile,htext
'load memory to pointer
pMem=htext
'load stringPointer to Istring
buffer=#<string>pMem
Freemem htext
Closefile hFile
ENDIF
SHOWWINDOW w1,@swhide,1 'hide richedit if you wish
Setcontroltext w1,1,buffer
'then....
count = CONTROLCMD ( w1, 1, @RTGETLINECOUNT )
Thanks, Guys - I will try them both later tonight
Off now to No 2 Daughter's for my tea!
Brian