Sélecteur de colonnes appliqué à tous les rapports ouvertsSalut les gars,
J'essaie d'écrire un script pour appliquer le sélecteur de colonnes à tous les rapports ouverts. Guidez-moi s'il-vous-plaît
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",
<Veuillez indiquer comment effectuer cette action. Merci d'avanceAutomatisation et scripts
Re : Sélecteur de colonnes appliqué à tous les rapports ouvertsComment souhaitez-vous utiliser Col List Box ? Column Switcher nécessite que vous ayez une seule colonne qui est ensuite remplacée par une autre colonne (en fonction de la liste des colonnes sur Column Switcher) et cette colonne doit être la même dans tous les rapports au début.
Re : Sélecteur de colonnes appliqué à tous les rapports ouverts@jthi , mon mauvais, je suis désolé .. Je suppose qu'au lieu d'un sélecteur de colonnes, il est plus facile d'avoir 2 colList Box où l'utilisateur sélectionne la colonne à remplacer en 1er et la colonne à remplacer par en 2ème.. Cette approche est-elle plus appropriée
Re : Sélecteur de colonnes appliqué à tous les rapports ouvertsJe pense que cela pourrait être un peu plus facile. Je n'ai pas le temps d'écrire une solution appropriée, mais vous trouverez ci-dessous une idée de la façon dont j'aborderais cela (utilisez le sélecteur de colonnes pour modifier les colonnes que vous créez lors de l'appel de fonction + "Demander pardon, pas autorisation"). Il contient encore des éléments codés en dur, mais j'y reviendrai plus tard dans la journée ou demain et le rendrai plus robuste car il s'agit d'un problème intéressant.
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 : Sélecteur de colonnes appliqué à tous les rapports ouvertsIl semble y avoir peu de bugs/interactions étranges qui rendent cela plus difficile que je ne le pensais et à cause de cela, le code est très compliqué, mais il semble fonctionner à un certain niveau.
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();