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.
  • Graph Builder Toolbar streamlines interactive graphing. Creates shortcuts on Report and GraphBuilder Helpers toolbars. Download and install the extension.
  • JMP will suspend normal business operations for our Rest and Recharge Day on Friday, October 2, 2026.
    Regular business hours will resume on Monday, October 5, 2026.

Discussions

Solve problems, and share tips and tricks with other JMP users.
Choose Language Hide Translation Bar

Are nested loops possible using JSL?

Is there a way to script a nested loop statement using JSL? I'm running into errors when I try. I am writing a script that transforms a dataset using indirect lognormal correction for change of support and I think I need a nested WHILE statement to make it work.

Although I realize the syntax is not entirely correct, the following illustration conveys what I am trying to do:

i=1;
j=1;
n=NRow() // with more than 209,000 rows

While( i < n-1,
While( j < n,
s = s + ( data(i) * data(j),
j = j++),
i = i++);

There is always more than one way to accomplish things, so if JSL does not support nested loops does anyone have any suggestions?
2 REPLIES 2
mpb
mpb
Level VII

Re: Are nested loops possible using JSL?

Sure you can nest loops. Here's a very simple example using nested "for" loops. Look in the log for the results.

Re: Are nested loops possible using JSL?

mpb,

You are absolutely correct. Your script works just as it should. The problem with my script turned out to be a bit of code preceding the loop where I tried reusing a variable and it wasn't overwriting the original value the way I thought it would.

Thanks for your help!

Recommended Articles