キャンセル
次の結果を表示 
表示  限定  | 次の代わりに検索 
もしかして: 
The Discovery Summit 2025 Call for Content is open! Submit an abstract today to present at our premier analytics conference.
言語を選択 翻訳バーを非表示
最初に公開されたスレッドを表示

Collection of good/valuable scripting examples the scripters club would like to be added to the scripting index examples

martindemel
Staff

In our last session the idea came up to collect good examples which may be good candidates to be added to the scripting index in JMP as examples. 

 

Please add in the comments section your ideas with links to community posts or just adding the code as example in the comments. Be sure to specify what function the example is related to (where you would like to see this example!

 

We will provide all suggestions to our support team and therefore to the developers, so they can consider adding at least some of them. 

 

Actions: 

  1. Add your suggestions in the comment field
  2. kudo the ones you liked to be added

The least we get is a valuable list of example in this post, which by itself should already be very helpful. 

 

Thanks! 

/****NeverStopLearning****/
5件の返信5
hogi
Level XII

Re: Collection of good/valuable scripting examples the scripters club would like to be added to the scripting index examples

For New Column() & << Set Property(), please add a Link to 
Writing JSL code dynamically 
[alternatively, one could add the link to Substitute and Expr.
The problem: Just user who know the answer will find the answer]

Names Default to Here(1);

// Open a sample data table
dt = Open("$SAMPLE_DATA/Cleansing.jmp");

// Values previously obtained from a lookup table and assigned to variables as:
myLSL = 6;
myUSL = 8;
myTarget = 7;

// Use the variables to set the spec limits column property
Eval(Eval Expr(
    Column(dt, "pH") << Set Property(
        "Spec Limits",
        {LSL( Expr(myLSL) ), USL( Expr(myUSL) ), Target( Expr(myTarget) ), Show Limits( 1 )}
    );
));

Re: Collection of good/valuable scripting examples the scripters club would like to be added to the scripting index examples

I always forget how Eval(), Eval Expr() and Expr() work together, so I have this page bookmarked, and I specifically use this bit of JSL from the linked page:

//Eval Expr
For( i = 1, i <= N Items(cols), i++,
       Eval( Eval Expr(
              dt << New Column( 
                    "2 * " || Char( cols[i] ),
                    Numeric,
                    "Continuous",
                    Formula( As Column( Expr( Char( cols[i] ) ) ) * 2)
              )
       ) )
);
hogi
Level XII

Re: Collection of good/valuable scripting examples the scripters club would like to be added to the scripting index examples

For Get Environment Variable():

 

uname = Get Environment Variable( "USERNAME" );

from: https://community.jmp.com/t5/Discussions/computer-name/m-p/753036/highlight/true#M93482  

 

hogi
Level XII

Re: Collection of good/valuable scripting examples the scripters club would like to be added to the scripting index examples

In the description of for loops, add a link to data table indexing, e.g. :
https://community.jmp.com/t5/Uncharted/Data-table-subscripting/ba-p/21013 

Re: Collection of good/valuable scripting examples the scripters club would like to be added to the scripting index examples

 
 I have the same trick for Eval(), Substitute(), Expr(), in particular a series of examples when it comes to columns.
dt = Open("$SAMPLE_DATA/Tablet Production.jmp");
ColList = dt << Get Column Names( Continuous );

// New column
For( i = 1, i <= N Items( colList ), i++,
	Eval(Substitute(								
		Expr(										
			newCol = dt << New Column( 
				col_Name,							
				Numeric,
				"Continuous", 
				Format( "Percent", 12, 2 ),
				Formula(As Column(col1) / Col_Mean	)); 	),
		Expr(col_Name), "Ratio " || Char(colList[i]) || " vs. Col Mean",					
		Expr(col1),Column(dt,ColList[i]),
		Expr(Col_Mean), Col mean(Column(dt,ColList[i])) 
)));