Before printing the name of a person (called P):
if not expanding text for comparison purposes:
now last person referenced is P;
But it seems that sometimes last person referenced is getting set even when the name of P is not printed to the screen. Since I know there is nowhere else in my code where last person referenced is set, it must be the case that inform is expanding text for purposes other than comparison or printing. Or am I missing something?
expanding text for comparison purposes is true if weâre doing a text comparison, and false otherwise. Itâs not the opposite of âoutputing textâ. When Inform performs the text expansion for the substituted form of a text, it doesnât know or care whether itâs actually outputting that text.
j is initially 0.
yak is a thing.
before printing the name of yak when not expanding text for comparison purposes, increment j.
to puts (sv - a sayable value): say sv; say line break.
when play begins:
puts yak;
puts j; [ 1 ]
if "[yak]" is "z", say "gosh.";
puts j; [ still 1 ]
let x be "[yak]";
puts j; [ still 1 ]
let y be the substituted form of x;
puts j; [ now 2 ]
âyakâ only gets printed once, but j ends up at 2. Odds are good youâve got someplace youâre not thinking of where youâre expanding â[p]â where p is a person, but not outputting it.
Yeah, the Standard Rules suggest that âexpanding text for comparison purposesâ means itâs not being printed to the screen, but in fact say__comp (the flag that it checks) is only set in TEXT_TY_Compare, the routine for comparing two texts against each otherânot in TEXT_TY_Transmute, the routine that prints the text into a buffer to expand all the substitutions. Meaning if you ever manually do âthe substituted form ofâ, that doesnât set the flag.
Which is usually what you want. But you can get around this:
Include (-
[ SubstituteForComparison to txt ;
@push say__comp;
say__comp = 1;
TEXT_TY_SubstitutedForm(to, txt);
@pull say__comp;
return to;
];
-).
To decide what text is the substituted form of (T - text) for comparison purposes:
(- SubstituteForComparison({-new:text}, {-by-reference:T}) -).
This is based on the code for âsubstituted form ofâ in Basic Inform, but it also sets the say__comp flag.
Aha! I had assumed, without being motivated enough to dig through the code to confirm it, that using âexpanding text for comparison purposesâ doesnât work during the activity âfor printing the name of somethingâ (as highlighted in WI §5.7. Text with random alternatives) because when checking for a leading vowel to choose between âaâ and âanâ for the indefinite article the name was expanded to an internal buffer without invoking the text comparison machinery. Thank you for confirming that, and even more for the fix!