StaticX__'s Calculator

By StaticX__ on Jul 30, 2008

I tried to make a calculator, it's very simple and I don't think it has got any bugs.. try it and tell me
You type /static.calc to open it

dialog staticcalc {
  title "StaticX__'s Calculator"
  size -1 -1 240 175
  option pixels notheme
  button "+", 1, 69 52 23 16
  button "-", 2, 94 52 23 16
  button "*", 3, 119 52 23 16
  button "/", 4, 144 52 23 16
  edit "", 5, 37 30 164 20, autohs limit 20
  edit "", 6, 37 91 164 20, autohs limit 20
  text "1st number", 7, 36 11 100 17
  text "2nd number", 8, 37 72 100 17
  edit "", 9, 37 130 164 20, read autohs limit 20
  text "Result", 10, 37 111 100 17
}

on *:DIALOG:staticcalc:sclick:*:{
  did -ra $dname 9 $calc($did(5) $did($did).text $did(6))
}

alias static.calc { dialog -m staticcalc staticcalc }

Comments

Sign in to comment.
StaticX__   -  Jul 31, 2008

ok, thx anyway, that will help me improve the writing of my codes.

 Respond  
Scakk   -  Jul 31, 2008

They were not wrong at all as they did work. Noutrious and myself were just showing you ( and perhaps others ) alternate ways of doing things.

 Respond  
StaticX__   -  Jul 31, 2008

Done. But I don\'t know why my codes are always wrong :/

 Respond  
Scakk   -  Jul 30, 2008

You could always make the sclick part into the below to shortenit even more.

on *:DIALOG:staticcalc:sclick:*:{ did -ra $dname 9 $calc($did(5) $did($did).text $did(6)) }
 Respond  
Noutrious   -  Jul 30, 2008
alias static.calc dialog $+(-,$iif($dialog(staticcalc),v,m staticcalc)) staticcalc
on *:DIALOG:staticcalc:sclick:*:{
  if ($did = 1) did -ra $dname 9 $calc($did(5) + $did(6))
  if ($did = 2) did -ra $dname 9 $calc($did(5) - $did(6))
  if ($did = 3) did -ra $dname 9 $calc($did(5) * $did(6))
  if ($did = 4) did -ra $dname 9 $calc($did(5) / $did(6))
}

This would shorten your code a-lot. :)

 Respond  
StaticX__   -  Jul 30, 2008

ok thx, edited :)

 Respond  
Scakk   -  Jul 30, 2008

In the /did lines you can replace %dialog with $dname as it will return the name of the dialog as it is under the on dialog line for the dialog being used.

Example:

/did -ra $dname 9 $calc($did(5) + $did(6))

Edit: Allows you to remove the below line.

var %dialog = staticcalc
 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.