Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Strip leading zeros
Message
 
 
À
20/10/2009 18:17:31
Information générale
Forum:
Visual FoxPro
Catégorie:
Codage, syntaxe et commandes
Versions des environnements
Visual FoxPro:
VFP 8 SP1
Divers
Thread ID:
01430254
Message ID:
01430356
Vues:
67
* Strip leading zeros
lcStr = "0000027890"
* - get rid of all zeros to get the first none-zero character
* - get position of the character. If it's 0 (all zeros string), set position beyond the string
lcNoLeadingZeros = SUBSTR(lcStr, NVL(AT(LEFT(CHRTRAN(lcStr, "0", ""),1), lcStr),LEN(lcStr)+1))
...
>Please Note: VFP 8
>
>I have a table with a PONUM field. It is a 10 character string. When the field is populated it is with PADL(value,10,"0"). While value is usually a number, it occasionally has a character in it so we could see (for example), 00001234-1
>
>I need an expression that essentially strips away the leading zeros and allows a comparison to another value. So if the user enters "2" we would filter by/select all records where the first non-zero character would be "2", getting (with EXACT OFF)......
>
>"0002567890"
>"0000027890"
>"00002678-1"
>"0000000002"
>etc.
>
>If not for the potential non-numeric characters I think I could use
TRANSFORM(VAL(value)) = "2"
but as the user enters more characters to refine the filter, I need to be able to account for those non-numerics.
>
--sb--
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform