Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Incrementing Alpha ID's
Message
General information
Forum:
Visual FoxPro
Category:
Other
Environment versions
Visual FoxPro:
VFP 9 SP1
OS:
Windows XP SP2
Miscellaneous
Thread ID:
01212864
Message ID:
01212978
Views:
24
More like this:
*
** AlphaID Incrementer
*
FUNCTION AlphaIDIncrementer
LPARAMETERS cAlphaID
LOCAL nIndex,nIDLEngth,cCharToIncrement
nIDLength = LEN(cAlphaID)
FOR nIndex = 1 TO nIDLength
cCharToIncrement=SUBSTR(cAlphaID,nIDLength-nIndex+1,1)
cCharToIncrement=CHR(ASC(cCharToIncrement)+1)
IF cCharToIncrement > "z"
cCharToIncrement = "a"
STUFF(cAlphaID,nIDLength-nIndex+1,1,cCharToIncrement)
ELSE
STUFF(cAlphaID,nIDLength-nIndex+1,1,cCharToIncrement)
EXIT
ENDIF
ENDFOR
IF nIndex > nIDLength
RETURN .F. && Overflow
ENDIF
RETURN cAlphaID

Note: alphaID must not be mixed case, it must be either upper or lower case. Also must be characters a-z.

>So, is that something like the following?
>
>lcID="aaaaa"
>lnID=ASC(lcID) + 1
>
>>You just increment it by 1 , each time. When it becomes greater than a "z" you set it back to an "a" and increment the character to the left.
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform