Top

$padnum()


mIRC Code
+ 2 likes
Please Register to submit score.
Bookmark and Share
Average Score  0.0 (of 0 scores)
Date Added  Jun 29, 2009
Last Updated  Jun 29, 2009
Tags  knoeki  num  number  pad  padding  padnum  prefix  zomgwtfbbq  zowb 

Introduction

Once again, I\'m back with another custom identifier.

I wrote this just because I happened to need this a few times.

It doesn\'t do much, but what it does do, it does right. (confused yet? :_)). It takes two numbers, a low and a high, and returns the low number prefixed with as many zeros as needed to get the same length as the high number. purely for visual pleasure when making long numbered lists or something like that, since it will align nicely.

Usage:
$padnum(low, high, <s>)


if you specify \'s\', it will add the zeroes to the end, rather than in front.

Grab the Code

alias padnum {
   if ($3 == s) {
      return $+($1,$str(0, $calc($len($2) - $len($1))))
   }
   else {
      return $+($str(0, $calc($len($2) - $len($1))),$1)
   }
}

Comments

  (1)  RSS
jonesy44
Comments: 1,853
 
mIRC Snippet:  $padnum()
Posted on Jun 29, 2009 5:46 pm
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 :)

Code:
alias padnum return $+($iif($3 == s,$1),$str(0, $calc($len($2) - $len($1))),$iif($3 != s,$1))

Commenting Options

Register or Login to Hawkee.com or use your Facebook or Twitter account by clicking the corresponding button below.

  
Bottom