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:
00168125
Vues:
25
>>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.

Thanks for the tips. This program was just something I slapped together and have been meaning to spruce up ever since. I never got back to it, I guess because it worked and there were so many non-working things to fix. Now that I'm nearing the end of this phase of the product, it's time to fix it.

Thanks,

-Michelle
Précédent
Répondre
Fil
Voir

Click here to load this message in the networking platform