> *------------------------------------------------- >FUNCTION NextNumber > * get the next incremental number for the passed field, padded with > * leading zeros > >**** PARAMETER cField,nLen lparameters cField, nLen local cOldAlias, lUsed, lDone, nReturnNum > > cOldAlias = ALIAS() > lUsed = USED( "System" ) > IF ! lUsed > USE SYSTEM IN 0 > ENDIF > SELECT SYSTEM > lDone = .F. > DO WHILE ! lDone > IF FLOCK() >**** nReturnNum = &cField >**** REPLACE &cField WITH &cField + 1 nReturnNum = eval(cField) replace (cField) with eval(cField) + 1 > cReturnNum = PADL( nReturnNum, nLen, '0' ) Why aren't you using integer keys? > UNLOCK > lDone = .T. > ELSE > INKEY(.5) > ENDIF > ENDDO > IF ! EMPTY( cOldAlias ) > SELECT (cOldAlias) > ENDIF > IF ! lUsed > USE IN SYSTEM > ENDIF > RETURN cReturnNum > >>