>rand(-1) >scan > if rand() < 0.05 && 5% > * process this employee > endif >endscan >>
>>lparameters lcPlantNo >> >>* get only active employee #'s into the temporary >>* table >>select prempl,first,last ; >> from prempl01 where left(prempl,1) = lcPlantNo ; >> and status = "A" ; >>union all ; >>select prempl,first,last ; >> from prempl02 where left(prempl,1) = lcPlantNo ; >> and status = "A" ; >> into cursor tmpEmpl >> >>select tmpEmpl >> >>nRecs = reccount() >>* the number of tests to perform is 5% of >>* the total population for this plant >>nNumTests = round(nRecs * .05,0) >>nTested=0 >>* initialize the seed value >>nEmplNo = rand(-1) >>do while nTested < nNumTests >> >> * get the random employee number >> nEmplNo = int(nRecs * rand() + 1) >> * random sort for printout >> nRandSort = rand()*100 >> >> if nEmplNo < 1 or nEmplNo > nRecs >> loop >> endif >> >> * save the employee to the temp file >> goto nEmplNo in tmpEmpl >> select testnumbers >> seek tmpEmpl.prempl >> if !found() >> * employee not already included in this test >> nTested = nTested + 1 >> append blank >> replace empid with tmpEmpl.prempl >> replace last with tmpEmpl.last >> replace first with tmpEmpl.first >> replace randsort with nRandSort >> endif >>enddo >> >>use in tmpEmpl >