Scripting Function - Boolean Function "empty/not empty"

Is there a better/more simple way for adding a "not empty" dependicie into a format string than my solution:

$if($grtr($len(%track%,0),$num(%track%,1),)

This format string should unify the track numbers by removing leading zeros, but only if the track number is not empty (because it will lead to a "0" entry in the track number). If track number tag is empty, keep it empty.
So I'm checking if the length of the track tag is greater than 0 and then formating if true and nothing if empty.

You could try
$if2($num(%track%,1),)

This is working perfectly fine, but to be honest I don't understand the logic behind, according to the documentation.

$if2(x,y) ... if x is true, x is returned, otherwise y.

In this case x would be "number with 1 digit - so no leading zero)".
How can it be that this is "true" if the tag is for example "02" at the moment. This is confusing me.

AFAIK the $if2() function does that what you requested: check if the addressed field is there.
You find something similar with the [ ] in format strings which only return a result if the addressed field is there.

Thank you very much for your help and explanation!
My code wasn't working all the time, so I'm glad that there is a sleek function that really works.

Maybe the documentation of this function can be changed/expanded.