>Select mytable >if empty (variable1) >scan for field2 = variable2 >Endscan >Else >scan for field1 = variable1 >Endscan >Endif >>
select mytable >> >>scan for iif(empty(variable1), field2 = variable2, field1 = variable1) >> * Code here >>endscan >>And here's another thought..., Depending on when macro expansion takes place, a macro may or may not give better performance. If the macro expansion takes place when the SCAN statement is initially encountered, then we might see an improvement in speed. If the macro expansion takes place at every loop iteration then you'll see a significant degradation in speed.
select mytable cCond = "iif(empty(variable1), field2 = variable2, field1 = variable1)" scan for &cCond. * Code here endscan.