Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Why one code works, while other doesn't?
Message
 
 
General information
Forum:
Visual FoxPro
Category:
Coding, syntax & commands
Miscellaneous
Thread ID:
00466654
Message ID:
00466827
Views:
32
>>>As far as effeicent goes, I'd bet that the cursor idea is faster anyways, so yes. You could easily test it out.
>>
>>Yes, cursor idea turns to be a little bit faster. Well, three lines of code comparing with several not always the best way to achieve the result. This is a lesson for me to the future...
>
>Hello, Nadya.
>
>Have you tried? :
>
>
>llReturn = strToFile( strTran( fileToStr( lcFileName ),["],''), lcSendFileName )
>
>
>Although I suspect that the speed would be the same...
set safe off
lcFileName="l:\redp\output\customer\website\ctxa0051.txt"
lcSendFileName="l:\redp\output\customer\website\test.txt"
lnSec=seconds()
? "File To Str Idea"
for i=1 to 5
  llReturn = strToFile( strTran( fileToStr( lcFileName ),["],''), lcSendFileName )
next
?seconds()-lnSec, (seconds()-lnSec)/5
? "Cursor Idea"
lnSec=seconds()
for i=1 to 5
create cursor curWork (workFile M)
append blank
append memo WorkFile from (lcFileName) overwrite
replace workFile with strtran(workFile,["],"")
copy to (lcSendFileName)
use in CurWork
next
?seconds()-lnSec, (seconds()-lnSec)/5
Result:
File to Str:
66.486    13.2972
Cursor Idea:
67.607    13.5124
for 639KB file.
So, you on-liner seems to be faster a little bit. Could you also test it on some file?

Thanks in advance.
If it's not broken, fix it until it is.


My Blog
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform