A real 'showstopper' - customising the use of show()

I do like the new (9.5) function show() to display status messages in my files. It’s a great way to display status messages.
Show() has a delay of five seconds before the next show event will show up.
In my code it could happen that I release many show() events one after the other. They will go on a stack in TBX and get shown one after another. This may result in a long list of show events and the front window’s message placard will go up and down very often.

So here is a little function (three functions to be precise) to collect those show events and always show the maximum of three lines in one event together. Reduces the number of events a little bit. Nothing spectacular :wink:

// manage the show events

// run once in a new file
function initShowStopper() {
	createAttribute("LastShowEvent", "number");
	createAttribute("ShowEventOn", "boolean");
	DisplayedAttributes("/gShowStopper") = "LastShowEvent;ShowEventOn;";
	$Rule("/gShowStopper") = "checkShowEvent();";
	$ShowEventOn("/gShowStopper") = true;
	$Text("/gShowStopper") = "Installation ShowStopper finished";

// check for open show events
function checkShowEvent() {
	if($ShowEventOn("/gShowStopper")) {
		var:number currentTime = date("now").format("U").toNumber;
		var:list currentText;
		var:string showText = "";
		var:string restText = "";

		// wait for at least 6 seconds to start a new show event
		if($LastShowEvent("/gShowStopper") < currentTime - 6) {
			if($Text("/gShowStopper") != "") {
				// there is something to be shown
				// lets get a max of 3 lines
				var currentLineNum = 0;
				currentText = $Text("/gShowStopper").split("\n+");
				currentText.each(lineOfText) {
					if(currentLineNum <= 2) {
						showText += lineOfText + "\n";
					} else {
						restText += lineOfText + "\n";
					currentLineNum += 1;
				$Text("/gShowStopper") = restText;
				$LastShowEvent("/gShowStopper") = date("now").format("U").toNumber;
				$ShowEventOn("/gShowStopper") = true;
			} else {
				$ShowEventOn("/gShowStopper") = false;

// add new show event
function addNewShowEvent_db(newMessage:string) {
	var:number currentTime = date("now").format("U").toNumber;
	$ShowEventOn("/gShowStopper") = true;
	$Text("/gShowStopper") += newMessage;

Very easy to use. Copy the code into a note in your library.
Put initShowStopper(); in a stamp and run it once. It will create all needed parts for the function.
Now you can use addNewShowEvent_db(“a message”) instead of show(“a message”).

That’s all. Have fun!


@webline nice. May I suggest to modify the title of this post: "At real showstopper: optimizing the use of show() to reduce conflict…

Also, the first line of your post is coming across as very critical to untrained users. You could soften this by saying.

“I do like the new (9.5) function show() to display status messages in my files, so I wrote some action code to make it more to my liking.”

Thanks for the great post.