Calculator

By Del_Felesif on Sep 12, 2005

It's just a simple calculator, you type in your command, and it's pretty self-explanatory.

dialog calculator {
  title "Jon's Calculator"
  size -1 -1 200 240
  edit "", 1, 5 5 190 20,
  button "+", 2, 5 30 20 20,
  button "-", 3, 30 30 20 20,
  button "*", 4, 55 30 20 20,
  button "/", 5, 80 30 20 20,
  list 6, 5 55 190 20, size
  button "Calculate", 7, 5 80 60 30
  button "Enter", 8, 155 30 40 20, default
  button "Say", 9, 70 80 60 30
  button "New", 10, 135 80 60 30
  button "(", 11, 105 30 20 20,
  button ")", 12, 130 30 20 20,
  list 13, 5 115 190 20, size
  button "1", 14, 5 140 60 20,
  button "2", 15, 70 140 60 20,
  button "3", 16, 135 140 60 20,
  button "4", 17, 5 165 60 20,
  button "5", 18, 70 165 60 20,
  button "6", 19, 135 165 60 20,
  button "7", 20, 5 190 60 20,
  button "8", 21, 70 190 60 20,
  button "9", 22, 135 190 60 20,
  button "0", 23, 70 215 60 20,
}
alias calc {
  dialog -mr calculator calculator
}
on *:DIALOG:calculator:sclick:*: {
  var %calc.say = $did($dname,6).seltext
  var %calc.text = $did(calculator,1).text
  if ($did == 2) {
    set %calc.eq %calc.eq %calc.text +
    var %calc.part = %calc.part + 1
    did -r calculator 1
  }
  if ($did == 3) {
    set %calc.eq %calc.eq %calc.text -
    var %calc.part = %calc.part + 1
    did -r calculator 1
  }
  if ($did == 4) {
    set %calc.eq %calc.eq %calc.text *
    var %calc.part = %calc.part + 1
    did -r calculator 1
  }
  if ($did == 5) {
    set %calc.eq %calc.eq %calc.text /
    var %calc.part = %calc.part + 1
    did -r calculator 1
  }
  if ($did == 7) {
    did -r calculator 6
    set %calc.answer $calc(%calc.eq)
    didtok calculator 6 44 %calc.answer
  }
  if ($did == 8) {
    set %calc.eq %calc.eq %calc.text
    var %calc.part = %calc.part + 1
    did -r calculator 1
  }
  if ($did == 9) {
    var %calc.say = $did($dname,6).seltext
    var %calc.say2 = $did($dname,13).seltext
    say %calc.say
    say %calc.say2
  }
  if ($did == 10) {
    set %calc.part 1
    set %calc.eq  
    did -r calculator 6
  }
  if ($did == 11) {
    set %calc.eq %calc.eq %calc.text (
    var %calc.part = %calc.part + 1
    did -r calculator 1
  }
  if ($did == 12) {
    set %calc.eq %calc.eq %calc.text )
    var %calc.part = %calc.part + 1
    did -r calculator 1
  }
  if ($did != 13) {
    did -r calculator 13
    didtok calculator 13 44 %calc.eq
  }
  if ($did == 14) {
    set %calc.eq %calc.eq $+ 1
    did -r calculator 13
    didtok calculator 13 44 %calc.eq
  }
  if ($did == 15) {
    set %calc.eq %calc.eq $+ 2
    did -r calculator 13
    didtok calculator 13 44 %calc.eq
  }
  if ($did == 16) {
    set %calc.eq %calc.eq $+ 3
    did -r calculator 13
    didtok calculator 13 44 %calc.eq
  }
  if ($did == 17) {
    set %calc.eq %calc.eq $+ 4
    did -r calculator 13
    didtok calculator 13 44 %calc.eq
  }
  if ($did == 18) {
    set %calc.eq %calc.eq $+ 5
    did -r calculator 13
    didtok calculator 13 44 %calc.eq
  }
  if ($did == 19) {
    set %calc.eq %calc.eq $+ 6
    did -r calculator 13
    didtok calculator 13 44 %calc.eq
  }
  if ($did == 20) {
    set %calc.eq %calc.eq $+ 7
    did -r calculator 13
    didtok calculator 13 44 %calc.eq
  }
  if ($did == 21) {
    set %calc.eq %calc.eq $+ 8
    did -r calculator 13
    didtok calculator 13 44 %calc.eq
  }
  if ($did == 22) {
    set %calc.eq %calc.eq $+ 9
    did -r calculator 13
    didtok calculator 13 44 %calc.eq
  }
  if ($did == 23) {
    set %calc.eq %calc.eq $+ 0
    did -r calculator 13
    didtok calculator 13 44 %calc.eq
  }
}
on *:DIALOG:calculator:close:*: {
  set %calc.part 1
  set %calc.eq  
}
on *:LOAD: {
  echo -a Yes, this does do Order of Operations.
  echo -a Open with /calc
}

Comments

Sign in to comment.
Pariah   -  Sep 13, 2005

I\'ve always been a fan of /run calc.exe but I\'m wierd like that.

 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.