You're not doing anything too stupid, however the way IIF() works is not obvious if you are used to tertiary constructs in other languages.

Basically, IIF() works like a function- this is *completely* different to IF/ELSE/ENDIF which is a control structure.

Because it is a function it takes parameters, so for it to work any expressions have to be resolved first. This means that your WriteAndDisplay() function calls are first executed to get their values, then the conditional part of the expression is evaluated and the relevant result is passed back.

Basically you are trying to use IIF() for a purpose that it's not designed for.