Thanks for your reply, Vince.
I am getting stubborn errors and am grasping for reasons.
Well not errors, but errand behavior. The errors occur when I use
return %@ValidValue[...]
which expands @AppStatus[] internally - and disappear when I simply
return %@IF[defined <envar>,1,0]
This happens not in one location of the code but in several locations and independently.
The debugger doesn't help much either in scenario's like this.
So, in a bout of despair . . . I began to wonder if perhaps that particular combination of function expansions could somehow be against a rule I overlooked or forgot about. I didn't and don't see any problem with it either, but - it appears at least - that we're both wrong.
Never mind, I'm working around it with the simpler variant, so at least I'm not stuck. I just can't code what I want to code.