Mike, I fear I can't help you reproduce the error, but just calling FILED(0) or such doesn'T error, it's the use of an empty string as a field name that causes the final syntax error, I don't know why that would differ under any circumstance. REPLACE (field(200)) WITH 42. Nothing?
Do you have an error handler on, suppressing or just silently logging errors?
Jamak,
the usual practice to get an exact amount of different random numbers is not going with other generators, you can't adjust the behaviour to get next N numbers not overlapping.
As you have lots of empty cells at the end I'd rather turn the for loop counter back 1 and repeat the loop once more, whenever field(X) already has its 'W' allotted, so check that before the REPLACE.
The simplest always working solution that will be better in cases you would want to pick 100% of all items just in random order is to use the random number to pick one item of a list of not already picked items and reduce that list during the process. So no item can be fetched twice or no day allotted twice. That also means your number range will get 1 shorter every time.
That's taking a little bit more effort in VFP. Using a cursor and DELETE rows you're faced with the deletion marking. RECCOUNT() won't drop by 1, the RECNO() you delete only will get a deleted() status. So you'd need to use other mechanisms like a collection or array you can really reduce. But it's overkill for your case, just repeat until you have hit enough empty cells.
Bye, Olaf.
Olaf Doschke Software Engineering