Excellent thanks. For anybody wanting to use the fuction,
there was slight changes needed.
Here is the amended code
.........
function delStructKey(structVars) {
for (i=1;listLen(StructVars);i=i+1) {
theVar = listGetAt(structVars, i)
var theKey = listGetAt(theVar, listLen(theVar, "."), ".");
var theStruct = left(theVar, len(theVar) - len(theKey) - 1);
if (isdefined('#theVar#') and evaluate(theVar) eq '') {
structDelete(evaluate(theStruct), '#theKey#');
}
}
}
.......
usage:
delStructKey("session.search.this, structVar2, ... ");