Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Proceedure Code for Primary Key
Message
Information générale
Forum:
Visual FoxPro
Catégorie:
Autre
Divers
Thread ID:
00168028
Message ID:
00168086
Vues:
30
>Here's my Getkey() program:
>
>
>PARAMETER lcKeyName
>
>LOCAL lnKeyNum
>
>IF NOT USED("keylist")
>   USE keylist IN 0
>ENDIF
>IF SEEK(ALLTRIM(lcKeyName),"keylist","idxKname")
>   REPLACE keynum WITH keynum+1 IN "keylist"
>   lnKeyNum = keylist.keynum
>ELSE
>   lnKeyNum = 0
>ENDIF
>USE IN keylist
>RETURN lnKeyNum
>
There's a bit of error-checking you can add to this routine.
PARAMETER lcKeyName

LOCAL lnKeyNum

IF NOT USED("keylist")
   USE keylist IN 0
ENDIF

lnKeyNum = 0

IF SEEK(ALLTRIM(lcKeyName),"keylist","idxKname")
   IF RLOCK()    && You don't want two users getting the
                 && same number....
      REPLACE keynum WITH keynum+1 IN "keylist"
      lnKeyNum = keylist.keynum
      UNLOCK
   ENDif
ENDIF
*USE IN keylist    && You will only do this until the
                   && first time you do a large APPEND FROM
                   && into this table. :-)
RETURN lnKeyNum
Now that I think about it, it might be better to set lnKeyNum to .NULL., rather than 0: it's a better out-of-bounds indicator.
My blog
My consulting page
My home page

Member of the Trim Your Auto-Quote Campaign!
What's another word for thesaurus?
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform