* Purpose Creates next string key from the passed one >* using specified set of characters >* >* Param's >* 1 - Current Key >* 2 - Defines the list of allowed characters >* BASENN - See DO CASE in the body of the program >* CUSTOM - the list of character as parameter 3 >* 3 - List of characters >* Return New Key >* >* Note : Routine ignores (doesn't change) the positions >* with the characters not in the specified list > >PARAMETER tcOldVal, tcOpt, tcCharList > >LOCAL lcNewVal, i, lcDigits, lcLetters, lnStrLen, lcOldChar, lcNewChar, lcCharList, lnPos > >lcOpt = IIF(EMPTY(tcOpt), "BASE10", UPPER(tcOpt)) >* Fill out the string 'lcCharList' with all characters >lcDigits = "0123456789" >lcLetters = "ABCDEFGHIJKLMNOPQRSTUVWXYZ" > >DO CASE >CASE "CUSTOM" $ lcOpt > lcCharList = tcCharList >CASE "BASE10" $ lcOpt > * Just Digits > lcCharList = lcDigits >CASE "BASE16L" $ lcOpt > * Hex-dec lower > lcCharList = lcDigits + "abcdef" >CASE "BASE16" $ lcOpt > * Hex-dec upper > lcCharList = lcDigits + "ABCDEF" >CASE "BASE26L" $ lcOpt > * Lower case letters > lcCharList = LOWER(lcLetters) >CASE "BASE26" $ lcOpt > * Upper case letters > lcCharList = lcLetters >CASE "BASE36L" $ lcOpt > * Digits + Lower case letters > lcCharList = lcDigits + LOWER(lcLetters) >CASE "BASE36" $ lcOpt > * Digits + Upper case letters > lcCharList = lcDigits + lcLetters >CASE "BASE52" $ lcOpt > * All letters > lcCharList = lcLetters + LOWER(lcLetters) >CASE "BASE62" $ lcOpt > * Digits + All letters > lcCharList = lcDigits + lcLetters + LOWER(lcLetters) >OTHERWISE > * The same as BASE10 > lcCharList = lcDigits >ENDCASE > >lnStrLen = LEN(lcCharList) > >lcNewVal = tcOldVal > >* Scan Val string from the right to the left > >FOR i = LEN(lcNewVal) TO 1 STEP -1 > > lcOldChar = SUBSTR(tcOldVal, i, 1) > > IF NOT (lcOldChar $ lcCharList) > * Keep it > LOOP > ENDIF > > * Get the next character for this position > *lcNewChar = GetNextChar( lcOldChar, lcCharList ) > lnPos = AT(lcOldChar, lcCharList) > > IF lnPos = lnStrLen > * It's last character > lcNewChar = LEFT(lcCharList,1) > ELSE > * Get the next character > lcNewChar = SUBSTR(lcCharList, lnPos+1,1) > ENDIF > > lcNewVal = STUFF(lcNewVal, i, 1, lcNewChar) > IF lcNewChar <> LEFT(lcCharList,1) > * We got next one > EXIT > ENDIF > >ENDFOR > >RETURN lcNewVal >>