FormatNum should not work at all with strings so I am rather confused by this. Do I document anywhere that %s is a supported format specifier?
From your most recent post It sounds like you were simply getting lucky with a previously existing NXC bug that made it appear that %s was working when it was not actually working. Now that I have fixed that bug it looks even less like it works than it used to.
In any case, the fmtnum opcode definitely does not work with %s or a string argument as the value to replace in the format string. Since it is designed for formatting numbers I don't have any plans to change that.
Could you explain the need for FlattenVar in your workaround macro? It doesn't make any sense to me. Nothing sensible would happen if val is a numeric type and if val is a string there is no need to call FlattenVar since it is already a string.
It's a trick to outwit the compiler, respectively, the preprocessor. I tried it under different circumstances without, but simply, it doesn't work without. Instead, the compiler complains of any unknown constants (identified as identifiers) or wrong variable types using the macro both with numbers and also with strings and also with format strings containing additional text. My guess is that TextOut is expected to work with numbers but it doesn't work with numbers, or do you have another guess? Did you try the sample code without FlattenVar with better results?