Simple code question
  • Caterpillar
    Caterpillar
    Blasterreal
    Posts: 40 from 2007/3/30
    Hi, i create simple Fahrenheit / Celcius converter with MUI, But i get little error, i think contents value must be float, how do that via MUI

    Quote:

    switch(id)
    {

    case MUIV_Application_ReturnID_Quit:
    running = FALSE;
    break;

    case CALCULATE:
    {
    float cell;

    get(fahrenText, MUIA_String_Contents, &contents);

    cell =(5.0/9.0) * (contents - 32.0); //ERROR main.c:127: invalid operands to binary -

    set(celciusText, MUIA_String_Contents, cell);

    }
    break;
  • »01.01.23 - 19:43
    Profile Visit Website
  • MorphOS Developer
    jacadcaps
    Posts: 2996 from 2003/3/5
    From: Canada
    MUIA_String_Contents must be a string, so you'll have to format your float into a temporary one first.
  • »01.01.23 - 20:13
    Profile Visit Website
  • Caterpillar
    Caterpillar
    Blasterreal
    Posts: 40 from 2007/3/30
    Thx jaca,

    Solition here, it work now

    Quote:

    switch(id)
    {

    case MUIV_Application_ReturnID_Quit:
    running = FALSE;
    break;

    case CALCULATE:
    {
    float cell;
    float value;
    char value2[32];

    get(fahrenText, MUIA_String_Contents, &contents);
    value = atof (contents);
    cell =(5.0/9.0) * (value - 32.0);

    sprintf (value2, "%f", cell);

    set(celciusText, MUIA_String_Contents, value2);

    }
    break;

    }
  • »01.01.23 - 20:38
    Profile Visit Website