Thomas,
>As the "lcEscape = replicate( "%", lnLength / 2 * 3 )" is included as well as the calling overhead of the parameters I do believe the factor between both measurements will be different if you are repeating the call a couply of thousand times for smaller strings. If the source string length is more in the range of 50 - 200, Substr() should be faster.
VFP can allocate memory pretty darned fast. My box an average of 0.115 seconds for 10,000 iterations rather than one large sring. This ends up taking right at twice as long as doing one string 10,000 times longer.
declare integer EscapeX in C:\VFP8App\df_foxpro\dequote\release\dequote.dll ;
integer nBufferLength, ;
string cInputBuffer, ;
string @cOutputBuffer
lcStr = strconv( "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789!@#$%^&*()_+", 15 )
? left( lcStr, 30 )
lnLength = len( lcStr )
lnStart = seconds()
for i = 1 to 10000
lcEscape = replicate( "%", lnLength / 2 * 3 )
EscapeX( lnLength, lcStr, @lcEscape )
endfor
lnStart = seconds() - lnStart
? lnStart, len( lcStr ), left( lcEscape, 40 )