Syntax
Private: /c
Public: /cp
Check Answer: /anscheck
For some reason i keep updating my calculators, i don't know why, but this one works nicely.
It adds commas, and changes / to ÷ in the answer.
The biggest perk to this calc is, it saves the answer, so if you go:
/c 44
[CALC] The answer to 44 is 16
/c 4
[CALC] The answer to 164 is 64
The comma adder is thanks to FiberOPtics' script
UPDATE: As requested, I should make it so you can but answer in anywhere.' m ' for memory
use ' m ' anywhere in the operation.
/c 44
[CALC] The answer to 44 is 16
/c 4m
[CALC] The answer to 416 is 64
UPDATE: I changed it into regex format, making it a bit neater.
alias c {
if ($regex($1-,^(\+|\-|\*|\/|\^)) == 1) {
set %b $left($1-,1)
if (/0 isin $strip($1-)) { echo -a 07[12CALC07] The answer to12 %ans $+ $replace(%b,/,÷,m,%ans,*,×) $+ $mid($1-,2) 07is12 Undefined | set %ans $calc(%ans %b $mid($replace($1-,m,%ans),2)) | halt }
echo -a 07[12CALC07] The answer to12 %ans $+ $replace(%b,/,÷,*,×) $+ $mid($replace($1-,m,%ans),2) 07is12 $comma($calc(%ans %b $mid($replace($1-,m,%ans),2)))
set %ans $calc(%ans %b $mid($replace($1-,m,%ans),2))
}
if ($regex($1-,^\d) == 1) {
if (/0 isin $strip($1-)) { echo -a 07[12CALC07] The answer to12 $replace($1-,/,÷,m,%ans,*,×) 07is12 Undefined | set %ans $calc(%ans %b $mid($replace($1-,m,%ans),2)) | halt }
echo -a 07[12CALC07] The answer to12 $replace($1-,/,÷,m,%ans,*,×) 07is12 $comma($calc($replace($1-,m,%ans)))
set %ans $calc($replace($1-,m,%ans))
}
}
alias cp {
if ($regex($1-,^(\+|\-|\*|\/|\^)) == 1) {
set %b $left($1-,1)
if (/0 isin $strip($1-)) { msg $chan 07[12CALC07] The answer to12 %ans $+ $replace(%b,/,÷,m,%ans,*,×) $+ $mid($1-,2) 07is12 Undefined | set %ans $calc(%ans %b $mid($replace($1-,m,%ans),2)) | halt }
msg $chan 07[12CALC07] The answer to12 %ans $+ $replace(%b,/,÷,*,×) $+ $mid($replace($1-,m,%ans),2) 07is12 $comma($calc(%ans %b $mid($replace($1-,m,%ans),2)))
set %ans $calc(%ans %b $mid($replace($1-,m,%ans),2))
}
if ($regex($1-,^\d) == 1) {
if (/0 isin $strip($1-)) { msg $chan 07[12CALC07] The answer to12 $replace($1-,/,÷,m,%ans,*,×) 07is12 Undefined | set %ans $calc(%ans %b $mid($replace($1-,m,%ans),2)) | halt }
msg $chan 07[12CALC07] The answer to12 $replace($1-,/,÷,m,%ans,*,×) 07is12 $comma($calc($replace($1-,m,%ans)))
set %ans $calc($replace($1-,m,%ans))
}
}
alias comma {
var %a, %b = $regsub($ticks,$1,/\G([+-]?\d+?)(?=(?:\d{3})++(?=\.\d++$|$))/g,\1 $+ $chr(44),%a)
return %a
}
alias anscheck {
echo -a 11[13Answer Check11]13 - 11[13 $+ $comma(%ans) $+ 11]
}