Abc & Mod Identifiers

By Sonny on Nov 08, 2011

The $abc identifier will just return the corresponding position or letter of the English alphabet. Example: $abc(g) ;returns 7 $abc(24) ;returns x $abc(0) ;returns 26 (total letters in alphabet)

The $mod identifier is a simple version of the modulus (%) operator found in many programming and scripting languages. For those not familiar with the modulus operator, it merely takes 2 numbers, divides them and returns the remainder. It's pretty convenient on occasion. Example: $mod(10,2) ;returns 0 $mod(37,7) ;returns 2

Two simple identifiers. If you have any problems, leave a comment and I'll fix/update with what I can.

abc { 
  var %abc a.b.c.d.e.f.g.h.i.j.k.l.m.n.o.p.q.r.s.t.u.v.w.x.y.z r
  return $iif($1 isalpha,$findtok(%abc,$1,46),$iif($1 isnum,$gettok(%abc,$iif($1 == 0,0,$1),46))))
}
mod { var %a = $1, %b = $2, %x = $int($calc(%a / %b)), %y = $calc(%x * %b), %z = $calc(%a - %y) | return %z }
Sign in to comment.
jaytea   -  Nov 09, 2011

Sonny, mIRC actually supports the modulo operator but yours is slightly better in certain cases since it inadvertently obeys the traditional mathematical definition of modulo (0 <= (a % b) < b, for positive b). $mod(-7, 3) = 2 (correct) but $calc(-7 % 3) = -1.

 Respond  
jaytea   -  Nov 09, 2011

[quote]

abc return $calc($asc($lower($1)) - 96)

[/quote]

or:

abc return $and($asc($1), 31)

:p

 Respond  
Savage_CL   -  Nov 09, 2011
abc return $calc($asc($lower($1)) - 96)

just another way :)

 Respond  
SReject   -  Nov 09, 2011

It doesn't return the full alphabet, but it does return $abc(Letter) as the letter's position and $abc(N) as the Nth number in the alpha bet

abc return $ [ $+ [ $Iif($1 isalpha,pos,mid) ] $+ ] (abcdefghijklmnopqrstuvwxyz,$1,1)
 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.