cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
Submit your abstract to the call for content for Discovery Summit Americas by April 23. Selected abstracts will be presented at Discovery Summit, Oct. 21- 24.
Discovery is online this week, April 16 and 18. Join us for these exciting interactive sessions.
Choose Language Hide Translation Bar
AD1
AD1
Level III

How to update display boxes in jmp?

Hi,

I have a display box (Text Box) which I would like to update in a for loop.

I see that I am not able to reliably update the Text Box in the loop.

This is really annoying because I have a lot of files to process and it is not possible to

always physically check the drives to see if files are being processed.

I am using Wait(0) so as to allow jmp to catch up. I have tried busy light 

as well which has the same problem. Everything updates in the end.

I have tried Wait(1) as well which works but again not so reliably.

How can I create a simple text box status update?

 

Thanks for your inputs!

6 REPLIES 6
ian_jmp
Staff

Re: How to update display boxes in jmp?

Probably more details are needed to understand the comment "not able to reliably update". The code below shows the idea, but I suspect you already know this. Note that 'Wait()' is generally to be avoided in JSL, and here it's just simulating the duration of some other processing.

NamesDefaultToHere(1);

nw = NewWindow("Update Text Box", tb = TextBox(Char(Today())), << sizeWindow(400, 200));

for(t=1, t<=10, t++,
	/// Simulate some activity that takes time
	delay = RandomInteger(1, 5);
	Wait(delay);
	// Update the Text Box
	tb << setText(Char(Today()));
	Beep();
	);
AD1
AD1
Level III

Re: How to update display boxes in jmp?

Thank you for your comment. Indeed, I know this. The code that you gave me just generates a window with a number.

I guess, it is printing the last number since everything goes very fast.

I am doing something like what you showed: A loop with a bunch of table manipulations inside it and an text update at 

then end of loop. When I say reliable, I mean if I put an update at the end of the for loop it should change the text

at that moment.  Often, only the last update is visible.

 

What I actually found to be working now is something that I got from another post (don't know which one since I was looking at quite some of them).

So basically, one can create and delete a text box in a loop. Somehow updating the text doesn't refresh the text box, which is weird.

Anyway, at the moment deleting and recreating the text box in the exact place with a new text works for me.

 

Thanks for your inputs!

pmroz
Super User

Re: How to update display boxes in jmp?

If you are showing processing status to the user, you might want to try the caption function instead of a text box.  

for (i = 1, i <= 1000000, i++,
	if (mod(i, 1000) == 0,
		caption("Processing " || char(i) || " records");
		wait(0);
	);
	k = i^3;
	l = k * 4 + i^4;
);
caption(remove);
wait(0);
AD1
AD1
Level III

Re: How to update display boxes in jmp?

Thanks. The snippet you provided works of course but I am looking for something that I can

integrate in my ui. I don't want to show a pop up message. There are many elements in my UI

that require this status feature and therefore I want something that I can add to my New Window()

as a display box and use as a status bar.

I am looking for something like this:

cap = "";
some_test_function = Function({},
	Show("What?");
	for (i = 1, i <= 1000000, i++,
		if (mod(i, 1000) == 0,
			//Something like this!!! Not working of course.
			cap << Set Text("Processing " || char(i) || " records");
			wait(0);
		);
		k = i^3;
		l = k * 4 + i^4;
	);
);


nw = New Window("test",
	bb = Button Box("test caption", some_test_function),
	cap = caption("processing"),
);

I tried to use the busy light as well but that has the same problem. Moreover, I don't know if the above piece, if corrected, will work when there are lots of table operations inside the for loop instead of a simple counting. I might have to use wait, maybe. So that's why I am stuck with the text box option.

I would highly appreciate any other solution that can be used in a UI scenario with multiple elements having access to the same status display box.

 

Thanks!

 

pmroz
Super User

Re: How to update display boxes in jmp?

I did a search for "progress bar" in this forum and found two useful links:

 

Check out code from @msharp here: How to show progress bar instead of internediate tables opening and closing 

 

Similar code from @SDF1 here: Suggestion on how to script a small update/progress window for modeling 

 

AD1
AD1
Level III

Re: How to update display boxes in jmp?

Yes, I have seen them. The progress bar is a neat one. It also however pops up in a new window and doesn't work well if you try to fix everything in a single window. Promising though. I will try to see if I can get it to work in my UI somehow. The other one is simply a text box method which, as mentioned, doesn't work in my case, at least.  I guess the problem really is with not enough time for display updates in case the for loop has too many things (some post mentioned about something to do with windows not being able to update the display boxes in time). The text box method works if I put a longer wait. A waiting time of 0 doesn't work all the time (meaning that often everything is updated after for loop finishes). 

 

I will try to create a general progress tracker that can be reliably updated. If I succeed, I will post again.

 

Thanks for your help and patience!