Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
How to copy text file line by line to memo field?
Message
De
11/07/2006 18:02:41
Dragan Nedeljkovich
Now officially retired
Zrenjanin, Serbia
 
 
À
10/07/2006 22:59:58
Information générale
Forum:
Visual FoxPro
Catégorie:
Codage, syntaxe et commandes
Versions des environnements
Visual FoxPro:
VFP 9 SP1
OS:
Windows XP SP2
Divers
Thread ID:
01134853
Message ID:
01135543
Vues:
17
>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.
Précédent
Répondre
Fil
Voir

Click here to load this message in the networking platform