I did post other findings regarding behavior of column switcher in some of the platforms to the original add-in discussion. Here is the script I did add there, which attempts to tackle some of the issues, but I haven't really tested it
Names Default To Here(1);
report_windows = Get Window List(Type("Reports")) << Get Window Title();
If(N Items(report_windows) == 0,
Throw("No report windows open");
);
nw = New Window("Select a Report", <<Modal, << return result,
hb = H List Box(
Panel Box("Select a report window",
lb = List Box(report_windows, Max Selected(1))
),
Panel Box("Actions",
Lineup Box(N Col(1),
Button Box("OK"),
Button Box("Cancel")
)
)
)
);
If(nw["Button"] != 1,
stop();
);
selected_window = Window(nw["lb"][1]);
obs_platform = (selected_window << XPath("//OutlineBox[@helpKey]"));
report = Empty();
For Each({ob_platform}, obs_platform << Get Scriptable Object,
// Three checks
If(Is Scriptable(ob_platform),
If((ob_platform << window class name) == "Report",
report = ob_platform;
);
)
);
If(IsEmpty(report),
Throw("No report found from report window");
);
dt = report << Get Data Table();
nw = New Window("Col Selections", << modal, << return result,
H List Box(
Panel Box("Select Colums",
fcs = Filter Col Selector(Datatable(dt))
),
Panel Box("Cast Columns",
Lineup Box(N Col(2),
Button Box("Y", << Set Function(function({this}, (this << sib) << append(fcs << get selected)))),
clb = Col List Box(Datatable(dt), Min Items(1))
)
),
Panel Box("Actions",
Lineup Box(N Col(1),
Button Box("OK",
cols = clb << get items;
),
Button Box("Cancel")
)
)
)
);
If(nw["Button"] != 1,
stop();
);
If(N Items(cols) < 1,
Throw("No columns selected"); // Should be moved to validator
);
save_path = Pick Directory("Select a directory");
new_report = report << Redo Analysis;
new_report << Show Window(0);
yexpr = Eval(EvalExpr(
Extract Expr(Expr(new_report << get script), Y(Wild())
)));
If(Is Empty(yexpr),
yexpr = Eval(EvalExpr(
Extract Expr(Expr(new_report << get script), Column(Wild())
)));
);
ycol = Arg(yexpr, 1);
ycolname = ycol << get name;
wait(0);
col_switcher = new_report << Column Switcher(ycolname, cols);
ncols = Length(col_switcher << Get List);
jrn = New Window("Reports", << Journal);
For(i = 1, i <= ncols, i++,
newrep = new_report << Report;
newrep << Show Window(0);
jrn << Append(newrep);
col_switcher << Next;
);
new_report << Remove Column Switcher;
jrn << Set page setup(margins(0.5, 0.5, 0.5, 0.5), scale(.7), portrait(0), paper size("Letter"));
jrn << save pdf(save_path || (selected_window << get window title) || "_report.pdf", Portrait(0));
jrn << Close Window;
new_report << Close Window;
wait(0);
Open(save_path);
Write();
-Jarmo