Send value of check box to the last row of a specified columnThe user selects a point on a chart. The script is then run where the user selects an option in a modal check box, "start" or "end". The script copies the selected row of data to another table, dt2. This part works fine. I cannot seem to append the value selected in the check box into column called "position" for the same row that was just added by the concatenate statement.
//Modal (non-Modal) Retrieval in OK button
//Initialize
cycleList = {"start", "end"};
rb_c = 0;
New Window( "Select start/end", <<MODAL></MODAL>
Re: Send value of check box to the last row of a specified columnHi Ian,
This works fine! Thank you very much. The script will save hours and hours of transcribing start and end of cycle data points.
Cheers!
Re: Send value of check box to the last row of a specified columnYou can avoid the JMP 13 dependency by using a loop:
NamesDefaultToHere(1);
// Sample data
dt = Open("$SAMPLE_DATA/Big Class.jmp");
// UI
win = NewWindow("Select Cycles",
rc = dt << Control Chart(
Sample Size( 1 ),
KSigma( 3 ),
Chart Col( :height, Run Chart( Show Center Line( 0 ) ) )
),
PanelBox("Define Cycle",
LineUpBox(NCol(2),
ButtonBox("Start Cycle", startScript),
ButtonBox("End Cysle", endScript)
)
)
);
// Make a copy of 'dt' with no rows
dt2 = Eval(dt << getScript);
dt2 << deleteRows(1::NRow(dt));
dt2 << setName((dt << getName)||" - Cycles");
// Add extra columns
dt2 << NewColumn("Row", Numeric, Ordinal);
dt2 << NewColumn("Cycle", Character);
// When 'Start Cycle' is pressed - If multiple rows are selected, take the first
startScript =
Expr(
r = dt << getSelectedRows;
dt2 << addRows(1);
for(c=1, c<=NCol(dt), c++, Column(dt2, c)[NRow(dt2)] = Column(dt, c)[r[1]]);
Column(dt2, "Row")[NRow(dt2)] = r[1];
Column(dt2, "Cycle")[NRow(dt2)] = "Start";
);
// When 'End Cycle' is pressed - If multiple rows are selected, take the first
endScript =
Expr(
r = dt << getSelectedRows;
dt2 << addRows(1);
for(c=1, c<=NCol(dt), c++, Column(dt2, c)[NRow(dt2)] = Column(dt, c)[r[1]]);
Column(dt2, "Row")[NRow(dt2)] = r[1];
Column(dt2, "Cycle")[NRow(dt2)] = "End";
);
Regarding 'multiple rows will not be selected by the user', then, if I have understood correctly, it is certainly possible that they could . . .
Re: Send value of check box to the last row of a specified columnHi Ian,
Using JMP 11. The user is presented with the chart from which they choose a single data point, run the script to define whether the point is the start or end of a cycle. I need the entire row of data saved to another table with the new column "position" defining whether that row is a "start" or "end" of the cycle. Multiple rows will not be selected by the user. Attached is a sample "chart 2" showing weight loss against time. The code will copy and save the row that the user selected, however, I cannot seem to trap the user's selection (start or end) and save that value to the "position" column for that row.
Cheers
Re: Send value of check box to the last row of a specified columnThe code didn't run for me, so I offer an alternative that you might be able to build on (requires JMP 13 because of the table subscripting):
NamesDefaultToHere(1);
// Sample data
dt = Open("$SAMPLE_DATA/Big Class.jmp");
// UI
win = NewWindow("Select Cycles",
rc = dt << Control Chart(
Sample Size( 1 ),
KSigma( 3 ),
Chart Col( :height, Run Chart( Show Center Line( 0 ) ) )
),
PanelBox("Define Cycle",
LineUpBox(NCol(2),
ButtonBox("Start Cycle", startScript),
ButtonBox("End Cysle", endScript)
)
)
);
// Make a copy of 'dt' with no rows
dt2 = Eval(dt << getScript);
dt2 << deleteRows(1::NRow(dt));
dt2 << setName((dt << getName)||" - Cycles");
// Add extra columns
dt2 << NewColumn("Row", Numeric, Ordinal);
dt2 << NewColumn("Cycle", Character);
// When 'Start Cycle' is pressed - If multiple rows are selected, take the first
startScript =
Expr(
r = dt << getSelectedRows;
dt2 << addRows(1);
dt2[NRow(dt2), 1::NCol(dt)] = dt[r[1],0];
dt2[NRow(dt2), "Row"] = r[1];
dt2[NRow(dt2), "Cycle"] = "Start";
);
// When 'End Cycle' is pressed - If multiple rows are selected, take the first
endScript =
Expr(
r = dt << getSelectedRows;
dt2 << addRows(1);
dt2[NRow(dt2), 1::NCol(dt)] = dt[r[1],0];
dt2[NRow(dt2), "Row"] = r[1];
dt2[NRow(dt2), "Cycle"] = "End";
);
Perhaps you had a good reason to design it the way you did, but it seems that defining a start and an end makes it more complicated and error prone than defining a range (that is, a whole cycle).