Would it be possible to change the way the scripting language works and how variables are parsed to allow the "%operclosechan.%chan" variables below to be evaluated:
set -eu10 %operclosechan.%chan %reason
if (%operclosechan.%chan) {
unset %operclosechan.%chan
This would require the scripting language to 1) disallow use of % anywhere in the variable name except at the beginning, and 2) interpret . followed by a % as a combining character in non-space-delimited text that interprets the % following the . as a variable name.