Alphabet Identifier ( $alph() )
Platform: mIRC
Published Apr 03, 2009
Updated Apr 03, 2009
I looked around and couldnt find an appropriate built-in identifier that works with the english aplhabet. So i decided to make one. This script takes an alphabetical character and puts it in numerical form, or vise versa. See below for some examples
Syntax: $alph(L,A,etc)
N = Alphabetical Number (1 = a, 26 = z)
L = Number from Alphabetical Characters (a = 1, z = 26)
Usage Examples:
$alph(1)
This would return "a" without the quotes
$alph(a)
This would return "1" without the quotes
$alph(1-z)
This would return "a-26" without the quotes
$alph(1,2,3,4,5,f,g,h,i,j)
This would return "a b c d e 6 7 8 9 10" without the quotes
$alph(1,7).list
This would return "a b c d e f g" without the quotes
$alph(a,h).list
This would return "1 2 3 4 5 6 7 8" without the quotes
By default, all Alphabetical letters are returned in lower-case form
This identifier can be very useful in loops
Ex:
When this is in remotes, and you type "/listalpha a z" without quotes
It will return every alphabetical number from a to z on separate lines
alias alph {
var %num.a 1 | var %num.b 2 | var %num.c 3 | var %num.d 4 | var %num.e 5 | var %num.f 6 | var %num.g 7 | var %num.h 8 | var %num.i 9 | var %num.j 10 | var %num.k 11 | var %num.l 12 | var %num.m 13
var %num.n 14 | var %num.o 15 | var %num.p 16 | var %num.q 17 | var %num.r 18 | var %num.s 19 | var %num.t 20 | var %num.u 21 | var %num.v 22 | var %num.w 23 | var %num.x 24 | var %num.y 25 | var %num.z 26
var %let.1 a | var %let.2 b | var %let.3 c | var %let.4 d | var %let.5 e | var %let.6 f | var %let.7 g | var %let.8 h | var %let.9 i | var %let.10 j | var %let.11 k | var %let.12 l | var %let.13 m
var %let.14 n | var %let.15 o | var %let.16 p | var %let.17 q | var %let.18 r | var %let.19 s | var %let.20 t | var %let.21 u | var %let.22 v | var %let.23 w | var %let.24 x | var %let.25 y | var %let.26 z
if ($1 isnum) && ($1 < 27) && (!$2) {
return %let. [ $+ [ $1 ] ]
}
elseif ($1 isalpha) && (!$2) {
return %num. [ $+ [ $1 ] ]
}
elseif (!$2) && ($numtok($1,45) == 2) {
if ($gettok($1,1,45) isnum) && ($gettok($1,1,45) > 26) { goto end }
if ($gettok($1,2,45) isnum) && ($gettok($1,2,45) > 26) { goto end }
return $+($iif($gettok($1,1,45) isalpha,%num. [ $+ [ $gettok($1,1,45) ] ],%let. [ $+ [ $gettok($1,1,45) ] ]),-,$iif($gettok($1,2,45) isalpha,%num. [ $+ [ $gettok($1,2,45) ] ],%let. [ $+ [ $gettok($1,2,45) ] ]))
}
elseif (!$3) && ($prop == list) {
if ($len($gettok($1-,1,32)) > 2) && ($1 isalpha) && ($2 isalpha) { goto end }
if ($1 isnum) && ($1 > 26) { goto end }
if ($2 isnum) && ($2 > 26) { goto end }
var %start $1
var %end $2
if ($1 isnum) && ($2 isnum) { while (%start <= %end) { if (!%result) { var %result = %let. [ $+ [ %start ] ] } | elseif (%result) { var %result = %result %let. [ $+ [ %start ] ] } | inc %start } | return %result }
elseif ($1 isalpha) && ($2 isalpha) { var %start = %num. [ $+ [ %start ] ] | var %end = %num. [ $+ [ %end ] ] | while (%start <= %end) { if (!%result) { var %result = %num. [ $+ [ %let. [ $+ [ %start ] ] ] ] } | elseif (%result) { var %result = %result %num. [ $+ [ %let. [ $+ [ %start ] ] ] ] } | inc %start } | return %result }
}
else { var %x 1 | var %lo.prop $1- | while (%x <= $numtok(%lo.prop,32)) { if ($gettok(%lo.prop,%x,32) > 26) && ($gettok(%lo.prop,%x,32) isnum) { goto end } | if ($len($gettok(%lo.prop,%x,32)) > 1) && ($gettok(%lo.prop,%x,32) isalpha) { goto end } | if (!%result) { var %result = $iif($gettok(%lo.prop,%x,32) isalpha,%num. [ $+ [ $gettok(%lo.prop,%x,32) ] ],%let. [ $+ [ $gettok(%lo.prop,%x,32) ] ]) } | elseif (%result) { var %result = %result $iif($gettok(%lo.prop,%x,32) isalpha,%num. [ $+ [ $gettok(%lo.prop,%x,32) ] ],%let. [ $+ [ $gettok(%lo.prop,%x,32) ] ]) } | if (%x = $numtok(%lo.prop,32)) { return %result } | inc %x } }
:end
}