#define KEY_LEN 10 set exclusive off set reprocess to 300 if !file("system.dbf") create table system free (cTable c(254), cKeyValue i) insert into system (cTest) values (0) use endif if !file("results.dbf") create table results free (cTest c(KEY_LEN)) index on ctest tag ctest candidate use endif set escape on do while .t. insert into results (cTest) values (NextNumber("cTest", KEY_LEN)) enddo *------------------------------------------------- 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, cReturnNum cOldAlias = alias() lUsed = used( "System" ) if ! lUsed use system in 0 endif select system lDone = .f. do while ! lDone locate if rlock() **** nReturnNum = &cField **** REPLACE &cField WITH &cField + 1 replace (cField) with eval(cField) + 1 cReturnNum = padl( eval(cField), nLen, '0' ) unlock lDone = .t. else inkey(.5) endif enddo if ! empty( cOldAlias ) select (cOldAlias) endif if ! lUsed use in system endif return cReturnNum