How to suppress posting to the post window

Is there any way to tell a function to not post its result in the Post window?


Hi and welcome,

there’s a commonly used way to return an empty String:

{ "bla"; "" }.value

Besides you can empty the post window with Cmd-Shft-P (on Mac at least, should work with equivalent keys on other Platforms).

The behavior for printing of the result of code you execute with e.g. shift + return is defined in Interpreter:interpretPrintCmdLine (you’ll see the last thing this function does is ("-> " ++ res).postln;). You can also override this function to provide whatever behavior you want: posting to another view, logging to a file, etc etc.

For example, here’s a quick extension to post function execution results to a Document in the IDE rather than the post window (interpretPrintCmdLine here is copy-pasted, I only changed the last line).

+Interpreter {
	interpretPrintCmdLine {
		var res, func, code = cmdLine, doc, ideClass = \ScIDE.asClass;
		preProcessor !? { cmdLine = preProcessor.value(cmdLine, this) };
		func = this.compile(cmdLine);
		if (ideClass.notNil) {
			thisProcess.nowExecutingPath = ideClass.currentPath
		} {
			if(\Document.asClass.notNil and: {(doc = Document.current).tryPerform(\dataptr).notNil}) {
				thisProcess.nowExecutingPath = doc.tryPerform(\path);
		res = func.value;
		thisProcess.nowExecutingPath = nil;
		codeDump.value(code, res, func, this);
	postResult {
		var document;
		document = Document.allDocuments.detect({ |d| d.title == "POST" }) ?? { Document("POST") };
		document.insertText("-> %\n".format(result), document.string.size);

A word of warning though! I recently modified the standard error reporting in a similar way, so I could show errors in a different view. I had a small bug in my own code, which meant in some cases I simply didn’t see errors at all, and I spent a whole afternoon being VERY confused trying to track down why. TLDR: It’s easy to shoot your self in the foot when you hack core functionality :wink: (it’s also very fun any useful, so fire away! You can always just revert it)


Thanks for the idea! I’ll use it when it makes sense, but in this case I need the function to return its result, not an empty string, and just not tell me about it.

This is great to know. I’ve never gone into the Interpreter like this. In this case I don’t want to change the rules generally, just make one particular function operate more silently - as my program runs I’m trying to creating a legible readout in the post window of what’s going on, but this one thing keeps printing itself in there and breaking up the flow. Thanks for pointing me in this direction, I’ll explore.

Note that there is no automatic posting of the results of any/all functions. The interpreter does post the result of a code block submitted by ctrl-return, but this is not the same as a function being called “as a program runs.”

If the disturbing post is the result of a ctrl-return block, then you can attach the empty string to the end of the code block (without embedding it in the function).

If the post is mid-block, then it must be an explicit post, which you could remove from the code.

It’s not clear to me what is your sequence of steps – so, it’s not clear what to recommend.


If you’re trying to nicely display a subset of post messages (e.g. things about the patch that you’re loading, etc), you might also consider the Log quark. This will dump to the post window (if you choose), but also can generate a separate window with only messages from a specific log:

LogWindow(\test, \other).front;
Log(\test).info("This is a test message: %", 1234);
Log(\other).info("This is an other test message: %", 1234);

// shows:
// [TEST]      This is a test message: 1234
// [OTHER]     This is an other test message: 1234

I did not know about this! Thank you, that looks very useful.

This was just the clue I needed, thank you. It was an explicit post, hiding in the underbrush. Big thanks.