Calculator

By asakura on Jul 18, 2008

my first script on here so do feel free to comment

menu * {
  .Calculator:dialog -m calculator calculator
}
dialog Calculator {
  title "Calculator"
  size -1 -1 205 335
  option pixels
  edit "", 1, 5 5 195 20, read autohs
  edit "", 2, 5 30 150 20, read autohs
  button "x^x", 38, 125 175 35 25
  button "1", 3, 5 205 35 25
  button "2", 4, 45 205 35 25
  button "3", 5, 85 205 35 25
  button "4", 6, 5 235 35 25
  button "5", 7, 45 235 35 25
  button "6", 8, 85 235 35 25
  button "7", 9, 5 265 35 25
  button "8", 10, 45 265 35 25
  button "9", 11, 85 265 35 25
  button "x", 12, 125 235 35 25
  button "+", 13, 125 265 35 25
  button "-", 14, 165 265 35 25
  button "÷", 15, 165 235 35 25
  button "=", 16, 125 295 75 25
  button ".", 17, 85 295 35 25
  button "<=", 18, 125 205 35 25
  button "CE", 23, 165 205 35 25
  button "x²", 19, 5 55 35 25
  button "x³", 20, 45 55 35 25
  button "Sr", 21, 45 85 35 25 
  button "Cr", 43, 5 85 35 25   
  button "0", 22, 45 295 35 25 
  button "pi", 24, 125 115 35 25
  button "sin", 25, 45 145 35 25 
  button "asin", 26, 5 145 35 25  
  button "cos", 27, 85 85 35 25 
  button "acos", 28, 125 85 35 25
  button "round", 29, 5 175 35 25
  button "(", 30, 45 175 35 25
  button ")", 31, 85 175 35 25
  button "M+", 32, 125 145 35 25
  button "MR", 33, 165 145 35 25
  button "On", 34, 165 55 35 25
  button "Off", 35, 165 85 35 25
  button "Copy", 36, 165 115 35 25
  button "Ans", 37, 5 295 35 25
  button "Tan", 39, 5 115 35 25
  button "ATan", 40, 45 115 35 25
  button "Abs", 41, 85 115 35 25
  button "Log", 42, 85 145 35 25
  button "Close", 47, 85 55 75 25, ok close
  button "E", 48, 165 175 35 25
}
on *:DIALOG:Calculator:init:*:{
  set %caled off 
  did -a calculator 2 0
  set %starter on 
}
on *:DIALOG:Calculator:sclick:*:{
  if ($did = 34) { set %starter on | did -r calculator 2 | did -r calculator 1 | did -a calculator 2 0 }
  if (%starter = on) {
    if ($did = 3) { did -a Calculator 1 1 | set %didgit 1 }
    if ($did = 4) { did -a Calculator 1 2 | set %didgit 2 }
    if ($did = 5) { did -a Calculator 1 3 | set %didgit 3 }
    if ($did = 6) { did -a Calculator 1 4 | set %didgit 4 }
    if ($did = 7) { did -a Calculator 1 5 | set %didgit 5 }
    if ($did = 8) { did -a Calculator 1 6 | set %didgit 6 }
    if ($did = 9) { did -a Calculator 1 7 | set %didgit 7 }
    if ($did = 10) { did -a Calculator 1 8 | set %didgit 8 }
    if ($did = 11) { did -a Calculator 1 9 | set %didgit 9 }
    if ($did = 22) { did -a Calculator 1 0 | set %didgit 0 }
    if ($did = 12) { did -a Calculator 1 x }
    if ($did = 13) { did -a Calculator 1 + }
    if ($did = 14) { did -a Calculator 1 - }
    if ($did = 15) { did -a Calculator 1 ÷ }
    if ($did = 17) { did -a Calculator 1 . }
    if ($did = 23) { did -r Calculator 1 | did -r Calculator 2 }
    if ($did = 16) { did -r Calculator 2 | set %sum $calc($replace($did(1),²,^2,³,^3,sr,^0.5,cr,^0.3333333333,x,*,÷,/,Ans,%sum,E,*10^)) | did -a Calculator 2 %sum | did -r calculator 1 | did -a calculator 1 Ans | set %caled on }
    if ($did = 20) { did -a Calculator 1 ³ }
    if ($did = 19) { did -a Calculator 1 ² }
    if ($did = 24) { did -a Calculator 1 3.141592654 }
    if ($did = 21) { did -a Calculator 1 sr }
    if ($did = 18) { did -ra calculator 1 $left($did(calculator,1),$calc($len($did(calculator,1)) -1)) | did -r calculator 1 | did -a calculator 1 Ans }
    if ($did = 25) { set %sum $sin($did(1)) | did -r calculator 2 | did -a calculator 2 %sum | did -r calculator 1 | did -a calculator 1 Ans }
    if ($did = 26) { set %sum $asin($did(1)) | did -r calculator 2 | did -a calculator 2 %sum | did -r calculator 1 | did -a calculator 1 Ans }
    if ($did = 27) { set %sum $cos($did(1)) | did -r calculator 2 | did -a calculator 2 %sum | did -r calculator 1 | did -a calculator 1 Ans }
    if ($did = 28) { set %sum $acos($did(1)) | did -r calculator 2 | did -a calculator 2 %sum | did -r calculator 1 | did -a calculator 1 Ans }
    if ($did = 29) { set %sum $round($did(1),10) | did -r calculator 2 | did -a calculator 2 %sum | did -r calculator 1 | did -a calculator 1 Ans }
    if ($did = 30) { did -a calculator 1 ( }
    if ($did = 31) { did -a calculator 1 ) }
    if ($did = 32) { set %MM $did(2) }
    if ($did = 33) { did -a Calculator 1 %MM }    
    if ($did = 35) { set %starter off | did -r Calculator 2 | did -r Calculator 1 }
    if ($did = 36) { clipboard $did(2) }
    if ($did = 37) { did -a calculator 1 Ans }
    if ($did = 41) { set %sum $Abs($did(1)) | did -r calculator 2 | did -a calculator 2 %sum | did -r calculator 1 | did -a calculator 1 Ans }
    if ($did = 42) { set %sum $log($did(1)) | did -r calculator 2 | did -a calculator 2 %sum | did -r calculator 1 | did -a calculator 1 Ans }
    if ($did = 38) { did -a calculator 1 ^ }
    if ($did = 48) { did -a calculator 1 E }
}

Comments

Sign in to comment.
Sachit Reddy   -  Jul 20, 2011

how to use this

 Respond  
asakura   -  Dec 24, 2009

and what if u want to do negatives? hmm?

 Respond  
slub77   -  Dec 19, 2009

lol or even simpler

on *:text:Scalc*:#:{
  if $2 isnum 0-99999999999999999 && $4 isnum 0-99999999999999999 {
    notice $nick $2 $3 $4 = $calc($2 $3 $4)
  }
  else { msg $chan Error }
}
 Respond  
