> >LPARAMETERS tcIDType, tnNumToGet > >LOCAL llNotUsed, lnArea, lnRetVal > >llNotUsed = .F. >llCanLock = .F. >lnArea = SELECT() > >IF !USED( "idcount" ) > USE idcount IN 0 > llNotUsed = .T. >ENDIF >SELECT idcount >SET ORDER TO TAG table > >*** Lock the entire table >DO WHILE !FLOCK() >ENDDO > >SEEK UPPER( tcIDType ) > >IF FOUND() > > *** If we find the record then return this value > lnRetVal = idcount.id > REPLACE id WITH lnRetVal + IIF( EMPTY( tnNumToGet ), 1, tnNumToGet ) > >ELSE > > *** Record not found do create one > INSERT INTO idcount ( id, table, tdesc ) VALUES ( 2, tcIDType ) > lnRetVal = 1 > >ENDIF > >FLUSH >UNLOCK > >IF llNotUsed > USE IN idCount >ENDIF > >SELECT( lnArea ) > >RETURN lnRetVal > >>