x= INT(RAND()*RECCOUNT()) + 1 >GO x >LOCATE REST FOR DELETED() >IF ! FOUND() > LOCATE FOR DELETED() >ENDIF >>
select (tcTableName) lnRecCount = reccount() lnReturnedRecNo = -1 && No Recyclable record (no lDeleted = .t.) if lnRecCount > 0 && Only recycle if table is not empty set reprocess to 0 seconds && each rlock() gets 1 and only 1 try for i = 1 to 5 && # of tries before giving up on recycling go 1 + (rand() * lnRecCount) && randomly select a record (for most records, if ldeleted and rlock() && lDeleted = .t.) if ldeleted && It didn't changed while we were getting lnReturnedRecNo = recno() && the lock so we will send back it's exit && record # for recycling. else unlock record recno() && unlock JUST this one (It was lDeleted, but endif && by the time we got the lock, it wasn't!) endif endfor endif return lnReturnedRecNo && recyclable record number, or -1 for none foundBob