This didn't work as I thought it would. It leaves the program too early and doesn't finish the job.
If I have an alpha ID that is 5 characters long always, and I want to increment say, from "aaaag" to the next ALPHA ID, it would naturally be the following: "aaaah", but the below doesn't give me that; it actually returns what I started with.
Cecil
>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.
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.