- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Get Direct Link
- Report Inappropriate Content
Suppress Eval all column formula
I was trying to use the script below to suppress eval or allow eval for all column formula in the table. For some reason, I kept getting an error (see snapshot) on the third time running the script but I can't particularly find the bug. Appreciate the community help in debugging this.
names default to here(1);
dt = current data table();
try(formula_suppress = dt:Formula_Suppress,
dt << set table variable("Formula_Suppress",1);
formula_suppress = 1;
);
wait(0.5);
formula_suppress = abs(formula_suppress - 1);
dt << set table variable("Formula_Suppress",formula_suppress);
//show(formula_suppres);
for(i=1,i<=ncol(dt),i++,
as column(dt,i) << suppress eval(formula_suppress)
);
if(formula_suppress == 1,
status = "Suppressed",
status = "Evaluated"
);
NewWindow("Alert",
showToolbars(0),showMenu(0),BorderBox(top(15),bottom(15),left(15),right(15),
VListBox(
TextBox("Formulas in the table are " || char(status),<<setFontStyle("bold"),<<fontcolor("red")),
SpacerBox(size(0,15)),
HCenterBox(ButtonBox(" close ",current window()<<close window ))
)
)
);
1 ACCEPTED SOLUTION
Accepted Solutions
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Get Direct Link
- Report Inappropriate Content
Re: Suppress Eval all column formula
The syntax error that was causing the failure was because the
formula_suppress = dt:Formula_Suppress,
was not returning what you were expecting. Below is a rework of the code that returns properly when the Table Variable does not exist
names default to here(1);
dt = current data table();
if(try(isempty(dt:Formula_Suppress),1) == 1,
dt << set table variable("Formula_Suppress",1);
formula_suppress = 1;
);
wait(0.5);
formula_suppress = abs(formula_suppress - 1);
dt << set table variable("Formula_Suppress",formula_suppress);
//show(formula_suppres);
for(i=1,i<=ncol(dt),i++,
as column(dt,i) << suppress eval(formula_suppress)
);
if(formula_suppress == 1,
status = "Suppressed",
status = "Evaluated"
);
NewWindow("Alert",
showToolbars(0),showMenu(0),BorderBox(top(15),bottom(15),left(15),right(15),
VListBox(
TextBox("Formulas in the table are " || char(status),<<setFontStyle("bold"),<<fontcolor("red")),
SpacerBox(size(0,15)),
HCenterBox(ButtonBox(" close ",current window()<<close window ))
)
)
);
Jim
1 REPLY 1
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Get Direct Link
- Report Inappropriate Content
Re: Suppress Eval all column formula
The syntax error that was causing the failure was because the
formula_suppress = dt:Formula_Suppress,
was not returning what you were expecting. Below is a rework of the code that returns properly when the Table Variable does not exist
names default to here(1);
dt = current data table();
if(try(isempty(dt:Formula_Suppress),1) == 1,
dt << set table variable("Formula_Suppress",1);
formula_suppress = 1;
);
wait(0.5);
formula_suppress = abs(formula_suppress - 1);
dt << set table variable("Formula_Suppress",formula_suppress);
//show(formula_suppres);
for(i=1,i<=ncol(dt),i++,
as column(dt,i) << suppress eval(formula_suppress)
);
if(formula_suppress == 1,
status = "Suppressed",
status = "Evaluated"
);
NewWindow("Alert",
showToolbars(0),showMenu(0),BorderBox(top(15),bottom(15),left(15),right(15),
VListBox(
TextBox("Formulas in the table are " || char(status),<<setFontStyle("bold"),<<fontcolor("red")),
SpacerBox(size(0,15)),
HCenterBox(ButtonBox(" close ",current window()<<close window ))
)
)
);
Jim