; -------------------------------------------------------------------------------------------------
; $pad(string, width, align)
; width is assumed left if unspecified, otherwise use left,right,center
;
; exaple:
; /echo -a $pad(Name, 16, center) $pad(Mail, 32, center) $pad(url, 50, center)
; /echo -a $pad(KingTomato, 16) $pad(kingtomato@kingtomato.com, 32) $pad(www.kingtomato.com, 50)
; -------------------------------------------------------------------------------------------------
alias pad {
if ($2 <= $len($1)) return $1
if ($3 == right) return $+($str($chr(160),$calc($2 - $len($1))), $1)
else if ($3 == center) {
var %left = $int($calc(($2 - $len($1)) / 2))
return $+($str($chr(160),%left), $1, $str($chr(160),$calc(($2 - $len($1)) - %left)))
}
return $+($1, $str($chr(160),$calc($2 - $len($1))))
}
; eof
; -------------------------------------------------------------------------------------------------
; demo code
on *:RAWMODE:#: {
; give the alias something tow rok with
/modes $1-
/echo $chan Modes we're dealing with:
/echo $chan $pad($chr(35), 5) $pad(chr, 5) $pad(sign, 5) $pad(mode, 5) param
; loop through em
var %m = 1
while ($modes(%m).chr) {
/echo $chan $pad(%m, 5) $pad($modes(%m).chr, 5) $pad($modes(%m).sign, 5) $pad($modes(%m).mode, 5) $modes(%m)
/inc %m
}
}