Le prime 6 righe dello script seguente funzionano come previsto, con l'output copiato di seguito.
Poi ho provato a memorizzare i valori di queste variabili in un elenco, cosa che non è andata bene. Sembra che siano stati memorizzati i nomi delle variabili invece dei valori. Come posso memorizzare i valori delle variabili nell'elenco? Grazie!
dt = new table("my table", new column("X", set values({-0.35, 0.15, 0.3}) ) );
dt << new column("Y", set values({300, 250, 200}) );
xmean = col mean (:X);
ymax = col max(:Y);
ymin = col min(:Y);
print (xmean, ymax, ymin);
dtsum = {xmean, ymax, ymin};
print (dtsum);
if (dtsum[1] < 0, print (dtsum[2]), print(dtsum[3]));
Uscite:
0.0333333333333333
300
200
{xmean, ymax, ymin}
.
Utilizzare Eval List() per valutare l'elenco ( Guida allo scripting > Strutture dati > Elenchi negli script JSL > Valuta elenchi )
Names Default To Here(1);
dt = New Table("my table", New Column("X", set values({-0.35, 0.15, 0.3})));
dt << New Column("Y", set values({300, 250, 200}));
xmean = Col Mean(:X);
ymax = Col Max(:Y);
ymin = Col Min(:Y);
Print(xmean, ymax, ymin);
dtsum = Eval List({xmean, ymax, ymin});
Print(dtsum);
If(dtsum[1] < 0,
Print(dtsum[2]),
Print(dtsum[3])
);