well i was bored and thought id make a dialog for a temperature script lol pretty self explaining enjoy and rate :p
menu * {
.Temperature:dialog -m tmp tmp
}
dialog tmp {
title "Temperature converter"
size -1 -1 200 90
option pixels
text "Celcius to Fahrenheit" 1, 5 7 120 20
button "Switch" 2, 130 5 60 20
edit "" 3, 5 35 100 20
button "Convert" 4, 130 35 60 20
text "" 5, 5 65 190 20
}
on *:DIALOG:tmp:init:0:{
set %xf 2
}
on *:DIALOG:tmp:sclick:*: {
if ($did == 4) {
if (%xf = 1) && ($did(3) = 0) {
did -ra $dname 5 -17.77°C
}
elseif ($did(3) !isnum) { did -ra Tmp 5 Please enter a number. | halt }
if (%xf = 1) && ($did(3) isnum) {
set %aae $calc($did(3) - 32)
set %bv $calc(%aae * 0.55555555555555555555555555555556)
did -ra $dname 5 $round(%bv,2) $+ °C
}
}
if ($did == 4) {
if (%xf = 2) && ($did(3) = 0) {
did -a $dname 5 32°F
}
elseif ($did(3) isnum) && (%xf = 2) {
set %aab $calc($did(3) * 1.8)
set %bc $calc(%aab + 32)
did -ra $dname 5 $round(%bc,2) $+ °F
}
}
if ($did = 2) { set %xf $replace($did(1),Celcius to Fahrenheit,1,Fahrenheit to Celcius,2) | did -ra $dname 1 $replace(%xf,1,Fahrenheit to Celcius,2,Celcius to Fahrenheit) }
}
you dont need both of these
elseif ($did(3) isletter) { did -ra tmp 5 Please use numbers only. | halt }
elseif ($did(3) !isnum) { did -ra Tmp 5 Please enter a number. | halt }
just do
elseif ($did(3) !isnum) { did -ra tmp 5 Please use numbers only. }
and maybe have it disable the convert button till you enter a number in the edit box
but all in all it\'s a nice lil dialog