phpInDev

get_real

float get_real ( string text, float default )

Asks the user for a real number using dialog similiar to get_integer. The real number is accepted in any format accepted by the real() function in GM. The dialog displays the text and uses default as the default value in the field. If invalid number is given, 0 will be returned.

Note: This script requires the is_numeric script from this site to work.

Example 1. using get_real

{ number = get_real("Enter real number", 0); show_message(string(number)); }

This could for example show:

1.12

Code for get_real.gml

{
    var realstring;
    
    realstring = get_string(string(argument0), string(argument1));
    
    if (is_numeric(realstring))
    {
        return real(realstring);
    }
    else
    {
        return 0;
    }
}