  title Temperature Converter
  dialog CREATE,"Degrees",-1,-1,135,55
  dialog ADD,STYLE,SmallText,MS Sans Serif,8,B
  dialog ADD,Edit,Input,5,5,40,,0,
  dialog ADD,Text,Status,8,47,,,"?",SmallText
  dialog ADD,Text,Result,33,5,,,"Ready...",SmallText
  dialog ADD,BUTTON,F,5,60,70,20,"To Farenheit"
  dialog ADD,BUTTON,C,30,60,70,20,"To Celcius"
  dialog SHOW

:EVLOOP
  wait EVENT
  goto @event()

:FBUTTON
  %c = @dlgtext(Input)
  if %c
    rem farenheit = 32 + (centigrade * 9)/5;
    %f = @fmul(%c, 9)
    %f = @fdiv(%f, 5)
    %f = @fadd(%f, 32)
    %f = @format(%f, .0)
    dialog SET, Result, %f F
    dialog SET, Status, "C"
  end 
  dialog FOCUS, Input
  goto EVLOOP

:CBUTTON
  %f = @dlgtext(Input)
  if %f
    rem Centrigrade = (farenheit-32)*5/9
    %c = @fsub(%f, 32)
    %c = @fmul(%c, 5)
    %c = @fdiv(%c, 9)
    %c = @format(%c, .0)
    dialog SET, Result, %c C
    dialog SET, Status, "F"
  end 
  dialog FOCUS, Input
  goto EVLOOP

:CLOSE
  exit 
