if condition, literal spaces and timer evaluations - 27/01/23 10:02 PM
Today I figured there was actually an issue when handling local %variables in a timer.
When a timer fires, the local variables that existed in the scope when the /timer was called are long gone and don't exist anymore, so in order to prevent double evaluation, $unsafe must be used so that the content of the variables is seen when /timer is seen, not when it fires.
if (%localvar != $null) { command }
vs
.timer -ho 1 0 if ( $unsafe(%localvar) ) command
this works when the variable has a content, but when it's $null, you get /if invalid format, because all the timer sees if ( ) command.
This is a bit annoying, not going to lie!
If the parameter passed to $unsafe() is $null, would it be possible to still return a plain text $unsafe().undo so that a future evaluation would turn that into $null, allowing timers to correcly handle these situations, there's many more if condition formats that fail depending on where $unsafe() is used.
I'm well aware of the idea of using an alias and doing the job in an alias but that's not the point here.
When a timer fires, the local variables that existed in the scope when the /timer was called are long gone and don't exist anymore, so in order to prevent double evaluation, $unsafe must be used so that the content of the variables is seen when /timer is seen, not when it fires.
if (%localvar != $null) { command }
vs
.timer -ho 1 0 if ( $unsafe(%localvar) ) command
this works when the variable has a content, but when it's $null, you get /if invalid format, because all the timer sees if ( ) command.
This is a bit annoying, not going to lie!
If the parameter passed to $unsafe() is $null, would it be possible to still return a plain text $unsafe().undo so that a future evaluation would turn that into $null, allowing timers to correcly handle these situations, there's many more if condition formats that fail depending on where $unsafe() is used.
I'm well aware of the idea of using an alias and doing the job in an alias but that's not the point here.