Someone at the forum has posted a snippet relating to calculator. That gives me an idea of utilizing Google's calculator feature to do the calculating of most basic operations.
The command is:> !calc or .calc or @calc
on *:sockopen:calc:{
tokenize 124 $sock(calc).mark
if $sockerr { $4 * SockOpen ERROR! }
else { $1-2 | $1 $3 }
}
on *:sockread:calc:{
tokenize 124 $sock(calc).mark
if $sockerr { $4 * SockRead ERROR! }
else {
var %calc, %x /<b>(.*)</b>/, %y /(.*)</b></h2><div style\="/
sockread %calc
if $regex(%calc,%x) && $regex($regml(1),%y) {
$4 $regsubex($+($chr(2),$---($remove($regml(1);,))),$&
/&#(\d+)|<[^>]*>/g,$chr(\1))) | sockclose calc
}
}
}
on $*:text:/((?<=[!@.]calc\s)-?\d+.*)/iS:*:{
if !%p { inc -u5 %p
if $sock(calc) { sockclose $v1 }
sockopen calc www.google.com 80
sockmark calc sockwrite -nt calc|GET $+(/search?q=,$&
$remove($replace($regml(1),+,$+(%,2B),x,*),$&
$chr(32)),&btnG=Search) HTTP/1.1|Host: $&
$+($sock(calc).addr,$str($crlf,2)) $+ |.msg $iif(#,#,$nick) $+($chr(15),CALC:)
}
}
alias -l --- return $regsubex($1,/(\=)(.+)/,$+(\1,$chr(32),$remove(\2,$chr(32))))
Ok I changed it to - because the . will match anything. :p
Yes, it wouldn't be hard, but as constructive as you should have been, telling a code will fail doesn't usually help a situation. When you offer your input or example, everybody can learn from you, something they either already know or don't. ^^