$chrpad()

By knoeki on Jul 02, 2009

Similar to my last identifier, I now present you $chrpad().

Usage:

$chrpad(txt, len, chr, s)

txt is the text you want to apply padding to.
len is the MAXIMUM length of the full string, including padding.
chr is the chr code to use for padding.
s again does the same as in the last one, i.e. it adds the padding to the end rather than in front.

This can be useful for scripts if you want to nicely align nicknames or something like that.

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

Comments

Sign in to comment.
Are you sure you want to unfollow this person?
Are you sure you want to delete this?
Click "Unsubscribe" to stop receiving notices pertaining to this post.
Click "Subscribe" to resume notices pertaining to this post.