This may or may not suit your purposes, depending on what you’re trying to do:
Conditional saying is a truth state that varies. Conditional saying is false.
To consay (M - a text):
if conditional saying is true:
[say paragraph break;]
Instead of examining the player:
now conditional saying is true;
consay "Not bad!";
now conditional saying is false;
consay "(If you don't look too closely.)";
This isn’t exactly what you want, because it doesn’t really affect the behavior of “say” per se(!), but if you find/replace “say” with “consay” throughout your source you get the same effect. Except line breaks might be weird. (That “say paragraph break” line is probably desirable, but it depends on your specific needs.)
On the other hand, this method does let you switch between “say” phrases and “consay” phrases so that some text always prints while other text is conditional and that might be useful!
On the Z-machine, you can turn off the output stream that goes to the screen, which will cause all printing to just be lost to the void until you turn it back on. (Or be sent to the transcript but not anywhere else, when the transcript is turned on; that’s a separate output stream that can also be turned off, if you want.)
On Glulx it’s a bit more complicated, because in Glk it’s illegal to print anything when there’s no current output stream. I think the best way to do this is to make a dummy stream that throws away everything sent to it, and redirect to that:
To avoid messing up the paragraphs, you can use this instead:
To consay (M - a text) -- running on:
if conditional saying is true:
Another option is to Include Text Capture by Eric Eve. and then you can start capturing text to redirect the “say” output to an internal buffer rather than immediately printing it, which would have the effect of silencing it if you discard the buffer without using it. (This is the I7 equivalent of Draconis’ @output_stream suggestion.) The capture buffer is fairly small by default (although can be enlarged) – although on Glulx overflowing the buffer is relatively harmless; it just throws away the extra characters, which is what you want anyway.
Include Text Capture by Eric Eve.
start capturing text;
say "This won't get printed.";
stop capturing text;
This is not as good as avoiding actually saying it in the first place (e.g. with consay, or otherwise skipping the rule that says the text), however.
Alternatively, if the text in question is associated with reporting the results of an action, then you can put it into a Report rule – if the action is tried “silently” then the Report rules are not executed.
Is it available within the I7 templates? (My saying that it’s not available is mostly because of looking at Glulx.i6t, where wrapper routines like glk_stream_open_memory are explicitly provided, but glk_stream_close is just implemented wherever it’s needed by pushing arguments and calling the @glk opcode directly (so no wrapper used). Which makes me think not all of infglk.h is included.)
(Slightly less disjointed response than the previous one. Sorry about that.)
The Text Capture extension and Glulx_PrintAnyToArray both make manual Glk calls because they want to retrieve the length of captured text from the return values – which should also be possible with the wrapper but is less convenient, since you’d have to get the results via an array rather than the stack.
It appears that Output Silencing requests the same thing (by passing $ffffffff rather than 0) but it’s not actually pulling the results off the stack afterwards, leaving it unbalanced. I’m not sure if that does anything dire in I6, but it’s probably not the best idea. (I also prefer using @push/@pull over using @copy as the latter is both longer and less portable, but that’s a stylistic choice.)
On a related note, it appears that the Glk and Glulx specs disagree on whether it is legal to print to a null stream or not. The Glulx spec says that’s it’s ok to print to a null stream (and would simply drop the output, as is the goal here) but not legal for a not-yet-set stream, while the Glk spec says that neither are legal since they mean the same thing. I assume the Glk spec is more correct in this regard though.