Run-time problem P21: Attempt to look up a non-existent correspondence in the table and Quixe run: Error: Function returned undefined value

I’m still trying to work on a dialogue system and am having a lot of problems with errors involving the tables I’m using. I don’t really have any idea what’s going wrong since technically the code is still working. I’m sorry this code is a bit long but after trying to shorten it, to take out some of the not as relevant parts of the code it just made things worse.

Lab is a room. Gwen is a woman. Gwen is here.

Y is a text that varies.
The index is a number that varies.
A person has a table name called Z.
X is a table name that varies.
V is a person that varies.

Table of Gwen's Dialogue Master
Conversation	Speech	Choice Table	Selected
"Test"	"I am testing!"		Table of Gwen's Dialogue Test	False
"Weather"	"It sure is weather outside!"	Table of Gwen's Dialogue Weather	False

Table of Gwen's Dialogue Test
Choice		Response	next topic	Selected 	Label
"Why are you testing?"	"[carry out]"	--	False	number
"What are you testing?"	"Testing is what I'm testing."	"Weather"	False	--

Table of Gwen's Dialogue Weather
Choice		Response	Selected 	next topic	Label
"Yep it sure is weather"	"weather"	false	a text	number
"What"	"Huh"	false	--	--

The Z of Gwen is Table of Gwen's Dialogue Master.

To say carry out:
	say "You did it".

To say next topic (R - a text):
	say R.

Instead of jumping:
	try Gwen starting conversation about "Test".

Understand "[a number]" as choosing.

Choosing is an action applying to one number.

Instead of doing something other than choosing when the command prompt is "You respond>":
	do nothing.

Check choosing a number less than 1:
	say "Natural numbers only";
	stop the action.

Check choosing a number greater than index:
	say "Please choose from the choices available.";
	stop the action.

Starting conversation about is an action applying to one topic.

Understand "Start conversation about [text]" as starting conversation about.

[Check an actor starting conversation about a topic:
	if the topic understood is not a conversation listed in the Z of the actor:
		say the topic understood;
		stop the action.]

Carry out an actor starting conversation about a topic:
	now V is the actor;
	now Y is the topic understood;
	choose row with conversation of Y in the Z of V;
	say "[V] says, [Speech entry]";
	say paragraph break;
	now X is Choice Table entry;
	repeat with i running from 1 to the number of rows in the X:
		choose row i in X;
		say "[bracket][i][close bracket]. [Choice entry]";
		say line break;
		increase index by 1.

After jumping, which starts the start conversation action I keep getting this run time problem printed saying that it could not find the corresponding entry in the table, however it still manages to print the write text from both tables. As well the check rule that I have commented out, which is only checking to see if the topic of the action is in the table, leads to a Quixe error which then halts anything else from happening.

This has left me pretty confused and I don’t even know where to start with addressing this, so any help into illuminating why this is happening and how to fix it would be greatly appreciated.

Glulx automatically converts all player input to lower case before processing the player’s command.

You can either remove the initial capital from "test" and "weather" in your conversation column, or you can use

now Y is the topic understood in sentence case;

to make the first letter of the player-entered text be a capital again.

(If you’re not using Glulx, it must be something else.)

1 Like

The Z-Machine does that automatically, but on Glulx this behavior is replicated in Inform code for simplicity’s sake.

You’re right – I had the difference between VMs backwards. Thanks!

Thank you this fixed the Run-time problem P21, however the commented out code (checking an actor starting conversation, specifically the line if the topic understood is a conversation listed in the Z of the actor:) is still leading to the Quixe run error.

Try "[the topic understood]" instead. the topic understood is a snippet variable, not text, so you can’t compare it directly to the conversation column. (I would have expected this to cause a compilation error, actually.)

1 Like

Thank you, this fixed it.

1 Like

Quixe errors like that should not be happening. Which version of Quixe is it? Does the error also occur in Parchment or Lectrote, or in a non-Quixe interpreter like Gargoyle?

The original sample code (with the bad rule commented in) produces a “Glulxe fatal error: memory access out of range” in the IDE.

This will be an error in any interpreter, although the message will vary.

That makes sense. “Function returned undefined value” is weirder.

To be honest I don’t even know what Quixe is, but I use Borogove as an IDE, I’m not sure if that has anything to do with it.

Borogove should be pretty close to up to date, so it’s probably not a Quixe bug that would be fixed by updating Quixe…

It’s not a bug. Quixe just doesn’t have explicit checks for reading outside memory. Explicit checks would slow down execution, and overrunning an array isn’t a security hole in a Javascript app the way it would be in C. So it just proceeds with a JS undefined value, and then asserts the next time it tries to use the value.