calculator dialog

Platform:  mIRC
Published  Sep 10, 2011
Updated  Jun 23, 2012
to use open up the dialog through the menu

and click the buttons and click calculate

i will try and update and make it better soon

have fun ;)

$comma alias by: FiberOPtics alias -l comma {
var %a, %b = $regsub($ticks,$$1,/\G([+-]?\d+?)(?=(?:\d{3})++(?=\.\d++$|$))/g,\1 $+ $chr(44),%a)
return %a
}
dialog calc {
title "Dialog Calculator"
size -1 -1 150 112
option dbu
box "Calculator Controls" 1, 5 5 140 60
box "Calculation/Awnser" 2, 5 67 140 38
button "1" 3, 9 14 20 10
button "2" 4, 31 14 20 10
button "3" 5, 52 14 20 10
button "4" 6, 9 26 20 10
button "5" 7, 31 26 20 10
button "6" 8, 52 26 20 10
button "7" 9, 9 38 20 10
button "8" 10, 31 38 20 10
button "9" 11, 52 38 20 10
button "0" 12, 9 50 42 10
button "k" 13, 78 14 20 10
button "m" 14, 99 14 20 10
button "b" 15, 120 14 20 10
button "." 16, 52 50 20 10
button "+" 17, 78 26 20 10
button "-" 18, 99 26 20 10
button "*" 19, 120 26 20 10
button "/" 20, 78 37 20 10
button "Clear All" 21, 99 37 41 10
edit "" 22, 10 75 130 12, autohs read multi
button "Calculate" 23, 10 89 130 10
}
menu * {
Calculator:{
dialog $iif($dialog(calc),-v,-md) calc calc
}
}
alias calc {
dialog -mt calc calc
}
on *:dialog:calc:sclick:19:{ did -a calc 22 * }
on *:dialog:calc:sclick:18:{ did -a calc 22 - }
on *:dialog:calc:sclick:9:{ did -a calc 22 7 }
on *:dialog:calc:sclick:10:{ did -a calc 22 8 }
on *:dialog:calc:sclick:11:{ did -a calc 22 9 }
on *:dialog:calc:sclick:17:{ did -a calc 22 + }
on *:dialog:calc:sclick:6:{ did -a calc 22 4 }
on *:dialog:calc:sclick:7:{ did -a calc 22 5 }
on *:dialog:calc:sclick:8:{ did -a calc 22 6 }
on *:dialog:calc:sclick:3:{ did -a calc 22 1 }
on *:dialog:calc:sclick:4:{ did -a calc 22 2 }
on *:dialog:calc:sclick:5:{ did -a calc 22 3 }
on *:dialog:calc:sclick:12:{ did -a calc 22 0 }
on *:dialog:calc:sclick:16:{ did -a calc 22 . }
on *:dialog:calc:sclick:13:{ did -a calc 22 k }
on *:dialog:calc:sclick:14:{ did -a calc 22 m }
on *:dialog:calc:sclick:15:{ did -a calc 22 b }
on *:dialog:calc:sclick:21:{ did -r calc 22 }
on *:dialog:calc:sclick:20:{ did -a calc 22 / }
on *:dialog:calc:sclick:23:{
if (!$did(22)) {
noop $input(Please specify a calculation in the edit box and click calculate,w,Warning!)
}
else {
did -ra calc 22 $comma($calc($replace($remove($did(22),$chr(44)),pi,$pi,m,000000,k,000,b,000000000)))
}
}

Comments

Sign in to comment.
toclafane1   -  Jun 23, 2012
@Warriorii - Updated. :)
 Respond  
Warriorii   -  Jun 22, 2012
Nice job, the only problem is if you put in a formula of 25/2 it will give u the answer 13 instead of 12.5
 Respond  
ProSec   -  Nov 27, 2011
nvm i got it
 Respond  
ProSec   -  Nov 27, 2011
question: im doing this in DCX. So my calculate button is like this: xdid -ra pscalc 1 $calc($xdid(pscalc, 1)) but i get an invalid argument error. Help?
 Respond  
_Dean_   -  Sep 11, 2011
its always a good comment posting alternative ways to do it
 Respond  
jaytea   -  Sep 11, 2011
not that i would recommend it, but here's a funny little method just fyi:

Code

 


edit: haha, just realized the buttons' text are precisely what you want to add to the editbox. a range check + $did($did).text would also suffice, and would be much more sensible than renumbering your controls:

Code

 
 Respond  
Jethro   -  Sep 11, 2011
It's hard to make a scientific, foolproof calculator out of MSL. The closest I've gotten to is socket through Google's calculator. Even so, Google's is not 100% scientific and will run into problem with some complex math calculations. Nothing's guaranteed.
 Respond  
_Dean_   -  Sep 10, 2011
as Jethro said, i think that use a $replacex is better
i added the /
since on your original code, you didnt put the sclick for $did 3

Code

 


this calculator has no accuracy, since if you use 7.3/2 it will return 4
 Respond  
troll   -  Sep 10, 2011
nice br0
 Respond  
toclafane1   -  Sep 10, 2011
i updated it so that it gives the calculation in the same box the sum is put in to also made a del button so u can erase the sum and re input it
 Respond  
troll   -  Sep 10, 2011
kkkkkkk
 Respond  
troll   -  Sep 10, 2011
k00l
 Respond  
toclafane1   -  Sep 10, 2011
thanks for your suggestion again Jethro :)
 Respond  
Jethro   -  Sep 10, 2011
I was aiming for one dialog event instead of one per each. It's just an example only. I think you could do it with $replacexcs() too, which will make it a lot shorter.
 Respond  
Dani_l11   -  Sep 10, 2011
where's the regexmatch?

also why add if ($devent == sclick) {

just using on *:dialog:calc:sclick:*:{ 's shorter
 Respond  
Jethro   -  Sep 10, 2011
You can do it with one event like this:

Code

 
 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.