asakura   -  Aug 26, 2008

haha cheers, but then tbook thats been done and its all old stuff get with it! lol

 Respond  
BlueThen   -  Aug 11, 2008

Very good alignment! Don\'t listen to tbook.

I\'m bluethen, and I approve of this dialog. :P

 Respond  
tbook   -  Aug 11, 2008

Why not just keep the script simple?

on :TEXT:.calc:#CHANNEL:{
if $1 == %calc $+ .calc {
if $2 == %calc $+ $null { /calc $2- | halt }
else { /calc $2- | halt }
}
}
alias calc {
if ($1- != $null) {
msg $chan Calculating
msg $chan Result $calc($1-)
else msg $chan Calculater: No parameters given. Halting.
}
}

Open remote paste it in

replace #channel with a channel you want to use it in.

join that channel type .calc 2+2, 3.3*2.5, etc.

good luck :] want more scripts? or need support on this one?
Join #Audity and leave me a message

 Respond  
asakura   -  Jul 18, 2008

cool ill add that to my one on mirc =D cheers

 Respond  
guest598594   -  Jul 18, 2008

Well you should have a closing one for every opening one. If someone put another snippet under yours, it wouldn\'t function properly ;)

Oh and also:

    if ($did = 26) { set %sum $asin($did(1)) | did -r calculator 2 | did -a calculator 2 %sum | did -r calculator 1 | did -a calculator 1 Ans }

You can combine switches, so you could make it:

    if ($did == 26) { set %sum $asin($did(1)) | did -ra calculator 2 %sum | did -ra calculator 1 Ans }
 Respond  
asakura   -  Jul 18, 2008

its about my 4th dialog lol but its my first posted one here :p and does that bracket do much lol i never added em because i thought it didnt do nything lnog as the line above ended with one

 Respond  
guest598594   -  Jul 18, 2008

You sure this is your first script? Well if it is, great job learning dialogs this quickly.

Btw, you forgot a } at the end.

 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.