cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
Check out the JMP® Marketplace featured Capability Explorer add-in
Choose Language Hide Translation Bar
StarfruitBob
Level VI

For Each() syntax

Hello,

 

I'm looking to expand the number of values that can be used in the For Each() function.  In the scripting index and handful of examples I've found within JMP community and JMP itself, combined, I've only seen a single value and index used: For each( { val1, index}, ... ). I'd like to use: For each( { val1, val2, ..., valn, index}, ...) . When I increase the number of values in the curly braces, a "too many arguments" error pops up.

 

Strangely, this error message states that the row number of the error corresponds to the total number of rows in the matrix that is passed into the For each() function, not the actual row number of that function in the script. I can confirm it's the number of values I'm attempting to use, and not the number of rows in the matrix I'm passing into the function, by changing the number of values to val1 & index only, which then works.

 

The matrix that is passed in has an equal number of columns as the number of values I want to pass into the For Each() function.

 

Any tips? Is this possible?

Learning every day!
11 REPLIES 11

Re: For Each() syntax

I think the piece you're missing in the examples is that the values you want to pull have to be in the form of a single value or a list.  So For each( { val1, val2, ..., valn, index}, ...) wouldn't work because there's too much stuff in the argument list.  But For each( { {val1, val2, ..., valn}, index}, ...) might work better.  That's also in line with the example that @jthi provided earlier.  

 

M

StarfruitBob
Level VI

Re: For Each() syntax

Hello,

 

I've already investigated the double curly braces, but I'm running across the "too many argument" error as in my original post.  I believe this because I haven't specified the correct number of containers in Across(). I do not know how to properly fill out Across().

 

At this time, my For() loop alternative is fleshing out very nicely and should replace the need for the For Each() function. However, I'd still like to learn how to use it properly, but perhaps I'll resurrect this thread at a different time. My focus is needed elsewhere for a while.

 

Thank you all for the discussion!

Learning every day!