Just for reference, check out $base too, it\'s helpful for the same function however using it can be quite tricky this simplifies it a hell of a lot. Here\'s a slightly shorter version for you :)
alias padnum return $+($iif($3 == s,$1),$str(0, $calc($len($2) - $len($1))),$iif($3 != s,$1))