Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Increment ALPHA ID's Only
Message
Information générale
Forum:
Visual FoxPro
Catégorie:
Autre
Versions des environnements
Visual FoxPro:
VFP 9 SP1
OS:
Windows XP SP2
Divers
Thread ID:
01220831
Message ID:
01220832
Vues:
38
See Re: Suggestions for random candidate key generation methodol Message #902854

>I am trying to get the below code to increment only an ALPHA ID field.
>
>I know that this code is close to what I want but it just isn't quite doing the job yet. If I have a 5-character ID such as lower case "aaaaa" and I want to increment it, you would naturally say that the 5th character ought to be the letter 'b', but although I see it in the memvars, it just isn't returning the right value. I've posted on this recently but didn't come up with a satisfactory solution yet.
>
>
>?IncrementAlpha("aaaaa")
>
>FUNCTION IncrementAlpha
>LPARAMETERS pcString
>
>lnStrLen=LEN(pcString)	&& get the string length.
>LOCAL i As Integer
>FOR i = 1 TO lnStrLen
>   cCharToIncrement=SUBSTR(pcString,lnStrLen-i +1, 1)
>   cCharToIncrement=CHR(ASC(cCharToIncrement) +1)
>   IF cCharToIncrement > "z"
>      cCharToIncrement = "a"
>      STUFF(pcString,lnStrLen-i + 1, 1, cCharToIncrement)
>   ELSE
>      STUFF(pcString,lnStrLen-i + 1, 1, cCharToIncrement)
>   ENDIF
>ENDFOR
>RETURN pcString
>ENDFUNC
>
--sb--
Précédent
Répondre
Fil
Voir

Click here to load this message in the networking platform