I frequently concatenate multiple data tables into a single table and then add two new columns with initialized data. New Column 1 is called "Device" and is a constant that I enter. New Column 2 is called "Index" and is sequential data from 1 to x, where x is the last row in the data table.
I would like to script the creation of these two new columns in the concatenated table, ideally with a Pop Up window to ask for the Device number.
OK, this will get you started. Your side of the bargain is that you need to read the Scripting Guide, so you can learn about all of the items in the script, and also learn about what kinds of things you can do to make the script exactly what you want.
Names Default To Here( 1 );
dt = Current Data Table();
nw = New Window( "Device Input",
Border Box( top( 10 ), bottom( 10 ), Left( 10 ), Right( 10 ),
sides( 15 ),
Lineup Box( N Col( 1 ),
Spacer Box( size( 0, 10 ) ),
Text Box( "Enter Device Name" ),
dev = Text Edit Box( " ",
<<set script( devText = dev << get text )
If( nw["button"] == 1,
dt << New Column( "Device",
character,set each value( devText )
dt << New Column( "index", set each value( Row() ) );
the script above is exactly what you need. So nothing to add for this.
However, you can learn a lot from JMP directly.
1. In your data table, you can e.g. right click on the last column and choose "New Formula Column"->"Row"->"Row".
--> You will get a new column with a sequence in it from 1 to the end of the data table.
2. Now click on the red triangle in the top left panel of the data table (the scripts part of th edata table). Select Copy Table Script (without data)
3. Open a script window and paste the code in it. At the bottom of the script you will find the script to create this new column with the formula using the Row() statement. This is what txnelson basically has used.
Scripting index and scripting guide are your friends for JSL tasks. and deepen the understanding. But keep in mind you can come far with the automatic creation of code from JMP.
That said, you should with any scripting/programming language always make yourself familiar to good programming practice