/range and $range()

By Rebellious on Dec 13, 2007

Returns a range of characters.

; ------------------------------------------------
; $range()
; Returns a range of characters from N-N:

; $range(<N>,<N>,[C])[.n]
; [C] and [.n] are optional. This pair adds a separator to each listed character in the range. If you don't specify one of the other, it just ignores them and returns the default list.

; ----------------------
; /range
; Same as the above in alias format; excluding the [C] and [.n] syntax

; /range <N> <N> 
; Echoes the list

; ----------------------

; Here are some examples: 

; /range 44 58 would return: [timestamp] * Range of characters 44-58: , - . / 0 1 2 3 4 5 6 7 8 9 :

; //echo -a $range(44,58) would return: , - . / 0 1 2 3 4 5 6 7 8 9 :
; //echo -a $range(44,58,42).n would return: ,*-*.*/*0*1*2*3*4*5*6*7*8*9*:

; ----------------------

; On another note:
; You can specify a character as N. For example:
; $range(*,58) would still return the range of characters normally.
; $range(*,:) would also return the same thing.

; ------------------------------------------------

alias range { 
  if ($1) && ($2) { 
    var %m = $iif($1 isnum,$1,$asc($v1)), %t = $iif($2 isnum,$2,$asc($2)), %u, %i = %m
    if (%m isnum 1-255) && (%t isnum 1-255) && (%m < %t) { 
      while (%m <= %t) { 
        %u = $addtok(%u,$chr(%m),32)
        inc %m
      }
      $iif($isid,return,echo -act info * Range of characters $+(%i,-,%t,:)) $iif($prop && $3 && $3 isnum 1-255,$replace(%u,$chr(32),$chr($3)),%u)
    }
    else return
  }
  else { 
    $iif($isid,return,echo -act info * /range:) $iif($isid,$false,insufficient paramaters)
  }
}

Comments

Sign in to comment.
guest598594   -  Dec 13, 2007

oh

 Respond  
Rebellious   -  Dec 13, 2007

Easy clipboard for ascii characters is what I use it for mainly, since I don\'t really want to open a new dialog or window to clipboard a char. This is easy and specific in range making it much easier for that purpose. Others may find their own uses for it as well, who knows. ;P

 Respond  
guest598594   -  Dec 13, 2007

good job, but can you explain when this would be helpful? :/

 Respond  
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.