Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Leading zero insertion?
Message
De
11/01/2000 04:06:53
Cetin Basoz
Engineerica Inc.
Izmir, Turquie
 
Information générale
Forum:
Visual FoxPro
Catégorie:
Codage, syntaxe et commandes
Divers
Thread ID:
00315933
Message ID:
00316012
Vues:
21
>Can I condense this code where I am inserting leading zeroes?
>It's not easy to read and it's also hard to follow. All it does is insert leading zeroes so I can do a seek.
>
>IF VALU $ "0123456789"
> DO CASE
> CASE VAL(VALU) < 10
> SEEKIT = "0000000" + UPPER(ALLTRIM(THISFORM.t_ln.VALUE))
> CASE VAL(VALU) < 100 AND VAL(VALU) > 9
> SEEKIT = "000000" + UPPER(ALLTRIM(THISFORM.t_ln.VALUE))
> CASE VAL(VALU) < 1000 AND VAL(VALU) > 99
> SEEKIT = "00000" + UPPER(ALLTRIM(THISFORM.t_ln.VALUE))
> CASE VAL(VALU) < 10000 AND VAL(VALU) > 999
> SEEKIT = "0000" + UPPER(ALLTRIM(THISFORM.t_ln.VALUE))
> CASE VAL(VALU) < 100000 AND VAL(VALU) > 9999
> SEEKIT = "000" + UPPER(ALLTRIM(THISFORM.t_ln.VALUE))
> CASE VAL(VALU) < 1000000 AND VAL(VALU) > 99999
> SEEKIT = "00" + UPPER(ALLTRIM(THISFORM.t_ln.VALUE))
> CASE VAL(VALU) < 10000000 AND VAL(VALU) > 999999
> SEEKIT = "0" + UPPER(ALLTRIM(THISFORM.t_ln.VALUE))
> CASE VAL(VALU) < 100000000 AND VAL(VALU) > 9999999
> SEEKIT = UPPER(ALLTRIM(THISFORM.t_ln.VALUE))
> ENDCASE
>ENDIF
>
>Thanks in advance.


Steve,
Padl() is the key function. However I wonder how this code work with that "if" unless you always have special values for "valu". ie: if valu = "38", it would fail on entry and no seek would be performed.
padl() would place leading zeroes, OK. But how it keeps in touch with the index ? Is it also padl() or by some other means zero leaded ? If that's "characterized" integer field, then wouldn't an index using bintoc(val(valu)) be better ?
With the expressions you used it sounds to me this is a pure digits containing field :)
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
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform