How to identify columns as variables

I want to write a rule/action/phrase into which I can plug a table. Normally, the table is processed specifically by entry name of column and row and specific constants (or objects or numbers) in that table. However, I want to pass in a table and process it by row and column position. I won’t know the row/column name but only which row & column it is in. Since this is for formatting, it is not important what the actual data in the table is.

I suspect that showme constants of table name. does what I want but I don’t know how to access that code.

I can count the number of columns in a table by some borrowed code using “I6 hackery”:

 To decide which number is the column count of (T - table name): (- ({T}-->0) -). 

Is there some way to access a particular column by its position; or alternatively, find its name for accessing? If it takes hackery to find the number of columns, I expect this is a challenging problem.

See this thread, which is basically the same question:

What’s the actual effect that you’re trying to achieve?

I have a lot of tables in my program so want neat tidy columns without repeating the same code for every table.I am trying to build a rule for formatting a table where the table name is input, thus I do not have specifics about column names. I can search for tabs and do a lot of extra work but I thought there might be something already available.

I have seen lots of chatter on the forum about this so I thought I would make it available as a public extension after it is working.

zarf: I think there may be a fertile nugget in that solution for my purposes:

choose a random row in the foo table;
if a random number from 1 to 5 is:
  -- 1: decide on the col1 entry;
  -- 2: decide on the col2 entry;
  -- 3: decide on the col3 entry;
  -- 4: decide on the col4 entry;
  -- 5: decide on the col5 entry;

I think I can decide on a col[N] entry by counting tabs. For my purposes, all output from the rule/phrase will be in text, so my table output will be in text. I need to convert numbers to text to count characters for spacing. What do you think?

I have a rule that allows me to print a line of a table that contains both text, numbers, and real numbers, and numbers, but I cannot pass this text to a variable.
Does anyone know why, and what to do about it?

To columnize (tbl - table name) to width (colwid - a number):
	let line be "";
	let linelen be 0;
	repeat through tbl:
		now line is current table row;
		say "[line][line break]";
[		say "[current table row][line break]";]
[		now line is printed name of item entry;]
		now linelen is number of characters in line;
		say "[line] has [linelen] characters[line break]";
	say variable letter spacing;
To say columnize (tbl - table name) to width (colwid - a number):

Now you can put that in a text as "[columnize Table 5 to width 24]" or whatever.

I don’t understand. The phrase is brackets doesn’t compile. I can get columnize rule to work for a specific table, but not a generic table where I don’t know the column name. Is there some way to find the column name? Or use column [some number]?

I’m sorry I am not asking a clear question.
I have this source code that compiles.

When play begins:
	columnize Table of BodyProtection to width 3;

To columnize (tbl - table name) to width (colwid - a number):
	say fixed letter spacing;
	let line be "";
	let linelen be 0;
	repeat through tbl:
		say "[current table row][line break]";
		now line is printed name of item entry;
[		now linelen is number of characters in line; ]
[		say "[line] has [linelen] characters[line break]"; ]
	say variable letter spacing;

It has this output:


Since I can SAY (print out) the row that is in the table, which means that the numbers are being converted to text, is there a way I can save the row of text to a variable for further analysis?

btw, the lines in comments also work to give me the first entry and the number of characters in it. However, I need to know the name of the column specifically for it to work; in this case, itis ‘item entry’. I cannot get to column 2 in general.