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
/****NeverStopLearning****/