Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Looking for a snazzy way
Message
De
25/07/2001 09:23:09
 
 
À
25/07/2001 08:53:26
Information générale
Forum:
Visual FoxPro
Catégorie:
Codage, syntaxe et commandes
Divers
Thread ID:
00534851
Message ID:
00534925
Vues:
13
>>>>
>>>>lcIm = '99999999'
>>>>if ( Thisform.decPlaces != 0 )
>>>> lcIm = Stuff(lcIm, Len(lcIm)-Thisform.decPlaces, 1, '.')
>>>>endif
>>>>
>>>
>>>Ok, I think I've found another solution
>>>
>>>
lcIm = padl(9999999 / 10 ^ Thisform.Decplaces,7) + '9'
>>>
>>>I'm now into questions of readability :(
>>
>>Not quite the same though - it falls over for Decplaces > 2 (your example treated them as the same as Decplaces=0),
>
>Yes I know,
>
>I wanted this for a generic function.. but the example I pulled the Case Statement from was in a form which will only ever go to 2 dp.
>My initial question didn't _Exactly_ specify my requirements, But then again your answer didn't _exactly_ meet my specification either! (not being ungrateful)
>
>I'm still open to suggestions!
>
>Will

for generic - how about the following, where tlen is total length of string & dp is number of decimal places
iff( dp = 0, padl( "", tlen, '9' ), padl( "", tlen-dp-1, '9' ) + "." + padl( "", dp, '9' ) )
with a bit of checking on valid values for tlen & dp
Len Speed
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform