| 1 |
/* |
| 2 |
* input tests - input, inputKey, inputEvent, inputDialog |
| 3 |
*/ |
| 4 |
|
| 5 |
#include "t3.h" |
| 6 |
#include "tads.h" |
| 7 |
|
| 8 |
_say_embed(str) { tadsSay(str); } |
| 9 |
|
| 10 |
class RuntimeError: object |
| 11 |
construct(errno, ...) { errno_ = errno; } |
| 12 |
display = "Runtime Error: <<errno_>>" |
| 13 |
errno_ = 0 |
| 14 |
; |
| 15 |
|
| 16 |
_main(args) |
| 17 |
{ |
| 18 |
try |
| 19 |
{ |
| 20 |
t3SetSay(_say_embed); |
| 21 |
main(); |
| 22 |
} |
| 23 |
catch (RuntimeError rte) |
| 24 |
{ |
| 25 |
"\n<<rte.display>>\n"; |
| 26 |
} |
| 27 |
} |
| 28 |
|
| 29 |
function main() |
| 30 |
{ |
| 31 |
local x; |
| 32 |
|
| 33 |
"Input and input key tests.\n"; |
| 34 |
|
| 35 |
"Enter a command: "; |
| 36 |
x = inputLine(); |
| 37 |
"You entered: \"<<x>>\"\n"; |
| 38 |
|
| 39 |
"Press a key..."; |
| 40 |
x = inputKey(); |
| 41 |
"You typed: \"<<x>>\"\n"; |
| 42 |
|
| 43 |
"Enter an event..."; |
| 44 |
x = inputEvent(); |
| 45 |
"Event code = <<x[1]>>, additional data = \"<< |
| 46 |
x.length() > 1 ? x[2] : "">>\"\n"; |
| 47 |
|
| 48 |
"Dialog...\n"; |
| 49 |
x = inputDialog(InDlgIconNone, 'This is a sample dialog prompt!', |
| 50 |
['Hello', 'Goodbye', 'Anyway'], 1, 2); |
| 51 |
"Response = <<x>>\n"; |
| 52 |
|
| 53 |
x = inputDialog(InDlgIconQuestion, |
| 54 |
'A standard yes/no dialog!', InDlgYesNo, 1, 2); |
| 55 |
"Response = <<x>>\n"; |
| 56 |
|
| 57 |
x = inputDialog(InDlgIconInfo, |
| 58 |
'Another dialog!', [InDlgLblOk, InDlgLblNo], |
| 59 |
nil, nil); |
| 60 |
"Response = <<x>>\n"; |
| 61 |
|
| 62 |
"Done!!!\n"; |
| 63 |
} |
| 64 |
|