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:
01220925
Vues:
16
Cecil,

I use the following function, which works with alphanumeric values (only upper case letters, although you can change it easily):
function incrementBase35(tcString as string, tnKeyLength as integer) as string
    local i as integer, ;
        lcCaracter as string

    if varType(tnKeyLength) <> 'N'
        tnKeyLength = len(tcString)
    endIf

    tcString = padl(allTrim(tcString), tnKeyLength, '0')

    for i = len(tcString) to 1 step -1
        lcCaracter = substr(tcString, i, 1)
        if lcCaracter < 'Z'
            *-- Change character to the next one. If it is 9, jump to A.
            tcString = stuff(tcString, i, 1, ;
                            iif(lcCaracter == '9', 'A', chr(asc(lcCaracter) + 1)))
             exit
         else
            *-- If we get to Z, jump to 0
            tcString = stuff(tcString, i, 1, '0')
        endIf
    endFor

    return tcString
endFunc
>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.
>
>

Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform