Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Help on FileToStr() and ChrTran() functions
Message
From
10/05/2001 18:50:14
 
General information
Forum:
Visual FoxPro
Category:
Coding, syntax & commands
Miscellaneous
Thread ID:
00505649
Message ID:
00506052
Views:
29
replace() v. strtran(), replacements 7396

replace 1    0.460999999995693

replace 2    0.489999999997963

strtran 1    10.8859999999986

chrtran() v. strtran(), replacements 159218

strtran 2    12.55799999999726

chrtran 2    0.370000000002619
These results from the code below should be interesting (note the replace times.)
output = ""
strContents = filetostr( "c:\temp\War_and_peace.txt" )

output = output + "replace() v. strtran(), replacements "
output = output + trans( occurs( 'was', strContents ) )

output = output + "replace 1"
ss = seconds()
loRegExp = createobject( "VBScript.RegExp" )
loRegExp.pattern = "was"
loRegExp.IgnoreCase = .f.
loRegExp.global = .t.
 = loRegExp.replace( strContents, "Z~Z" )
output = output + trans( seconds() - ss ) + chr(10)+chr(13)

output = output + "replace 2"
ss = seconds()
 = loRegExp.replace( strContents, "Z~Z" )
output = output + trans( seconds() - ss ) + chr(10)+chr(13)

output = output + "strtran 1"
ss = seconds()
 = strtran( strContents, 'was', 'Z~Z' )
output = output + trans( seconds() - ss ) + chr(10)+chr(13)

output = output + "chrtran() v. strtran(), replacements "
output = output + trans( occurs( 's', strContents ) )

output = output + "strtran 2"
ss = seconds()
 = strtran( strContents, 's', 'a' )
output = output + trans( seconds() - ss ) + chr(10)+chr(13)

output = output + "chrtran 2"
ss = seconds()
 = chrtran( strContents, 's', 'a' )
output = output + trans( seconds() - ss ) + chr(10)+chr(13)

*!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! don't do this - SLOW !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
*!*	output = output + "chrtran "
*!*	ss = seconds()
*!*	= chrtran( strContents, 's', '' )
*!*	output = output + chr(10)+chr(13) + trans( seconds() - ss ) + chr(10)+chr(13)

_cliptext = output
Previous
Reply
Map
View

Click here to load this message in the networking platform