Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
How to copy text file line by line to memo field?
Message
From
11/07/2006 18:02:41
Dragan Nedeljkovich (Online)
Now officially retired
Zrenjanin, Serbia
 
 
To
10/07/2006 22:59:58
General information
Forum:
Visual FoxPro
Category:
Coding, syntax & commands
Environment versions
Visual FoxPro:
VFP 9 SP1
OS:
Windows XP SP2
Miscellaneous
Thread ID:
01134853
Message ID:
01135543
Views:
16
>Thanks to both Tore and Borislav. After testing, I found Borislav way is much faster, is the ALINES function working faster than MLINE function?

It depends... mline() is counting from the start, so its speed drops linearly with the length of the string, which means that its overall time grows with the square of the length. However, if you supply the third parameter (the offset), then things may change. The last offset is saved in system variable _mline, so this may be faster than without it, specially for large strings, but aLines() is still so much faster:
lcText=FILETOSTR(TRANSFORM(lcfile))
_mline=0
ltStart=SECONDS()
SET MEMOWIDTH TO 16383
nLen=len(lcText)
do while _mline<nLen
   c=MLINE(lcText,1,_mline)
ENDDO
ltend=SECONDS()
?ltend-ltstart

ltStart=SECONDS()
SET MEMOWIDTH TO 16383
n=ALINES(aa, lcText)
FOR i=1 TO n
	c=aa[i]
ENDFOR
ltend=SECONDS()
?ltend-ltstart
I've eliminated the writing into cursor for this benchmark, just to see the net effect of retrieving a line either way. I've created a textfile of about 1.5 megabytes, and the result is about 32 seconds for mline() vs 0.04 seconds for alines(). That's about 800:1 - we have a clear winner here. It was 1000:1 when I had a "do while _mline < len(lcText)" - because then it had to retrieve the length of the lctext for each row.

back to same old

the first online autobiography, unfinished by design
What, me reckless? I'm full of recks!
Balkans, eh? Count them.
Previous
Reply
Map
View

Click here to load this message in the networking platform