열려 있는 모든 보고서에 열 전환기가 적용됨안녕하세요 여러분,
열려 있는 모든 보고서에 열 전환기를 적용하는 스크립트를 작성하려고 합니다. 안내해주세요
dt = Current data Table();
//Get all Open reports
wList = Get Window List( Type( "Reports" ) );
//Get Column to replace and column to replace with
win = New Window( "Set a Value",
<이 작업을 수행하는 방법을 안내해 주십시오. 미리 감사드립니다자동화 및 스크립팅
Re: 열려 있는 모든 보고서에 열 전환기가 적용되었습니다.Col List Box를 어떻게 사용하시겠습니까? 열 전환기를 사용하려면 열 전환기의 열 목록을 기반으로 다른 열로 변경되는 단일 열이 있어야 하며 이 열은 시작 시 모든 보고서에서 동일해야 합니다.
Re: 열려 있는 모든 보고서에 열 전환기가 적용되었습니다.@jthi , 미안해요.. 열 전환기 대신 사용자가 첫 번째에서 교체할 열과 두 번째에서 교체할 열을 선택하는 2개의 colList 상자를 갖는 것이 더 쉬운 것 같아요.. 이 접근 방식이 더 적합한가요?
Re: 열려 있는 모든 보고서에 열 전환기가 적용되었습니다.좀 더 쉬울 수도 있을 것 같아요. 적절한 솔루션을 작성할 시간이 없지만 아래에는 이에 접근하는 방법에 대한 아이디어가 있습니다(열 전환기를 사용하여 함수 호출에서 생성한 열 변경 + "허가가 아니라 용서를 구하세요"). 여전히 하드코딩된 내용이 있지만 오늘이나 내일 다시 돌아와서 이 문제가 흥미로운 문제이므로 더욱 강력하게 만들겠습니다.
Names Default To Here(1);
dt = Open("$SAMPLE_DATA/Probe.jmp");
dt << Clear Row States;
New Window("",
Lineup box(N Col(2),
dist = dt << Distribution(Continuous Distribution(Column(:DELL_RPNBR))),
dist2 = dt << Distribution(Continuous Distribution(Column(:DELW_M1))),
gb1 = dt << Graph Builder(
Size(528, 448),
Show Control Panel(0),
Variables(X(:Site), Y(:Lot ID)),
Elements(Points(X, Y, Legend(3)))
),
gb2 = dt << Graph Builder(
Size(523, 454),
Show Control Panel(0),
Variables(X(:DELW_M1), Y(:DELL_RPNBR)),
Elements(Points(X, Y, Legend(3)))
)
)
);
nw = New Window("",
H List Box(
Lineup Box(N Col(2),
Panel Box("Select Column to Change",
fcs1 = Filter Col Selector(dt, << Set Max Selected(1))
),
Panel Box("Select New Column",
fcs2 = Filter Col Selector(dt, << Set Max Selected(1))
)
),
Panel Box("Action",
Button Box("Change Columns"),
Button Box("Cancel"),
)
)
);
update_reports = function({dt, report_list, old_col, new_col}, {Default Local},
nw_switcher = New Window("", << Window View("Invisible"),
ref_colswitcher = dt << Column Switcher(:DELL_RPNBR, {:DELW_SICR, :DELL_RPNBR});
);
wait(0);
For Each({report}, report_list,
Try(ref_colswitcher << Link Platform(report));
);
wait(0);
nw_switcher[ListBoxBox(1)] << Set Selected(1);
nw_switcher << Close Window;
);
reports = Eval List({dist, dist2, gb1, gb2});
update_reports(dt, reports, "a", "b");
Re: 열려 있는 모든 보고서에 열 전환기가 적용되었습니다.몇 가지 다른 버그/이상한 상호 작용이 있어 생각보다 이 문제를 더 어렵게 만들고 그로 인해 코드가 매우 지저분해 보이지만 어느 정도 작동하는 것 같습니다.
Names Default To Here(1);
get_reports_for_datatable = function({dt}, {Default Local},
valid_reports = {};
// This might need improvements
report_windows = Get Window List(Type("Reports"));
For Each({report_window}, report_windows,
Try(
cur_analytic_layer = report_window[OutlineBox(1)] << Get Scriptable Object;
cur_dt = cur_analytic_layer << Get Data Table;
If(cur_dt == dt,
Insert Into(valid_reports, cur_analytic_layer);
);
,
show(exception_msg);
);
);
return(valid_reports);
);
// I would use function, but there seem to be some bugs
swap_report_columns = Expr(
Eval(EvalExpr(
nw_switcher = New Window("Switcher", << Window View("Invisible"),
vlb2 = V List Box(
ref_colswitcher2 = dt << Column Switcher(Expr(NameExpr(AsColumn(dt, old_col))),
{Expr(NameExpr(AsColumn(dt, old_col))), Expr(NameExpr(AsColumn(dt, new_col)))}
)
)
);
));
Batch Interactive(1);
For Each({report, idx}, report_list,
//report = report_list[2]
nw1 = New Window("", << Window View("Invisible"),
ref_colswitcher1 = dt << Column Switcher(Expr(NameExpr(AsColumn(dt, old_col))),
{Expr(NameExpr(AsColumn(dt, old_col))), Expr(NameExpr(AsColumn(dt, new_col)))}
)
);
lc = Log Capture(ref_colswitcher1 << Link Platform(report));
ref_colswitcher1 << Remove Column Switcher;
nw1 << Close Window;
If(Is Missing(lc),
Log Capture(
Try(ref_colswitcher2 << Link Platform(report));
);
);
wait(0);
);
Batch Interactive(0);
Try(vlb2[ListBoxBox(1)] << Set Selected(2));
wait(0);
ref_colswitcher2 << Remove Column Switcher;
Caption(remove);
nw_switcher << Close Window;
);
swap_columns = Expr(
nw = New Window("Swap report columns", << Type("Launcher"),
window:dt = Current Data Table(),
H List Box(
Lineup Box(N Col(2),
Panel Box("Select Column to Change",
fcs1 = Filter Col Selector(dt, << Set Max Selected(1))
),
Panel Box("Select New Column",
fcs2 = Filter Col Selector(dt, << Set Max Selected(1))
)
),
Panel Box("Action",
Button Box("Change Columns",
report_list = get_reports_for_datatable(dt);
old_col = (fcs1 << get selected)[1];
new_col = (fcs2 << get selected)[1];
Try(swap_report_columns);
),
Button Box("Cancel",
fcs1 << close window;
),
)
)
);
);
dt = Open("$SAMPLE_DATA/Probe.jmp");
dt << Clear Row States;
dist = dt << Distribution(Continuous Distribution(Column(:DELL_RPNBR)));
dist2 = dt << Distribution(Continuous Distribution(Column(:DELW_M1)));
gb1 = dt << Graph Builder(
Size(528, 448),
Show Control Panel(0),
Variables(X(:Site), Y(:Lot ID)),
Elements(Points(X, Y, Legend(3)))
);
gb2 = dt << Graph Builder(
Size(523, 454),
Show Control Panel(0),
Variables(X(:DELW_M1), Y(:DELL_RPNBR)),
Elements(Points(X, Y, Legend(3)))
);
swap_columns;
Write();