Originally Posted by 3run
Well, you needed to use stuff I've made in this thread.

Try this code:
Code
BMAP *pointer_tga = "pointer.png";

STRING *name_str = "Click to Enter Value Here!";
STRING *enter_value_str = "Click to Enter Value Here!";
STRING *error_msg_str = "You need to enter a number from 0 to 99!";
STRING *data_saved_msg_str = "Data was successfully saved into the log file.";

function input_name(); 

PANEL *input_pan = 
{
	layer = 10;
	bmap = "textbox.png";
	on_click = input_name;
	flags = SHOW;
}

TEXT *name_txt = 
{
	layer = 11; // just above the textbox panel
	font = "Calibri#30";   
	string(name_str);
	flags = SHOW | CENTER_X | CENTER_Y;
}

// receives a STRING and position (num) of a character in that STRING
// returns a single character as a STRING
STRING *get_next_char(STRING *src_str, int num)
{
	if(!src_str)
	{
		return NULL;
	}
	
	if(num > str_len(src_str))
	{
		return NULL;
	}
	
	STRING *temp_str = "";
	str_cpy(temp_str, src_str);
	str_trunc(temp_str, str_len(src_str) - num);
	str_clip(temp_str, num - 1);
	
	return temp_str;
}

// returns TRUE (1) if string is numeric
// otherwise returs FALSE (0)
var is_numeric_str(STRING *src_str)
{
	if(!src_str)
	{
		return false;
	}
	
	int i = 0, j = 0, res = true;
	
	for (i = 0; i < str_len(src_str); i++)
	{
		STRING *temp_str = get_next_char(src_str, i + 1);
		
		for (j = 0; j < 10; j++)
		{
			if (!str_cmpi(temp_str, str_for_num(NULL, j)))
			{
				res = false;
				continue;
			}
			
			res = true;
			break;
		}
		
		if(res == false)
		{
			break;
		}
	}
	
	return res;
}

// returns TRUE (1) is string's length is zero
// otherwise returns FALSE (0)
var is_empty_str(STRING *str)
{
	if(!str)
	{
		return false;
	}
	
	if(str_len(str) > 0)
	{
		return false;
	}
	else
	{
		return true;
	}
}

function input_name()
{
	str_cpy(name_str, "   ");
	var input = inkey(name_str);
	
	if(input != 13) // terminated input with ESC or anything else ?
	{
		// then return "Click to Enter Value Here!" message back
		// same for all errors bellow !
		str_cpy(name_str, enter_value_str);
	}
	else // pressed enter ?
	{
		// string is empty ? then show error message
		if(is_empty_str(name_str))
		{
			error(error_msg_str);
			str_cpy(name_str, enter_value_str);
		}
		else // if not ?
		{
			// if numeric ? then save the file
			if(is_numeric_str(name_str))
			{
				// we can also check for the range here
				// if it's more than 2 characters, then we are out of the range
				if(str_len(name_str) > 2)
				{
					error(error_msg_str);
					str_cpy(name_str, enter_value_str);
				}
				else // 0 ... 99
				{
					var filehandle;
					filehandle = file_open_write("log.xml"); 
					file_str_write(filehandle, name_str); 
					file_close(filehandle);
					error(data_saved_msg_str);
				}
			}
			else // not numeric ? then show error message
			{
				error(error_msg_str);
				str_cpy(name_str, enter_value_str);
			}
		}
	}
}

function mouse_startup()
{
	warn_level = 6; // make sure to show all errors
	fps_max = 60; // limit fps to 60
	
	mouse_mode = 4; // this will take care of mouse_cursor/mouse_pos stuff
	mouse_map = pointer_tga;
	
	while(!key_esc)
	{
		// we need to do this in order to have proper panel positions with different screen resolutions
		input_pan->pos_x = (screen_size.x / 2) - (bmap_width(input_pan->bmap) / 2);
		input_pan->pos_y = (screen_size.y / 2) - (bmap_height(input_pan->bmap) / 2) - 64;
		
		name_txt->pos_x = input_pan->pos_x + (bmap_width(input_pan->bmap) / 2);
		name_txt->pos_y = input_pan->pos_y + (bmap_height(input_pan->bmap) / 2);
		
		wait(1);
	}
}


Greets!


Thank you @3run laugh That was great solution! This is exactly what I want to do.