cOrder=key() private uCurrent uCurrent=eval(cOrder) cFilter=filter() if !empty(cFilter) cFilter=" and " +cFilter endif TEXT TO c NOSHOW TEXTMERGE select * from TheTable where {{cOrder}}<=uCurrent {{cFilter}}; into cursor tmp ENDTEXT =execscript(c)With the filter there's an odd chance that the expression may include something that wouldn't work in a sql statement - in that case, this would have to be a "copy to ... for {{cOrder}}<=uCurrent {{cFilter}}"