cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
Try the Materials Informatics Toolkit, which is designed to easily handle SMILES data. This and other helpful add-ins are available in the JMP® Marketplace
Choose Language Hide Translation Bar
Steffen_Bugge
Level IV

JSL for importing spec limits

I am writing a JSL code to import specification limits from a separate data table into the main data table. 

 

// Open the Spec Limits table
specTable = Open("C:\Trending Tool Spec Limits.jmp");

// Open data table for analysis
dataTable = Data Table( "Trending data" );

// Extract Spec Limits and Show Limits from Spec Table
For Each Row(
    specName = specTable:Variable[];
    LSL = specTable:LSL[];
    USL = specTable:USL[];
    showLimits = specTable:Show Limits[]; // Assume Show Limits column has 1 for "show" and 0 for "hide"
    
    // Get the corresponding column in the data table
    col = Column( dataTable, specName );
    
    // Set the Spec Limits property as an associative array
    col << Set Property( "Spec Limits", {LSL( LSL ), USL( USL ), "Show Limits"( showLimits )}         	
        );
    	
 );

// Close the Spec Limits table
Close( specTable, NoSave );

The script is setting up the spec. limit property in all the correct places given by the spec. limit table, but it is not importing the actual spec limits. Any suggestions?

2 ACCEPTED SOLUTIONS

Accepted Solutions
jthi
Super User

Re: JSL for importing spec limits

You can use Manage Limit platform for this if your data is in correct format

Names Default To Here(1);

dtLimits = New Table("Cities Limits",
	Add Rows(4),
	New Column("Process", Character, Set Values({"OZONE", "CO", "SO2", "NO"})),
	New Column("LSL", Numeric, Set Values([0, 0, 0, 0])),
	New Column("Target", Numeric, Set Values([0.2, 15, 0.05, 0.035])),
	New Column("USL", Numeric, Set Values([0.4, 30, 0.1, 0.07])),
	Set Label Columns(:Process)
);
dt = Open("$SAMPLE_DATA/Cities.jmp");
obj = dt << Manage Limits(
	Process Variables(:OZONE, :CO, :SO2, :NO),
	Load From Limits Table(dtLimits)
);
obj << Save to Column Properties;

If you wish to go your route, you need to evaluate the limits

Eval(EvalExpr(
	col << Set Property("Spec Limits", {LSL(Expr(LSL)), USL(Expr(USL)), Show Limits(Expr(showLimits)}))
));
-Jarmo

View solution in original post

Steffen_Bugge
Level IV

Re: JSL for importing spec limits

Thanks @jthi , works like a charm!

I updated my original script to evaluate the limits. 

// Open the Spec Limits table
specTable = Open("C:\Trending Tool Spec Limits.jmp");

// Open data table for analysis
dataTable = Data Table( "Trending data" );

// Extract Spec Limits and Show Limits from Spec Table
For Each Row(
    specName = specTable:Variable[];
    LSL = specTable:LSL[];
    USL = specTable:USL[];
    showLimits = specTable:Show Limits[]; // Assume Show Limits column has 1 for "show" and 0 for "hide"
    
    // Get the corresponding column in the data table
    col = Column( dataTable, specName );
    
    // Set the Spec Limits property as an associative array
   Eval(EvalExpr(
	col << Set Property("Spec Limits", {LSL(Expr(LSL)), USL(Expr(USL)), "Show Limits"n(Expr(showLimits)))})
	);
    	
 );

// Close the Spec Limits table
Close( specTable, NoSave );

View solution in original post

7 REPLIES 7
jthi
Super User

Re: JSL for importing spec limits

You can use Manage Limit platform for this if your data is in correct format

Names Default To Here(1);

dtLimits = New Table("Cities Limits",
	Add Rows(4),
	New Column("Process", Character, Set Values({"OZONE", "CO", "SO2", "NO"})),
	New Column("LSL", Numeric, Set Values([0, 0, 0, 0])),
	New Column("Target", Numeric, Set Values([0.2, 15, 0.05, 0.035])),
	New Column("USL", Numeric, Set Values([0.4, 30, 0.1, 0.07])),
	Set Label Columns(:Process)
);
dt = Open("$SAMPLE_DATA/Cities.jmp");
obj = dt << Manage Limits(
	Process Variables(:OZONE, :CO, :SO2, :NO),
	Load From Limits Table(dtLimits)
);
obj << Save to Column Properties;

If you wish to go your route, you need to evaluate the limits

Eval(EvalExpr(
	col << Set Property("Spec Limits", {LSL(Expr(LSL)), USL(Expr(USL)), Show Limits(Expr(showLimits)}))
));
-Jarmo
Steffen_Bugge
Level IV

Re: JSL for importing spec limits

Thanks @jthi , works like a charm!

I updated my original script to evaluate the limits. 

// Open the Spec Limits table
specTable = Open("C:\Trending Tool Spec Limits.jmp");

// Open data table for analysis
dataTable = Data Table( "Trending data" );

// Extract Spec Limits and Show Limits from Spec Table
For Each Row(
    specName = specTable:Variable[];
    LSL = specTable:LSL[];
    USL = specTable:USL[];
    showLimits = specTable:Show Limits[]; // Assume Show Limits column has 1 for "show" and 0 for "hide"
    
    // Get the corresponding column in the data table
    col = Column( dataTable, specName );
    
    // Set the Spec Limits property as an associative array
   Eval(EvalExpr(
	col << Set Property("Spec Limits", {LSL(Expr(LSL)), USL(Expr(USL)), "Show Limits"n(Expr(showLimits)))})
	);
    	
 );

// Close the Spec Limits table
Close( specTable, NoSave );
Steffen_Bugge
Level IV

Re: JSL for importing spec limits

@jthi, when importing the spec limits with the EvalExpr function, the limits are imported but do not show up as limits before I open the spec. limit property window and press Apply. Do you know why, and what can be done to avoid this?

jthi
Super User

Re: JSL for importing spec limits

Are you sure your data in your spec limits table is numeric and not character?

-Jarmo
Steffen_Bugge
Level IV

Re: JSL for importing spec limits

Yes, it is numeric. It was saved from the Manage Limits platform. 

jthi
Super User

Re: JSL for importing spec limits

Ah... now I did notice that you are using incorrect syntax for setting the limits, you are missing the list (squiggly brackets)

jthi_0-1724351816305.png

 

Names Default To Here(1);

dtLimits = New Table("Cities Limits",
	Add Rows(4),
	New Column("Variable", Character, Set Values({"OZONE", "CO", "SO2", "NO"})),
	New Column("LSL", Numeric, Set Values([0, 0, 0, 0])),
	New Column("USL", Numeric, Set Values([0.4, 30, 0.1, 0.07])),
	New Column("Show Limits", Numeric, Set Values([1, 1, 1, 1]))
);
dt = Open("$SAMPLE_DATA/Cities.jmp");

For Each Row(dtLimits,
	specName = dtLimits:Variable[];
	low = dtLimits:LSL[];
	high = dtLimits:USL[];
	showLimits = dtLimits:Show Limits[];
	
	Eval(Eval Expr(
		Column(dt, specName) << Set Property("Spec Limits", {LSL(Expr(low)), USL(Expr(high)), Show Limits(Expr(showLimits))})
	));
);

Close(dtLimits, NoSave);
-Jarmo
Steffen_Bugge
Level IV

Re: JSL for importing spec limits

Perfect, thanks! That did the trick!