Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Padding with zeroes
Message
De
18/09/1998 11:46:58
Cetin Basoz
Engineerica Inc.
Izmir, Turquie
 
 
À
18/09/1998 11:25:12
Information générale
Forum:
Visual FoxPro
Catégorie:
Gestionnaire d'écran & Écrans
Divers
Thread ID:
00137666
Message ID:
00138251
Vues:
14
>>>>>>You can try this in lostfocus
*lostfocus
>>>>>>this.value = substr(this.value,1,1)+;
>>>>>>        padl(val(substr(this.value,2)),5,"0")
Inputmask would be something like "A99999" and format "!".
>>>>
>>>>>Change lostfocus code to :
this.value = substr(this.value,1,1)+;
>>>>>        padl(substr(trim(this.value),2),5,"0")
>>>
>>>TRANSFORM("@L 999999",XXX) pads XXX representation with zeroes; I would try to use that instead of PADL().
>
>>Federico,
>>You can use many routines for conversion. However here transform() doesn't seem to be a shorter (or faster - if ever a lostfocus like this one needs optimizing) coding to me. Maybe I could see why it's better if you provide full code.
>
>I just prefer using TRANSFORM(); since FP gives us a way to pad numbers with zeroes automatically, I don't like (want) my programmers to reinvent the wheel or use (possibly) more obscure methods. My code would be
This.Value = LEFT(This.Value,1)+TRANSF("@L 99999", VAL(SUBSTR(THIS.VALUE,2))
>
>I think I read somewhere that in FP there are at least three ways to do anything; I (let's emphasize that "I") just prefer the least involved way.

OK I missed a nonobscure built-in function and reinvented the padl(). I missed it doesn't even cause coding error as I did in first reply. I was wrong I confess. Sure at least 3 ways or no way :)
Cetin
Çetin Basöz

The way to Go
Flutter - For mobile, web and desktop.
World's most advanced open source relational database.
.Net for foxheads - Blog (main)
FoxSharp - Blog (mirror)
Welcome to FoxyClasses

LinqPad - C#,VB,F#,SQL,eSQL ... scratchpad
Précédent
Répondre
Fil
Voir

Click here to load this message in the networking platform