cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
Choose Language Hide Translation Bar
Ohad_s
Level II

Run script on different tables

Hi,

I have a script that splits text from one column to serval columns, deletes some, gives names, and changes data type.

the script includes the table name,

I want to use this script on other tables without changing table names for different files.

all the tables I use are in the same format except for table names.

 
// Text to columns
Data Table(
	"TM1_CTW RPT+TPT x10.0_TU_Defualt_6050_01_Surface_TM1_CTW RPT+TPT x10.0_TU_Defualt_6293_04_Surface"
) << Text to Columns( columns( :File Name ), Delimiters( "_" ) );
 
 
// Delete columns
Data Table(
	"TM1_CTW RPT+TPT x10.0_TU_Defualt_6050_01_Surface_TM1_CTW RPT+TPT x10.0_TU_Defualt_6293_04_Surface"
) << Delete Columns( :File Name 1, :File Name 2, :File Name 3, :File Name 4, :File Name 7 );
 
 
// Change column info: Scan
Data Table(
	"TM1_CTW RPT+TPT x10.0_TU_Defualt_6050_01_Surface_TM1_CTW RPT+TPT x10.0_TU_Defualt_6293_04_Surface"
):File Name 5 << Data Type( Numeric ) << Set Name( "Scan" ) << Set Modeling Type( "Ordinal" ) <<
Set Field Width( 12 );
 
 
// Change column info: Wafer
Data Table(
	"TM1_CTW RPT+TPT x10.0_TU_Defualt_6050_01_Surface_TM1_CTW RPT+TPT x10.0_TU_Defualt_6293_04_Surface"
):File Name 6 << Data Type( Numeric ) << Set Name( "Wafer" ) << Set Modeling Type( "Ordinal" ) <<
Set Field Width( 12 );

 

Ohad_s_0-1712567249491.png

 

       

1 ACCEPTED SOLUTION

Accepted Solutions
jthi
Super User

Re: Run script on different tables

You can get the table list using Get Data Table List();, you can then loop over this list by using For Each() and perform actions inside it. You could turn whatever you do inside the loop into expression using Expr() or to a function with Function() to make the code a bit more clean

 

Names Default To Here(1);
Open("$SAMPLE_DATA/Big Class.jmp");
Open("$SAMPLE_DATA/Cars.jmp");

For Each({dt}, Get Data Table List(),
	dtname = dt << get name;
	show(dtname);
);

Depending how you open your tables / get them, you most likely already have references to those and you could just use them instead of Get Data Table List().

 

 

Scripting Index (from JMP Help menu) and scripting guide have a lot of information and documentation regarding JMP scriptig, I suggest checking those out.

-Jarmo

View solution in original post

1 REPLY 1
jthi
Super User

Re: Run script on different tables

You can get the table list using Get Data Table List();, you can then loop over this list by using For Each() and perform actions inside it. You could turn whatever you do inside the loop into expression using Expr() or to a function with Function() to make the code a bit more clean

 

Names Default To Here(1);
Open("$SAMPLE_DATA/Big Class.jmp");
Open("$SAMPLE_DATA/Cars.jmp");

For Each({dt}, Get Data Table List(),
	dtname = dt << get name;
	show(dtname);
);

Depending how you open your tables / get them, you most likely already have references to those and you could just use them instead of Get Data Table List().

 

 

Scripting Index (from JMP Help menu) and scripting guide have a lot of information and documentation regarding JMP scriptig, I suggest checking those out.

-Jarmo