Whenever I am messing with Execute, the very first thing I do, is turn on NoMacrosinStrings, and NoVarsinStrings... I think it makes it easier to build the execute line:

(untested)
 Code:
$RC=setoption("NoVarsinstrings","on")
$RC=setoption("NoMacrosinstrings","on")

$a = EXECUTE('isdeclared($varprefix' + $counter + ')')