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
Uribo
Level II

Loop(FOR) / basic

 
Dear Masters,
 
Nice to meet you.

I tried to double loop with the script , attached csv data but it will not be the result I think.

The minimum value of the difference between the A column and B 1, the minimum value of the difference between the A column and B 2, the minimum value of the difference between the A column and B 3,........difference between column A and B10.

I wanted to output the minimum value of the difference between column A and B until B10, but only the minimum value of difference between A1 and B1, value was "-8", is output.
 
 
 
--------------------------------------------------
db = Current Data Table();
temp = Column( "A" ) << Get Values;
temp2 = Column( "B" )<< Get Values;

Row = N Row( db );
a=0;

For( i = 1,Row, i++,
a=temp[i];

g=0
For( j = 1, Row, j++,
g = temp2[j];
Col Minimum(a-g );
);
);
------------------------------------------------------

Thank you for your kind support.
 
Uribo
1 ACCEPTED SOLUTION

Accepted Solutions
txnelson
Super User

Re: Loop(FOR) / basic

You have 2 issues of syntax.

1. The For() loop requires the termination expression to be a comparison of some sort.  

2. You have specified a column called "A" and a memory variable called "a".  Because you did not show any scoping to indicate that the variable "a" is to be treated as a memory variable, JMP assumed you were referring to the column "A".  Remember, JMP is not case specific.

Here is a corrected version of your script

db = Current Data Table();
temp = Column( "A" ) << Get Values;
temp2 = Column( "B" ) << Get Values;

Row = N Row( db );
::a = 0;

For( i = 1, i <= Row, i++,
	::a = temp[i];

	g = 0;
	For( j = 1, j <= Row, j++,
		g = temp2[j];
		Col Minimum( a - g );
	);
);
Jim

View solution in original post

2 REPLIES 2
txnelson
Super User

Re: Loop(FOR) / basic

You have 2 issues of syntax.

1. The For() loop requires the termination expression to be a comparison of some sort.  

2. You have specified a column called "A" and a memory variable called "a".  Because you did not show any scoping to indicate that the variable "a" is to be treated as a memory variable, JMP assumed you were referring to the column "A".  Remember, JMP is not case specific.

Here is a corrected version of your script

db = Current Data Table();
temp = Column( "A" ) << Get Values;
temp2 = Column( "B" ) << Get Values;

Row = N Row( db );
::a = 0;

For( i = 1, i <= Row, i++,
	::a = temp[i];

	g = 0;
	For( j = 1, j <= Row, j++,
		g = temp2[j];
		Col Minimum( a - g );
	);
);
Jim
Uribo
Level II

Re: Loop(FOR) / basic

Dear txnelson, 

 

Thank you very much for your quick reply, and polite commentary .

I was saved because the JMP script was at a loss as a novice beginner.

 

Regars,

Uribo