cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
The Discovery Summit 2025 Call for Content is open! Submit an abstract today to present at our premier analytics conference.
Choose Language Hide Translation Bar
View Original Published Thread

Getting categories from another script.

SpannerHead
Level V

This was very helpful to get me where I am

Solved: Invoking a script from another script - JMP User Community

I can invoke a script from the main script.  The script I invoke applies categories to the target data set and I'd like to be able to form a list of categories in the script I invoke that I can apply to the main script.  Below is a snapshot of the invoked script, several parameters and categories can be iterated and I'd like a list of categories available in the main table.

 

Try((Column( "Parameter") << Set Selected(1););
dt << group columns( "ENG" );
dt << deselect column group( "ENG" );):

 

 


Slán



SpannerHead
2 ACCEPTED SOLUTIONS

Accepted Solutions
ngambles
Level III


Re: Getting categories from another script.

If I'm understanding your post correctly, it looks like your invoked script is creating "categories" in your data table by creating multiple column groups. Those column groups will have names like "Reject", "Engineering", "Etc...".

 

After you have run your invoked script, you can get the list of column groups from your data table by using the "get column groups names" function. An example is shown below:

names default to here(1);

dt = current data table();

categoryList = dt << get column groups names;

show(categoryList);

To take it one step farther, after you get your list of categories, you can loop through the list and use the "get column group" function to get the list of all the test measurement columns that are within each column group. Here's an example:

names default to here(1);

dt = current data table();

categoryList = dt << get column groups names;

for( k = 1, k <= n items( categoryList ), k++,
    
    show( categoryList[k] );

    colList = dt << get column group( categoryList[k] );

    print( colList );
);

View solution in original post

SpannerHead
Level V


Re: Getting categories from another script.

Nice!  I use something like this to feed information from the subscript to the main script.  I am writing the subscript with another script.  Probably not standard but I write the script in the columns of the data table containing the spec limits, copy that as text and paste into a script window.  Seems to work.

 

	Spud = (":" || cnmes2[l]);
	Spuds = Parse( Eval Insert( Spud ) );
	Tabname = Char( dt );
	
//This section of the script devises a name for each script generated.
 	
	Tabname = Char( dt );
	Show( Tabname );
	name = Char( Column Name( l ) );
	names = Char( "Spec Limits, Group and Notes Script " ) || Char( Tabname ) || Char( name );
	Show( names );
	Show( Spuds );
	Ainim = Regex( names, "\!"", "", GLOBALREPLACE );
	Show( Ainim );
	link = Char(cats);
	
//Scripts are generated in 2 table columns "Address Data Table" and "Group with Notes and Spec Limits" before being pasted into a Script Window.

	New Column( "Address Data Table",
		Character,
		"Nominal",
		Formula(
			If( Row() == 1,
				"dt=Current Data Table();
				Process_Script = " || "\!"" || Ainim || "\!"" || "; Show( Process_Script );
	cats = " || link ||  "; Show( Process_Script );"
			)
		)
	);
	
	Column( "Address Data Table" ) << Delete Formula;For( l = Num(Start), l <= N Items( cnmes2 ), l++, 

summarize(cats=by(cnmes2 [l] ));
delcats = {"", "-"};

For( i = 1, i <= N Items( delcats ), i++,
	Remove From( cats, As List( Loc( cats, delcats[i] ) ) )
);

show(cats);

Slán



SpannerHead

View solution in original post

6 REPLIES 6
jthi
Super User


Re: Getting categories from another script.

Are you just running Include, to run the other script file? Does it have expressions/functions? Which categories and how you wish to have them available? 

-Jarmo
SpannerHead
Level V


Re: Getting categories from another script.

I do use Include to run the other script, which applies categories to the table columns.  An alternative way to get what I need would be to list the categories in the finished table.


Slán



SpannerHead
jthi
Super User


Re: Getting categories from another script.

Where are the categories? What do you mean by categories? How should they be added to your main table?

-Jarmo
SpannerHead
Level V


Re: Getting categories from another script.

Each measurement that has specs falls within a category defined by the test organisation.  Some categories are Reject, meaning they are crucial to pass, others are Engineering, meaning they are of interest but not critical to pass.


Slán



SpannerHead
ngambles
Level III


Re: Getting categories from another script.

If I'm understanding your post correctly, it looks like your invoked script is creating "categories" in your data table by creating multiple column groups. Those column groups will have names like "Reject", "Engineering", "Etc...".

 

After you have run your invoked script, you can get the list of column groups from your data table by using the "get column groups names" function. An example is shown below:

names default to here(1);

dt = current data table();

categoryList = dt << get column groups names;

show(categoryList);

To take it one step farther, after you get your list of categories, you can loop through the list and use the "get column group" function to get the list of all the test measurement columns that are within each column group. Here's an example:

names default to here(1);

dt = current data table();

categoryList = dt << get column groups names;

for( k = 1, k <= n items( categoryList ), k++,
    
    show( categoryList[k] );

    colList = dt << get column group( categoryList[k] );

    print( colList );
);
SpannerHead
Level V


Re: Getting categories from another script.

Nice!  I use something like this to feed information from the subscript to the main script.  I am writing the subscript with another script.  Probably not standard but I write the script in the columns of the data table containing the spec limits, copy that as text and paste into a script window.  Seems to work.

 

	Spud = (":" || cnmes2[l]);
	Spuds = Parse( Eval Insert( Spud ) );
	Tabname = Char( dt );
	
//This section of the script devises a name for each script generated.
 	
	Tabname = Char( dt );
	Show( Tabname );
	name = Char( Column Name( l ) );
	names = Char( "Spec Limits, Group and Notes Script " ) || Char( Tabname ) || Char( name );
	Show( names );
	Show( Spuds );
	Ainim = Regex( names, "\!"", "", GLOBALREPLACE );
	Show( Ainim );
	link = Char(cats);
	
//Scripts are generated in 2 table columns "Address Data Table" and "Group with Notes and Spec Limits" before being pasted into a Script Window.

	New Column( "Address Data Table",
		Character,
		"Nominal",
		Formula(
			If( Row() == 1,
				"dt=Current Data Table();
				Process_Script = " || "\!"" || Ainim || "\!"" || "; Show( Process_Script );
	cats = " || link ||  "; Show( Process_Script );"
			)
		)
	);
	
	Column( "Address Data Table" ) << Delete Formula;For( l = Num(Start), l <= N Items( cnmes2 ), l++, 

summarize(cats=by(cnmes2 [l] ));
delcats = {"", "-"};

For( i = 1, i <= N Items( delcats ), i++,
	Remove From( cats, As List( Loc( cats, delcats[i] ) ) )
);

show(cats);

Slán



SpannerHead