User Entered Values to Column values using JSLI am new to JSL Scripting.
I am trying to populate a column using entries from a panel box.
In part of my code below, I am trying to get the value entered ,34, to populate a column named Price Code. However, when I run this code an empty column is returned.
I have tried using Get Values (Num) in place of Set Values(Num) and I still get an empty Price Code column.
dataTable = New Table( "Data Table",
Add Rows( 3 ),
New Column( "Customer Name",
Character,
"Nominal",
Set Values( {"Jane", "Scott", "Abby"} )
),
New Column( "Dollar Amount",
"Continuous",
Set Values( [2002, 1323, 1954] )
)
);
popUp = New Window ("Number", << modal(),
Panel Box("Enter a Number", lineup box ( N col (1)),
number = Number edit box (34), ),
Panel Box ("Actions", H List Box ( Button Box ("OK", keep_going = 1;
Num = :number << Get;),
Button Box ("Cancel", keep_going = 0) ), ),
);
dataTable << New Column("Price Code",Numeric, "Continuous", Set Values(Num));
Re: User Entered Values to Column values using JSLI was able to solve my problem wtih the following
Try( :Sample[dt << get rows where( :Sample== "01a" )] = s1 );
Re: User Entered Values to Column values using JSLThanks all, I was wondering if I wanted to subsitutute a string in a column named sample, why won't the following script work?
myCol = dt << Column ("sample");
substitute into(myCol, "01a", s1);Re: User Entered Values to Column values using JSLSlightly different approach to fix your original script
Names Default To Here( 1 );
dt = current data table();
dt << New Column("Sample Number",Character,Formula(Left(:Sample, Length(:Sample) - 1)),EvalFormula);
InputWindow = New Window( "Enter Input",
<<MODAL></MODAL>Re: User Entered Values to Column values using JSLYou are not scoping the reference properly. You reference the column Sample Number as:
:Sample Number
Please take the time to read the Scripting Guide to round out your knowledge of the components of JSL.
Help==>Books==>Scripting GuideRe: User Entered Values to Column values using JSLJust to update, the I got the values in the table to be replaced with the user input by actually specifying the row but the script seems to end there. It does not "Sort the samples by name"Re: User Entered Values to Column values using JSLThanks so much for your help, here's my full script, I still cannot get teb1, teb2,... etc to replace sample number 01, 02,...etc. In the current script, the user input just seems to replace the values of sample name and sample number in the first row, second row etc. I would like the user input to replace sample number 01, 02, 03, 04, 05, 06 etc
dt=New Table();
dt=current data table();
current data table() << Bring Window To Front;
Wait(0);
Main Menu("Paste With Column Names");
// Change the column name
Col1=column("X-Value");
Col1<<SET name=""></SET>Re: User Entered Values to Column values using JSLNot being able to see your sample data table, I am not completly sure what the issue is, but for sure, the main issue is that you are not doing anything to write the values from the input screen to the data table. Below is a modification of your code that writes the values to the data table
Names Default To Here( 1 );
dt=open("$SAMPLE_DATA/big class.jmp");
dt<<NEW column=""></NEW>Re: User Entered Values to Column values using JSLSorry I should rephrase that, there is no error message but the sample names in the data table are not being replaced with the user input
Re: User Entered Values to Column values using JSLWhat is error message in the log?Re: User Entered Values to Column values using JSLThank you for the help but I'm getting an error, where am I going wrong?
dt << New Column("Sample Number",Character,Formula(Left(:Sample, Length(:Sample) - 1)),EvalFormula);
dt = current data table();
Names Default To Here( 1 );
InputWindow = New Window( "Enter Input",
<<MODAL></MODAL>Re: User Entered Values to Column values using JSLHere is one way:
Names Default To Here( 1 );
InputWindow = New Window( "Enter Input",
<<MODAL></MODAL>
Re: User Entered Values to Column values using JSLSomething like this? But how would you replace the sample number with the user input for sample name?
// Create a new column for sample names
dt << New Column("Sample Number",Character,Formula(Left(:Sample, Length(:Sample) - 1)),EvalFormula);
dt = current data table();
InputWindow = New Window( "Enter Input", <<MODAL></MODAL>Re: User Entered Values to Column values using JSLI think you could make a cleaner and simpler UI with a Table Box() organizing a String Col Box() for the labels and a V List() of Text Edit Box() for the input values.
Re: User Entered Values to Column values using JSLI was wondering in regards to this solution, how would I go about getting the input from the user in regards to sample name and set that as my sample number?
dt << New Column("Sample Number",Character,Formula(Left(:Sample, Length(:Sample) - 1)),EvalFormula);
InputWindow = New Window( "Enter Input", <<MODAL></MODAL>Re: User Entered Values to Column values using JSLThank you so much txnelson.
Re: User Entered Values to Column values using JSLThank you so much txnelson
Re: User Entered Values to Column values using JSLThis is a simple 2 issue problem.
1. When you referenced
Num = :number << Get;
You are scoping the variable number wrong, ":" in front of the variable, tells JSL to look for a column named "Number" in a data table. If you either leave it blank, or specify "::" it will look for a memory variable.
2. If you want the scaler value from the memory variable "NUM" to be populated in all rows of the table you need to specify:
dataTable << New Column( "Price Code", Numeric, "Continuous", Set each Value( Num ) );
So the complete script would be:
Names Default To Here( 1 );
dataTable = New Table( "Data Table",
Add Rows( 3 ),
New Column( "Customer Name", Character, "Nominal", Set Values( {"Jane", "Scott", "Abby"} ) ),
New Column( "Dollar Amount", "Continuous", Set Values( [2002, 1323, 1954] ) )
);
popUp = New Window( "Number",
<<MODAL></MODAL>