#include <acknex.h>
STRING* defstr="#100";
STRING* test_str="";
//is input box open
int is_input_box_on=0;
//test variable
int test_num;
//debug
function textx_startup()
{
while(1)
{
if(is_input_box_on==1)
{
draw_text("Enter any number",1,1,COLOR_GREEN);
draw_text(test_str,1,200,COLOR_GREEN);
}
DEBUG_VAR(test_num,20);
wait(1);
}
}
function on_f1_event()
{
beep();
//clear all strings
str_cpy(test_str,"");
test_num=0;
char this_char = 0;
is_input_box_on=1;
while(this_char!=13)//wait until press enter
{
this_char = inchar(defstr);
if(this_char!=1)
{
//if is numeric
if(str_stri(this_char,"0")||
str_stri(this_char,"1")||
str_stri(this_char,"2")||
str_stri(this_char,"3")||
str_stri(this_char,"4")||
str_stri(this_char,"5")||
str_stri(this_char,"6")||
str_stri(this_char,"7")||
str_stri(this_char,"8")||
str_stri(this_char,"9"))
{
str_cat(test_str,defstr);
}
else
{
//if isn't numeric don't do anything
}
}
wait(1);
}
//convert string to number
test_num=str_to_int(test_str);
//turn of the box
is_input_box_on=0;
//if bigger than 100
if(test_num>100)
{
printf("Error: Value is bigger than 100!");
//try again
on_f1_event();
}
}
function main()
{
on_f1_event();
}
void on_esc_event()
{
sys_exit("");
}