Calculator With Answer Save

By RagBot on Sep 14, 2009

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 4
4 is 16
/c 4
[CALC] The answer to 16
4 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 4
4 is 16
/c 4m
[CALC] The answer to 4
16 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]
}

Comments

Sign in to comment.
Blogger   -  Sep 16, 2009

Funy scripting... but i liked

 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.