Newsgroups: rec.arts.int-fiction
Path: gmd.de!rrz.uni-koeln.de!unidui!math.fu-berlin.de!ifmsun8.ifm.uni-hamburg.de!news.DKRZ-Hamburg.DE!dscomsa!dxcern!mcsun!uknet!bnr.co.uk!pipex!uunet!europa.eng.gtefsd.com!darwin.sura.net!udel!rochester!cornell!uw-beaver!cs.ubc.ca!newsserver.sfu.ca!sfu.ca!neilg
From: neilg@fraser.sfu.ca (Neil K. Guy)
Subject: Re: TADS & 'everything'
Message-ID: <neilg.737347115@sfu.ca>
Sender: news@sfu.ca
Organization: Simon Fraser University, Burnaby, B.C., Canada
References: <TR95005.93May13000901@black.oxford.ac.uk>
Distribution: rec.arts.int-fiction
Date: Fri, 14 May 1993 02:38:35 GMT
Lines: 80

tr95005@oxford.ac.uk (Richard Forster) writes:

>I'm trying to stop some of my verbs in TADS from allowing the use of ALL on
>direct objects [...]

 It's funny you should bring this up. I remember discussing this
problem with Dave Baggett quite a long time ago, and I was recently
talking about it with Mike Roberts. I'm trying to do exactly the same
thing, and he came up with a couple of suggestions for workarounds,
because right now TADS can't easily let you specifically disallow
multiple direct objects.

 Anyway, my code incorporates his suggestions, is definitely less than
brilliant but it sort of works sometimes, and looks like this:

 You'd put this doDefault into the verb you don't want working with
"all." Let's say the "askVerb."

  doDefault( actor, prep, io ) =  
  {
    if ( objwords( 1 ) = [ 'all' ] )
    {
      global.noMultiples := 'ask about';
      return( nil );
    }
    else
      return( takeVerb.doDefault ( actor, prep, io ) );
  }

 So I store a special message in a new global variable called
"noMultiples." This variable serves as both a flag that "all" has
been disallowed and also serves as the string for the verb in
question. Naturally you'd change this string for each verb. For some
verbs it'd be the same as the sdesc, but in this case it's different.
I'm using the new objwords() function which is documented in the
TADSVER file for the latest versions of the TADS compiler. (2.1)
Also, if the direct object isn't "all" then the verb uses the same
doDefault as the takeVerb - that is, it assumes you mean all the
objects in the actor's location that aren't tied down.

 Then we make a little change to the parseError function. If the
noMultiples flag has been set then for case errno = 15 (the only
error message we want to change this time) then we return the new
error message, which includes the custom noMultiples message. We then
clear the noMultiples variable. If the flag wasn't set then we simply
return the normal error message - albeit one that was rewritten to
avoid the terrible grammatical crime of ending a sentence with a
preposition. :)

parseError: function( errno, str )
{
  switch ( errno )
  {
    case 15:
      if ( global.noMultiples <> '' )
      {
        local noAllErr := 'You can't ' + global.noMultiples +
        ' more than one item at a time. ';
        global.noMultiples := '';
        return( noAllErr );
      }
      else
        return( 'I don't see to what you're referring. ' );
      break;
    default:
      return nil;
  }
}

 Anyway, this is a bit of a kludge but kind of works for me. It's not
entirely consistent, however. Any improvements would, of course, be
greatly appreciated.

 Incidentally, this all reminds me that I'm still interested in
putting together a kind of TADS sample code collection (on
ftp.gmd.de, thanks to our generous if-archive manager, Volker
Blasius). Anyone who's out there and interested? Please mail me if
you are!

 - Neil K. (n_k_guy@sfu.ca)
