Generic search routine

I need to put a find…search routine in a global method that will be passed the table and field to search on, and the value to search for, but I can’t figure out how to do so.
Assume lctablename and lcfielname are variables containing the table and field names, and lfieldvalue contains the text to be searched for.

var ofscheckunique = databaseManager.getFoundSet(currentcontroller.getServerName(),lctablename)
ofscheckunique.find()
ofscheckunique.lcfieldname = lfieldvalue
var lnsearchresult = ofscheckunique.search()

doesn’t work because lcfieldname is not the search field name but holds the field name. Neither of these variations work either.

ofscheckunique.find()
ofscheckunique.[lcfieldname] = lfieldvalue
var lnsearchresult = ofscheckunique.search()

ofscheckunique.find()
eval(‘ofscheckunique.’+lcfieldname) = lfieldvalue
var lnsearchresult = ofscheckunique.search()

Can this be done? Thanks for any help.

Try this line for the assignment…

// note no "." before brackets
ofscheckunique[lcfieldname] = lfieldvalue

g

Thanks, that did it.