cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
  • Don’t miss your chance to experience Discovery Summit Europe at our best available rate! Early bird registration through 31 Oct.
  • Image to Table JMP extension imports single or batch images as data tables. Useful to extract curves from pictures or convert image data to curve data to use in analyses like Functional Data Explorer. Download and install the extension.

Uncharted

Choose Language Hide Translation Bar
Craige_Hales
Super User
Progress Bar

Re: Does JSL provide a "busy" indicator similar to a spinning wheel or bar?

 

here's an example of a progress indicator made in JSL; it uses a namespace to encapsulate the code.  The last few lines are a test, try setting workload ​bigger or smaller.  For smooth performance the progress:set function must be called fairly often. The progress:init function needs to know the total amount of work that will be done to get the percentage right.

 

Edit: attached a copy of the JSL, apparently the inline JSL may not display correctly.

11084_progress.PNG

progress = New Namespace(
	"progress"
);
progress:init = Function( {workload},
	progress:TotalWork = workload;
	progress:Current = -1;
	progress:tick = Tick Seconds();
	progress:Window = New Window( "progress",
		H List Box(
			Spacer Box( size( 20, 20 ) ),
			progress:busy = Busy Light( <<size( 60, 60 ) ),
			Border Box( Left( 20 ), Right( 20 ), top( 20 ), bottom( 20 ),
				H List Box(
					progress:left = Spacer Box( color( RGB Color( 20, 200, 20 ) ) ),
					progress:right = Spacer Box( color( RGB Color( 100, 100, 100 ) ) ),
					Spacer Box( size( 20, 10 ) ),
					progress:text = Text Box( "0" )
				)
			)
		)
	);
	progress:set( 0 );
);
progress:set = Function( {workdone},
	{now = Tick Seconds(), pct = Round( 100 * workdone / progress:TotalWork )},
	If( now - progress:tick > 1 / 30,
		progress:tick = now;
		If( pct != progress:Current,
			progress:Current = pct;
			progress:left << size( progress:Current, 20 );
			progress:right << size( 100 - progress:Current, 20 );
			progress:text << settext( Char( pct ) || "%" );
		);
		progress:busy << advance;
		Wait( 0 );
	)
);
progress:term = Function( {},
	progress:Window << closeWindow
);
/////////////////////////
// test
/////////////////////////
workload = 1e6; // 1e6 is about 5 seconds
progress:init( workload );
For( i = 1, i <= workload, i++,
	progress:set( i )
);
progress:term();

 

Last Modified: Oct 25, 2018 9:48 PM
Comments
frank_wang
Level IV

Hi Craige

Thanks for your sharing about progress bar. 

I 'd like to monitor how many files has been processed with progress bar. 

So that, my "Workload" is not about 'time' but 'Count'. (N files in folder)

Is that mean I should delete "progress:tick" and the sentence

If( now - progress:tick > 1 / 30,
		progress:tick = now;

Could you give me some advises.

Thanks.

 

 

Craige_Hales
Super User

Good question.

 

The test you are asking about is designed to prevent updating the display more than 30 times per second, which would be a waste of time. In fact without that test, the example would update the display a million times and take a very long time to run.

 

The example assumes there are 1e6 files. You should write a loop similar to the last 6 lines of code, doing your file processing just before progress:set(i). And change the 1e6 to your number of files.