#include "t3.h"
#include "tads.h"

_say_embed(str) { tadsSay(str); }

class RuntimeError: object
    construct(errno, ...) { errno_ = errno; }
    display = "Runtime Error: <<errno_>>"
    errno_ = 0
;

_main(args)
{
    try
    {
        t3SetSay(_say_embed);
        main();
    }
    catch (RuntimeError rte)
    {
        "\n<<rte.display>>\n";
    }
}

function main()
{
    local x;
    
    "inputKey() library fuction tests.\n
    See http://www.tads.org/t3doc/doc/sysman/tadsio.htm / inputEvent(timeout?) table.\n
    Loops until you push 'q'.\n\n";

	local done = nil;
	while (! done) { 
	    "Press a key...";
	    x = inputKey();
	    "You typed: \"<<x>>\"\n";
	    done = (x == 'q' || x == nil || x == '[eof]');
	}

    "\n\nDone.\n";
}

