Choose Language Hide Translation Bar
Highlighted
TheRealYeti
Level II

How do I stop UI from looking like it hang up while doing long for loop operation

I made I UI that lets the user choose which process, temperature and voltage to include in the computation of Cpk, the script will iterate over each combination of process, temperature and voltage. I noticed that the UI hangs up while it is doing its operation. Is there a way to avoid this? I think a function similar to DoEvents in vb6 or better, a background process worker ?

1 ACCEPTED SOLUTION

Accepted Solutions
Highlighted
pmroz
Super User

Re: How do I stop UI from looking like it hang up while doing long for loop operation

If you're looping in JSL you could add calls to caption() to inform the user of progress.

for (i = 1, i <= 1000000, i++,
	a = i*2;
	b = a^i;
	if (mod(i, 1000) == 0,
		caption("Processing ... " || char(i));
		wait(0);
	);
);
caption(remove);

View solution in original post

6 REPLIES 6
Highlighted
gzmorgan0
Super User

Re: How do I stop UI from looking like it hang up while doing long for loop operation

@TheRealYeti ,

I'll attack your question from another direction, your script might be inefficient. I have seen scripts that took hours to run, rewritten to run in a minute or two. Without more details, it is difficult to assess that.

 

Given that you know vb6, you could get the user input and your script could generate a JSL script to do the work, but run it via VB6 that uses DoEvents.  I do not know that function nor am I a VB expert.

 

The JMP documentation "Automation Reference" points you to many of the JMP library functions exposed to VB.

 

To create a JMP session and make it visible, add the following code to your VB

script.

 

Dim MyJMP As JMP.Application

 

Dim JMPDoc As JMP.Document

Set MyJMP = CreateObject("JMP.Application")

MyJMP.Visible = True

 

The JMP library function, Run JSL, 

 

Run JSL file

 

Not sure if any of that helps. 

Highlighted
TheRealYeti
Level II

Re: How do I stop UI from looking like it hang up while doing long for loop operation

My code runs in under a minute. My concern is that during the process, the GUI (made in JSL) would look like it stopped responding. I think  this is because the script and the GUI both run in the same thread (I could be wrong). In VB6, adding DoEvents command inside the for loop can be a quick solution, it allows the UI to update its elements and appear responsive but the total operation would take longer.

 

I'd like the script to be integrated in JMP itself and making it an add-in so other users can just install it and reuse it. If I go down the VB6 path, I'd rather do it completely in VB6, vs generating JSL script using VB6 then execute it. Thank you for giving different approach I appreciate every feedback.

Highlighted
pmroz
Super User

Re: How do I stop UI from looking like it hang up while doing long for loop operation

If you're looping in JSL you could add calls to caption() to inform the user of progress.

for (i = 1, i <= 1000000, i++,
	a = i*2;
	b = a^i;
	if (mod(i, 1000) == 0,
		caption("Processing ... " || char(i));
		wait(0);
	);
);
caption(remove);

View solution in original post

Highlighted
TheRealYeti
Level II

Re: How do I stop UI from looking like it hang up while doing long for loop operation

It looks like wait is what I need!
I will take a look at @David's suggestion next.

Thanks!
Highlighted
David_Burnham
Super User

Re: How do I stop UI from looking like it hang up while doing long for loop operation

If you are performing a number of time consuming discrete tasks you can use this status widget:

Activity Status Class 

 

It will give the user status of progress and force screen updates.

-Dave
Highlighted
Craige_Hales
Staff (Retired)

Re: How do I stop UI from looking like it hang up while doing long for loop operation

or modify code like Progress Bar  to meet your needs. @David_Burnham 's status class looks nice too!

Craige
Article Labels