Varying printed names by a property in a column

I have a table of “terms,” with a column named “size”. Each term’s size is S, M, or L. I want each term’s name to print in a different User Style, depending on its size and other factors.

I have this working well, but I’m trying to find another way to do it, using less code.

This is a simplified version of a new approach I’m trying:

The printed name of a term is [1TERM].
To say 1TERM:
Say “[if the size is S][size] ABC[end if][if the size is M] [size] DEF[end if]”.

This results in “S ABC S DEF” if the term’s size is S, or “M ABC M DEF” if the term’s size is M.

That doesn’t make sense to me. The program seems to be saying that both “if” statements are true, as if it’s finding both sizes in the table, by looking in multiple rows - but at the same time, when we ask it to report the [size], it consistently gives the correct size for the term in question, as if it knows which row to look in.

In this example, how can I get 1TERM to say either “ABC” or “DEF”, not both?

The problem is that the compiler isn’t connecting “the size” to the original object. Try this:

To say 1term:
	say "[if the size of the item described is S][size] ABC[end if][if the size of the item described is M] [size] DEF[end if]s"

Although this will be clearer if you don’t try to write it all on one line:

To say 1term:
	let sval be the size of the item described;
	if sval is S:
		say sval;
		say "ABC";
	if sval is M:
		say sval;
		say "DEF";
1 Like