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)
>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--