Using inputdialog()

Hi there.

I’m new to TADS and I was wondering if anyone could help me out here.

I’m familiar with other programming languages like Java and Python but I think my unfamiliarity with C-like languages is getting in my way here.

I searched quite a bit online and the example I found of using inputdialog was as follows:

[code] ret := inputdialog(INDLG_ICON_WARNING, ‘What would you like to do next?’,
[’&Restore’, ‘Re&start’, ‘&Quit’],
nil, 3);
switch(ret)
{
case 1:
/* restore a game… */
break;

case 2:
  /* restart the game */
  restart();
  break;

case 3:
  /* quit */
  quit();
  break;
}[/code]

But when I run the game, it doesn’t seem to activate this at all. I assumed it would automatically run the switch loop when a user enters the room, but I must be wrong. My code is as follows:

[code]study: Room ‘Study’
"This study is much as you would expect. A desk stands in the middle of the
room. The way out is to the east. "

 ret := inputdialog(INDLG_ICON_WARNING, 'What would you like to do next?',
                   ['&Restore', 'Re&start', '&Quit'],
                   nil, 3);
switch(ret)
{
case 1:
  /* restore a game... */
  break;

case 2:
  /* restart the game */
  restart();
  break;

case 3:
  /* quit */
  quit();
  break;
}

east = hallway

;[/code]

Anyone willing to point me in the right direction here?

Thanks a million!

It looks like you’re mixing TADS 2 and TADS 3 together. Your room is using a TADS 3 template, which can’t be used in TADS 2, but your routine (which isn’t part of a property or a function), is using a TADS 2 Pascal-style operator, which can’t be used in TADS 3.

You have to pick one system or the other. Basically, TADS 2 is the simpler system, and TADS 3 is the more elaborate system.

If you’re looking for something in the middle ground between the two, I would highly recommend Eric Eve’s adv3Lite library for TADS 3. It’s simpler to use than the full T3 library, and has a few nice features that are not part of T3 at all.

The syntax of adv3Lite is fully T3, though. No matter what library you use, reading the documentation will give you better results than searching online for code snippets. Page 159 of LearningT3Lite.pdf shows how to get input from the player in what seems to be a situation similar to what you’re trying to do.