CIAO,
Ho un problema con la sceneggiatura.
Ottengo una colonna vuota quando provo a usare il ciclo.
Quando non uso un loop, funziona.
col = dt << get column names;
For(i = 1, i <= N Items(col), i++,
c = "c" || Char(i);
Eval(Parse(Eval Insert("^c^= column(dt,i)<<GET values=""></GET>New Column( "Flag",<BR /> Character,<BR /> Nominal,<BR /> Formula(for(i=1,i<3,i++,<BR /> if(c2[i]>:LSL[i],"Pass","Failed"))));<BR />
La prima cosa che direi è che questo è un Problema XY . Ma per rispondere alla domanda su come si fa a controllare un flag un numero dinamico di colonne, costruirei la formula al di fuori della formula stessa.
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)))) ));
Potresti anche fare un elenco di nomi invece di numeri.
Grazie per la tua risposta.
* Secondo il tuo script, non funziona così bene - ottengo la stessa risposta ogni riga, perché stai stampando dopo il ciclo.
* Per quanto riguarda il grosso problema -
Cosa proponi di fare?
Devo controllare che ogni riga (a tutte le colonne) tra LSL e USL - Ma il problema è che il nome delle colonne cambia continuamente.

Sospetto che il tuo passaggio/fallimento non venga restituito come ultimo valore calcolato.La seguente modifica potrebbe risolvere il tuo problema.
col = dt << get column names;
For( i = 1, i <= N Items( col ), i++,
c = "c" || Char( i );
Eval( Parse( Eval Insert( "^c^= column(dt,i)<<GET values=""> :LSL[i],
x = "Pass",
x = "Failed"
)
);
x;
)
);</GET>
Tuttavia, hai un problema più grande. La tua formula si basa sull'avere una variabile di memoria chiamata "c2" affinché funzioni.Se modifichi o elimini il valore di quella variabile, la formula utilizzerà il valore modificato per calcolare la formula o, se è stato eliminato, la formula non funzionerà più.