Code
 It is the same issue as double-evaluation in many other scripting contexts

To elaborate on that, there aren't that many double-evaluating scripting context, the one known are listed on wikichip: https://en.wikichip.org/wiki/mirc/msl_injection

/timer, /dde, /scon and /scid include a command, we can understand the scripting engine will be run twice: the double evaluation is unavoidable (switches were requested to prevent that but from the engine's point of view it's normal)

/flash does not take a command, but it includes a text that will be used later, it's less intuitive but ok, there could be a lot of time before a flash occurs after /flash has been executed, so it makes sense to reevaluate if you want to display real time informations.

But the $submenu context, everything happens at the same time as far as the scripter is concerned, so it's not like your real time informations will change much during the scope of $submenu.. besides $ticks and $ticksqpc..!?
It's always possible to use % $+ global variable as a returned value and set that variable afterward to get the desired result but it seems like it's not required at all, I don't think anyone knew about this to begin with, and there don't seem to be real benefit from double evaluating here

I could be wrong but I believe that all double evaluation contexts happen because the scripting engine is being called twice on the string, it's obvious for /timer etc, it's less obvious why it occurs on $submenu, to me, or even the $calc bit.

I suppose this is too old behavior to change anyway, but since double evaluation does not occur except in specific cases, it would be nice to have a note in the help file about these contexts because it's dangerous, I don't know if anyone knew about this one to be honnest, I'll add $submenu to the wikichip page.


#mircscripting @ irc.swiftirc.net == the best mIRC help channel