Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- alias tempcon { dialog $iif($dialog(temperature),-v,-m) temperature temperature }
- menu * {
- Temperature: tempcon
- }
- dialog temperature {
- title "Temperature Converter"
- size -1 -1 150 75
- option dbu
- text "From:", 100, 35 3 26 10, nowrap
- text "To:", 99, 105 3 26 10, nowrap
- text "=", 98, 73 16 3 5, nowrap
- edit "", 1, 17 11 50 10
- edit "", 2, 83 11 50 10, style disable
- list 3, 15 24 55 30, sort vsbar
- list 4, 80 24 55 30, sort vsbar
- button "Convert!", 5, 5 57 45 15
- button "Clear!", 6, 100 57 45 15
- button "Exit!", 7, 53 58 45 13
- check "Round #'s", 8, 58 47 35 10, nowrap
- }
- on *:dialog:temperature:*:*: {
- if ($devent == init) && ($did == 0) { did -b $dname 5-6 | did $iif($did(8).state == 1,-c,-u) $dname 8 | didtok $dname 3-4 32 Fahrenheit Celsius Kelvin }
- if ($devent == sclick) {
- if ($did(1).edited) && ($did(3).sel) && ($did(4).sel) { did -e $dname 5 }
- if ($did == 5) {
- if ($did(1) isalpha) { noop $input(You can only convert numbers!,uwok1,Error!) }
- else {
- var %w $did(1), %x $did(3).seltext, %y $did(4).seltext
- if (%x == Fahrenheit) && (%y == Fahrenheit) { did -ra $dname 2 $iif($did(8).state == 0,%w,$round(%w,0)) }
- if (%x == Fahrenheit) && (%y == Celsius) { var %z $calc((%w -32) / 1.8)) | did -ra $dname 2 $iif($did(8).state == 0,%z,$round(%z,0)) }
- if (%x == Fahrenheit) && (%y == Kelvin) { var %z $calc(((%w - 32) / 1.8) + 273.15) | did -ra $dname 2 $iif($did(8).state == 0,%z,$round(%z,0)) }
- if (%x == Celsius) && (%y == Celsius) { did -ra $dname 2 $iif($did(8).state == 0,%w,$round(%w,0)) }
- if (%x == Celsius) && (%y == Fahrenheit) { var %z $calc((%w * 1.8) + 32)) | did -ra $dname 2 $iif($did(8).state == 0,%z,$round(%z,0)) }
- if (%x == Celsius) && (%y == Kelvin) { var %z $calc(%w + 273.15) | did -ra $dname 2 $iif($did(8).state == 0,%z,$round(%z,0)) }
- if (%x == Kelvin) && (%y == Kelvin) { did -ra $dname 2 $iif($did(8).state == 0,%w,$round(%w,0)) }
- if (%x == Kelvin) && (%y == Fahrenheit) { var %z $calc(((%w - 273.15) * 1.8 ) + 32) | did -ra $dname 2 $iif($did(8).state == 0,%z,$round(%z,0)) }
- if (%x == Kelvin) && (%y == Celsius) { var %z $calc(%w - 273.15) | did -ra $dname 2 $iif($did(8).state == 0,%z,$round(%z,0)) }
- }
- did -e $dname 6
- }
- if ($did == 6) { did -ra $dname 1-2 | did -u $dname 3-4 | did -b $dname 5-6 }
- if ($did == 7) { did -u $dname 8 | dialog -x $dname }
- }
- if ($devent == edit) && ($did == 1) && ($did(3-4).seltext) { did $iif($did(1),-e,-b) $dname 5 }
- if ($devent == close) { did -u $dname 8 }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement