Overwriting a table row

I want to overwrite a row in one of my tables. I think I’ve followed the instructions properly, and even copied the code in the example (section 16.4), but still I get parser errors. Can someone help?
I am trying to overwrite the number of Items in the table with this:

	now money of player is money of player + price;
	now weight of cash is cashWeight;
	say "You now have [cash] ([cashWeight] lb)";
	increment qty of noun;
	now noun is nowhere;
	now the Nbr corresponding to an Item of noun in the Table of Arms is qty;

for this table.

Table of Arms
Item	Nbr 	Cost		Weight	Damage
arrow	36	0.2		0.1	"d6"
axe battle	3	5		9	"d6"
sword short		15	8		10		"d6"

The error occurs on the last line of code: “now the Nbr corresponding…”.

Addendum to the above post: If I try to examine the table, it doesn’t exist.

showme contents of table of arms
There seems to be no such object anywhere in the model world.

I get this for all my tables, but everything plays ok.
–puzzled.

What error is the compiler showing you? In the absence of anything else, I think that in this line of code, the problem may be with “qty” which, as I understand it, is a variable value of something else. Perhaps we should instead write:

now the Nbr corresponding to an Item of noun in the Table of Arms is qty of noun;

Same here. And here.

Try this:

Section 1 - Not for Release

When play begins:
	showme the contents of the table of arms;

I think this command also works in non-NFR sections, if you want to control the evolution of the contents of tables in a code under construction.

I hope this snippet is closer to what you’re looking for. One method you can use is to choose the row you want to update first, and then using now ... is ... on the entry.

Borogrove snippet: Borogove

Here, I’ll grab the current Nbr for the arrow row, add 5 to it, then update the value back.

Laboratory is a room.

arrow, axe battle, and sword short are things.

Table of Arms
Item	Nbr	Cost	Weight	Damage
arrow	36	0.2	0.1	"d6"
axe battle	3	5	9	"d6"
sword short	15	8	10	"d6"

When play begins:
	say "The table before:[line break]";
	showme the contents of Table of Arms;
	say "[line break]";
	choose row with an Item of arrow in Table of Arms;
	let currentNbr be the Nbr entry;
	now the Nbr entry is currentNbr + 5;
	say "The table after:[line break]";
	showme the contents of Table of Arms.

Output:

The table before:
Table of Arms
(row 1)  | arrow | 36 | 0.2 | 0.1 | d6 |
(row 2)  | axe battle | 3 | 5.0 | 9.0 | d6 |
(row 3)  | sword short | 15 | 8.0 | 10.0 | d6 |
 
The table after:
Table of Arms
(row 1)  | arrow | 41 | 0.2 | 0.1 | d6 |
(row 2)  | axe battle | 3 | 5.0 | 9.0 | d6 |
(row 3)  | sword short | 15 | 8.0 | 10.0 | d6 |

I’m being purposely long-winded in this example, and directly choosing the arrow row, but the idea is that you should be able to choose the row you need, pull out the chosen row’s desired value with the ___ entry, and then you can use now the ___ entry is .... to update the new value back into the table.

OP, is this the error?

Choosing the row as Josh suggests should do it.

Thank you. This is a great tip towards debugging.

1 Like

Thanks much. Despite you answer being so-called long-winded, it was exactly what I needed.

Thanks. I was missing the qty of Item entry (in your case, qty of noun).

1 Like

I found something surprising. Although I can say

showme the contents of table of body protection;

inside source code, it does not work as a command line action. Also, the word ‘the’ must precede ‘contents of’ or it doesn’t parse.

I set up a test file that only displays the table. Apparently, tables are not objects and only table names are text objects. Confirmed by the INDEX also.

Yes, exactly, same for me. This thread speaks about that, from what I understand.

Thanks, Stephane. It is useful to see it validated in another thread.

1 Like