Nil object reference (in a rather abusive vocabWord setup...)

I have built what seems a nifty, perhaps an abuse of TADS/a3Lite, mean of easily having multiple inactive buttons with only one object, but QTads throws a nil obj reference error.

The relevant code is below (with the definition changed for avoiding spoilers, and yes, was the original “color-based puzzle”, but I have found a nifter, blind-friendly, solution, based on certain names):

inactive: Button, Component ';button buttons stone stones; black, white, red, cyan, magenta, green, yellow, gray, orange, purple, pink, brown; it 
them'
desc = "The button's shape, appareance, colors and layout on the 
plate, has a striking rensemblance to [SPOILER], to the point that for convenience, you have named  these buttons after the twelwe [SPOILER]."
location = [SPOILER] // the surface where the buttons have
/* TODO: this is probably the "first contact" (literally !) with the 
magic(k)al nature of Etuye, so to be improved re. magikno */
feelDesc = "feeling around the buttons, you feel a weak but strange tingling 
sensation around the tip of the fingers."
touchDesc = "Touching the button, you strange tingling sensation on the 
fingers touching it."
makePushed() {
  "You try to push the Ruben button. Aside the strange tingling, nothing 
happens, aside that the swirling in the lens is replaced for a brief moment 
by broken lines radiating from its centre";
}
;

entering, for example, x black or x black stone, all work as designed, but if I imput x multiple buttons, e.g. x black, red, cyan, brown the nil object reference showstopper raise its ugly head.

After an entire morning fighting this, I must ask to the fellow TADS & a3Lite coders suggestion on tackling this issue.

(of course, I can easily code as twelve single button object (after all, four or five are active…) but i feel that is a wastage of resources)

TIA and
Best regards from Italy,
dott. Piergiorgio.

ps. and EDIT: yes, this also show why I feel that FEEL and TOUCH ought to be separate… :wink:

4 Likes

Not an a3lite guy (yet), so no help, but wanted to call out this:

This is EXACTLY what I do! Pepper my code with TODO so I don’t forget to clean stuff up while focusing elsewhere. It has become my easily-searchable, de facto bug tracking mechanism…

2 Likes

Why do you have nothing in front of the first semicolon? It’s possible that the parser is attempting to refer to this object by name, but can’t, because the first segment of vocab is empty. That’s my first guess, at least.

Because of this:

X black, white, red, cyan, magenta, green, yellow, gray, orange, purple, pink, brown

generic button:
The button’s shape, appareance, colors and layout on the
plate, has a striking rensemblance to [SPOILER], to the point that for convenience, you have named these buttons after the twelwe [SPOILER].
generic button:
The button’s shape, appareance, colors and layout on the
plate, has a striking rensemblance to [SPOILER], to the point that for convenience, you have named these buttons after the twelwe [SPOILER].
generic button:
The button’s shape, appareance, colors and layout on the
plate, has a striking rensemblance to [SPOILER], to the point that for convenience, you have named these buttons after the twelwe [SPOILER].

(and so on, for a total of twelve identical descs…)

This happens only if the names are separated by a comma; if the names are separated by a space, I got the expected & desired output (only ONE description); and, much more serious, the multiple output (NOT separated by newlines…) happens also when feeling, touching and pressing the button with comma-separated names… whose raise an interesting worldbuilding question: nimble and agile elves can have six fingers ? (eh… this alone can explain why Tolkien is so loved by conservative bretons… but I’m now wildly digressing)

so, either a show-stopping nil reference or a rather unpolished multiple output if the names are separated by commas
(now I have done another test: happens also with AND…)

1 Like

I suspect the parser interprets any command in the form of X, Y as a command to X to do Y (in other words, that the parser doesn’t allow commas to be used as separators for other purposes),

1 Like

Does adv3lite share the NounPhraseWithVocab bug from adv3? The one that causes a runtime error on FOO, BAR?

If it’s the same bug, then the workaround is:

modify NounPhraseWithVocab
        resolveNounsMatchName(results, resolver, matchList) {
                try {
                        return inherited(results, resolver, matchList);
                }
                catch (RuntimeError e) {
                        // Runtime error 2203 is "nil object reference."
                        if (e.errno_ == 2203) {
                                results.noVocabMatch(resolver.getAction(),
                                        getOrigText());
                                return [];
                        }
                        // It wasn't a nil object reference. Re-throw the
                        // error so that it's not lost.
                        throw e;
                }
        }
;
2 Likes

thank for the suggestion, jbg, but no, the workaround, if is the same bug, must be applied elsewhere, because NounPhraseWithVocab isn’t an Adv3Lite object/method/routine (confirmed thru grepping the entire a3Lite directory):

error: 
The "replace" and "modify" keywords cannot be used with an object that is not
previously defined.  The object must at least be defined as an "extern" object
before it can be replaced or modified.

Eric suspects that the issue lies in the parser, and for obvious reasons I have no doubts that he’s right.

Best solution, perhaps, separate inactive buttons sharing the same not-so-stock message, leaving to the powerful << >> adprose system the dealing with the differences, mitigating the code inefficiency ? Opinions ?

(In the meantime, I’m working elsewhere in the code…:wink: )

Best regards from Italy,
dott. Piergiorgio.

1 Like

Solved thru use (abuse ?) of doer, with the unexpected discovery of an interesting strange quirk of TADS compiling, reported to our little IF community in another debate I have just created…

Thanks to everyone, and

Best regards from Italy,
dott. Piergiorgio.

2 Likes