First thing I'd say is that this is an XY Problem. But to answer the question of how do you make a flag check a dynamic number of columns, I would build the formula outside of the formula itself.
names default to here(1);
dt = New Table( "Test",
Add Rows( 5 ),
Set Header Height( 46 ),
New Column( "System",
Character,
"Nominal",
Set Values( {"F_T_F_S", "F_T_F_R", "F_T_F_T", "F_T_F_U", "F_T_F_V"} )
),
New Column( "01/09/2019",
Numeric,
"Continuous",
Format( "Best", 12 ),
Set Values( [500, 450, 900, 358, 500] )
),
New Column( "01/10/2019",
Numeric,
"Continuous",
Format( "Best", 12 ),
Set Values( [666, 120, 280, 852, 456] )
),
New Column( "01/11/2019",
Numeric,
"Continuous",
Format( "Best", 12 ),
Set Values( [520, 500, 450, 520, 520] )
),
New Column( "01/12/2019",
Numeric,
"Continuous",
Format( "Best", 12 ),
Set Values( [450, 666, 120, 450, 450] )
),
New Column( "LSL",
Numeric,
"Continuous",
Format( "Best", 12 ),
Set Values( [500, 800, 800, 0, 0] )
),
New Column( "USL",
Numeric,
"Continuous",
Format( "Best", 12 ),
Set Values( [980, 1100, 1100, 3700, 3700] )
)
);
//build the formula outside of the formula itself
ANDExpr = Expr(AND()); // we're going to throw all relavent columns into this AND Expression
for(i=2, i<=5, i++,
col = Column(i);
insert into(ANDExpr,
EvalExpr(:LSL < Expr(col)[] < :USL) // for each column check that it's between LSL & USL
);
);
f = EvalExpr(
if(Expr(nameexpr(ANDExpr)),
"Pass",
"Fail"
)
);
show(nameexpr(f));
Eval(EvalExpr(dt << New Column("Flag", formula(Expr(nameexpr(f)))) ));
You could also do a list of names instead of numbers.