Removing multiple rows from a table

Continuing my training on tables, I have a new quandary.

The short version: Targeting a table, is there a way to identify ALL rows sharing a certain value, and then blank out only those rows?

The long version:

I have a few playable characters who come and go. Each character has a few special skills. I have a table listing the verbs available to the player and update that table depending on who they are at that moment.

The table:

Table of Game Verbs
Action	Character
"Examine"	0
"Look"	0
"Take"	0
"Ask about"	0
"Drink"	0
"Use"	0
"Fill"	0
"Give"	0
with ten blank rows

Basic verbs are given a “character” of zero. Each character has their own “character” value. When one of those characters are selected, their rows of character-specific verbs are added.

Let’s say we’ve selected one of the characters and then table then looks like this:

Table of Game Verbs
Action	Character
"Examine"	0
"Look"	0
"Take"	0
"Ask about"	0
"Drink"	0
"Use"	0
"Fill"	0
"Give"	0
"Repair" 1
"Shoot" 1

We then want to choose a different character, necessitating the removal of those two rows. Is there a way to identify ALL rows sharing a certain value, and then blank out those rows?

Since the basic verb list is fixed, I can see a mightily inefficient way of doing some thing like this:

repeat through the Table of Game Verbs:
		choose row 9 in Table of Game Verbs; 
		blank out the whole row; 
                choose row 10 in Table of Game Verbs;
                blank out the whole row.

Etc.

I guess there’s nothing entirely wrong with that but I’m hoping I’m just in need of a syntax lesson and it turns out to be something like the below (but wouldn’t also cause a run-time error):

repeat through the Table of Game Verbs:
     choose a row with a character value >0 in Table of Game Verbs;
     blank out the whole row.

Thank you.

You ought to be able to just check the value from within the repeat loop:

repeat through the Table of Game Verbs:
     if the character value entry is 0:
          blank out the whole row.

One thing about this is that repeating through a table and choosing a row are essentially doing the same thing. When you repeat through the table, you’re choosing row 1, then row 2, then row 3… so you don’t need to choose a row within the repeat loop. You can just refer directly to the entry for the column you want in the row of your loop.

(This also means that in the code where you directly choose rows 9 and 10, you don’t need the repeat loop at all.)

Also I haven’t checked this! I’m not sure whether blanking out a row in the middle of the repeat loop will have funny effects, or if I’ve messed the syntax or something.

1 Like

Thank you! For some reason I thought I couldn’t put an “if” in there. Slight tweak for working code:

repeat through the Table of Game Verbs:
		if the character entry is 0:
			blank out the whole row;