#include #include #include #include #include #include /* set up a handler for our custom resources, in the net4res/ directory */ WebResourceResFile path = static new RexPattern('^/net4res/') ; /* the main command window */ cmdwin: WebCommandWin ; /* the main status window */ statwin: WebStatusWin ; /* * Main entrypoint */ main(args) { randomize(); local host; if (args.length() >= 2 && args.sublist(2).indexOf('-local') != nil) host = 'localhost'; else host = getLocalIP(); /* set up the server */ local srv = new HTTPServer(host, nil, 65535); "HTTP server listening on <>:<>
"; /* connect to the user interface */ webMainWin.connect(srv); /* set up the command window and status line */ webMainWin.createFrame(cmdwin, 'cmd', '0, stat.bottom, 100%, 100%'); webMainWin.createFrame(statwin, 'stat', '0, 0, 100%, content.height'); /* set the default output function to write to the command window */ t3SetSay({txt: cmdwin.write(toString(txt))}); statwin.setStatus('Welcome'); statwin.resize(); local turnCount = 0; "http://<>:<>/?TADS_session=<>

"; "Hello! This is our first test! We shall see how it goes!"; for (;;) { "

Please enter your name:
>"; statwin.setStatus('Name Entry', turnCount++); local txt = cmdwin.getInputLine(); ""; "

Well, it looks like you entered <>! If this is correct, please press 1. If not, press 2.
>"; statwin.setStatus('Confirmation', turnCount++); local n = cmdwin.getInputLine(); ""; if (n == '1') { "

Great! We\'ll call that a day, then!
"; break; } else if (n != '2') { "

You didn\'t press 1 or 2, but we\'ll assume you need to re-enter your name."; } } /* done - shut down the server */ "

Shutting down the server...
"; eventPage.sendEvent(''); ClientSession.shutdownWait(); //t3SetSay(&tadsSay); local x = nil; x.sendEvent(); "Shutting down the HTTP server...
"; srv.shutdown(true); }