Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
PADL() has a nice undocumented feature
Message
De
23/02/2006 05:53:54
 
 
À
23/02/2006 04:08:38
Information générale
Forum:
Visual FoxPro
Catégorie:
Codage, syntaxe et commandes
Divers
Thread ID:
01098313
Message ID:
01098390
Vues:
9
>So, the conclusion is that the performance improves if the 3rd parameter already has the appropriate length. Cool.
>

True, except the default ( space ), because VFP's parameter validation is very slow.

>>>This is to let you all know that I discovered a really nice, undocumented feature of PADL(). It is present in at least vfp7 and higher.
>>>
>>>The 3rd parameter can be used to define the Pad Character, says the doc. However, this parameter can be of varying length! An example:
>>>
>>>
? "Result: " + padl( 123, 10, "#000000000" )
>>>Result: #000000123
>>
>>Of course an immediate issue it is found ! grrr
>>REPLICATE(char,nn) it is optimized.
>>VFPT doesn't optimize PADX().
>>Result, writing a more complex code is gotten a notably greater speed.
>>
>>
>>CLEAR
>>
>>? PADL('123'	,100,'#')==PADL('123'	,100,REPLICATE('#',100))
>>? PADL(123		,100,'#')==PADL(123		,100,REPLICATE('#',100))
>>
>>FOR K=1 TO 1000000
>>NEXT
>>
>>LOOPCOUNT = 200000
>>
>>t1=SECONDS()
>>FOR K=1 TO INT(M.LOOPCOUNT)
>>	=PADL('123'	,100,'#')
>>	=PADL('123'	,100,'#')
>>	=PADL(123	,100,'#')
>>NEXT
>>
>>? "DIRECT", SECONDS()-T1
>>
>>t1=SECONDS()
>>
>>FOR K=1 TO INT(M.LOOPCOUNT)
>>	=PADL('123'	,100,REPLICATE('#',100))
>>	=PADL('123'	,100,REPLICATE('#',100))
>>	=PADL(123	,100,REPLICATE('#',100))
>>NEXT
>>
>>? "INDIRECT",SECONDS()-T1
>>
Précédent
Répondre
Fil
Voir

Click here to load this message in the networking platform