Heres a standalone script showing it in action. (formatting ugly UNTIL pasted into SED)
Run the script and then anything you type gets added to the text object by the "get_inchar()" function.
If you press 'Enter', the function will terminate itself and beep.
BUT, if you press 'F1', the function will terminate (and beep) via "inkey_active" being set to zero in main().
#include <acknex.h>
#include <default.c>
TEXT* buffer = { string( "Buffer = "); font="Arial#18b"; flags=SHOW; }
void get_inchar()
{
STRING* tmp_str = str_create(" "); char this_char = 0;
while((this_char!=1)&&(this_char!=13)) // exit on "1" or "13"
{ // 13 = pressed enter here
// 1 = inchar terminated by main
this_char = inchar(tmp_str);
if(this_char!=1) str_cat((buffer.pstring)[0], tmp_str);
wait(1); //This wait is !CRITICAL! or it wont react to inkey_active changes
}
beep();
}
function main()
{
get_inchar(); //start capturing keys into "buffer"
while(1)
{
if(key_f1) inkey_active = 0; // terminating capture from
// "outside" the inchar function
wait(1);
}
}