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
Resheffink1
Level I

If statement not working in jsl

Hi all.

 

Can you please check what is the problem with my if statement? I want to run several jsl commands in case the condition is true (in my case, that the spec file name is as written in the code) but it does not work.

Everything else is working fine, just the if statement is not.

 

My JMP version is 18

 

 

dt = Current Data Table();
dt << Select Columns( :PARAMETER );
dt << Text To Columns( delimiter( "_" ) );
dt << delete columns( :PARAMETER 1 );
If( :SPECFILE == "MS-SMLD",
	:PARAMETER 2 << set name( "Column_name1" );
	:PARAMETER 3 << set name( "Column_name2" );
	:PARAMETER 4 << set name( "Column_name3" );
	:PARAMETER 5 << set name( "Column_name4" );
	:PARAMETER 6 << set name( "Column_name5" ) ;
	,
	If( :SPECFILE == "SMLA", Formula(
		dt << delete columns( :PARAMETER 5 );
		:PARAMETER 2 << set name( "Column_name1" );
		:PARAMETER 3 << set name( "Column_name2" );
		:PARAMETER 4 << set name( "Column_name3" );
		 )
	)
);

Thanks,

Reshef

4 REPLIES 4
jthi
Super User

Re: If statement not working in jsl

Might be enough if you changed :SPECFILE to SPECFILE (:SPECFILE would (usually) refer to a column).

-Jarmo
Resheffink1
Level I

Re: If statement not working in jsl

Hi.

 

Thanks! but the "SPECFILE" is indeed a column in my jmp table.

Anyway, I tried it and it does not work.

 

Maybe its what separate the jsl commands in my IF statement?

Or, maybe its impossible to run several jsl commands in one IF statement?

 

 

Thanks,

Reshef

jthi
Super User

Re: If statement not working in jsl

Then you have to define the Row (Row() = 1; for example) or loop over the rows in your table using For Each Row. The "default" row in JMP is 0 which isn't valid row

-Jarmo
txnelson
Super User

Re: If statement not working in jsl

If what you are trying to do, is to look at row 1's value in column "SPECFILE" and then make decisions based on it, the JSL below will be what you want

Names Default To Here( 1 );
dt = Current Data Table();
dt << Select Columns( :PARAMETER );
dt << Text To Columns( delimiter( "_" ) );
dt << delete columns( :PARAMETER 1 );
If(
	:SPECFILE[1] == "MS-SMLD",
		:PARAMETER 2 << set name( "Column_name1" );
		:PARAMETER 3 << set name( "Column_name2" );
		:PARAMETER 4 << set name( "Column_name3" );
		:PARAMETER 5 << set name( "Column_name4" );
		:PARAMETER 6 << set name( "Column_name5" );,
	:SPECFILE[1] == "SMLA",
		dt << delete columns( :PARAMETER 5 );
		:PARAMETER 2 << set name( "Column_name1" );
		:PARAMETER 3 << set name( "Column_name2" );
		:PARAMETER 4 << set name( "Column_name3" );
);
Jim