Dynamic Coding ProblemHello,
Looking for tips on how to make my script more dynamic.
Given the snippet below we have a data table << Get as Report that we add onto a Col Box() with dynamic buttons.
Now, here lies the issue. I need to put X amount of data tables into my window and I'm not sure how to go about it since I also need to add dynamic buttons to each table.
The exact amount of data tables can vary.
Thanks for the help
data_window = New Window("Down Time Exceeding 5mins",
<< Size Window( 1000, 600 ),
H List Box(
OutLine Box ("foo",
dt_Rpt = dt_dt << Get as Report();
)
)
);
tb = dt_Rpt[Table Box( 1 )];
tb << append(
bb = col box("Pull Alarms")
);
bblist = {};
for (i = 1, i<=N Rows(dt_dt), i++,
bb_expr = evalinsert("\[bblist[i] = buttonbox("Pull Alarms",
tb << Set Selected Rows(Matrix({^i^}));
dt = Get Data Table( "foo Alarms for rows " || char(^i^));
dt << ShowWindow( 1 );
dt << Bring Window To Front;
)]\");
eval(parse(bb_expr));
bb << append(bblist[i]);
);Automation and ScriptingRe: Dynamic Coding ProblemCreate a function to generate a data table with buttons:
Define Function( Create_Data_Table_With_Buttons( dt_name, window_title ),
dt_Rpt = dt_name << Get as Report();
tb = dt_Rpt[Table Box( 1 )];
tb << append(
bb = col box("Pull Alarms")
);
bblist = {};
for (i = 1, i <= N Rows(dt_name), i++,
bb_expr = evalinsert("\[bblist[i] = buttonbox("Pull Alarms",
tb << Set Selected Rows(Matrix({^i^}));
dt = Get Data Table( "^window_title^ Alarms for rows " || char(^i^));
dt << ShowWindow( 1 );
dt << Bring Window To Front;
)]\");
eval(parse(bb_expr));
bb << append(bblist[i]);
);
return dt_Rpt;
);
Create a list of data table names and their corresponding window titles:
data_table_info = {
{"dt_1", "Down Time Exceeding 5mins"},
{"dt_2", "Another Data Table1"},
{"dt_3", "Another Data Table2"}
};
Use a loop to create multiple OutLine boxes with data tables and buttons:
data_window = New Window("Multiple Data Tables",
<< Size Window( 1000, 600 ),
H List Box(
V List Box(
for(i = 1, i <= N Items(data_table_info), i++,
OutLine Box(data_table_info[i][2],
Create_Data_Table_With_Buttons(
Eval(data_table_info[i][1]),
data_table_info[i][2]
)
)
)
)
)
);
Hope that helps.
Re: Dynamic Coding ProblemAre you possibly looking something like this?
Names Default To Here(1);
dt = Open("$SAMPLE_DATA/Big Class.jmp");
data_window = New Window("Down Time Exceeding 5mins",
<<SIZE window=""></SIZE>Re: Dynamic Coding ProblemThanks!! Didn't even think about using several functions. I thought I might have to create some gigantic headache string to parse, but this totally worked.
I have a function that creates the data tables for each string in my query list. Then I pass the dt to another function that
appends Lbox which creates the report in my window
window = expr(
nw = New Window("Down Time Exceeding 5mins",
<< Size Window( 1500, 800 ),
Lbox = Line Up Box(Spacing(5),
N Col(3),
)
);
);
eval(window);
nw <