>>Just in case ???
>>Oh from your first message I assumed you were using it already.
>
>When I open the file the order is set alright, maybe I have messed it somewhere along the code.
>
>>In any case if you think WHILE is a problem simply use FOR instead. A FOR automatically rewinds to top, yes, but fox is clever enough to use index to find records for replacement with expressions like in your sample (I don't mean WHILE is a problem - whenever I saw WHILE fail it was my fault not Fox's).
>
>Same I guess in my case, but the fun part is that it randomly fails.
>
>>
>>WHILE with ALL is likely to always fail. Suppose you have ids :
>
>True
>
>>If I remember correct in your original message m.id was char ? If so remember if set exact is off :
>
>That is an idea maybe the replacement is being done but somewhere else and I guess exact is off
>
>>PS: You can use FOR and WHILE together in the same command.
>
>REPLACE dbf.fld WITH .T. FOR dbf.id = m.id (WHILE ???)
seek m.ID
replace f1 with value1, f2 with value2 ;
while dbf.id = m.id for SomeField = SomeValue
This makes the replacement WHILE the ID is m.ID but only FOR records where SeomeField is also equals to SomeValue. ie:
id f1 f2 somefield
-- -- -- ---------
1
2
3 1 2 ready
3 4 3 notready
3 1 6 ready
3 7 3 notready
4
seek 3
replace f1 with f1+1, f2 with f2-1 while id = 3 ;
for somefield = 'notready'
Cetin