CIAO,
Sto cercando di sostituire tutte le celle difettose nella tabella dati allegata, che è evidenziata in rosso con 1 e le celle passanti con 0.

Ho trovato questo ma qualcosa non funziona-
Come si ottiene il colore di una cella specifica in una tabella dati utilizzando JSL?
C'è un modo migliore per sostituire i valori della cella?
Ecco cosa ho provato
Names Default To Here( 1 );
dt = Current Data Table();
cols = dt << get column group( "Tests" );
get_cell_color = Function( {col, r},
s = col << get script;
//Locate argument "Color Cells" in column script
For( i = 1, i <= N Arg( s ), i++,
If( Head Name( Arg( s, i ) ) == "Color Cells",
p = i;
Break();
)
);
//Identify the sublist that contains the color of row r
L = Arg( Arg( s, p ), 1 );
For( i = 1, N Items( L ), i++,
If( N Row( Loc( L[i][2], r ) ) == 1,
color = L[i][1];
Break();
)
);
color;
);
//
test_cols = Transform Each( {col}, cols, col << get name );
dt << Select All Rows;
selrow = dt << get Selected Rows();
dt << begin data update;
For Each( {testcol, idx}, test_cols,
For Each( {ro, idx2}, selrow,
cellcolor = get_cell_color( Column( testcol ), ro );
If( !cellcolor == 3,
Column( testcol )[ro] = 0
)
;
)
);
dt << end data update;Grazie,
Come ottenere il numero di riga di celle colorate in una colonna e assegnargli un tag (ad esempio "1") in una colonna appena creata? potrebbe fornire altri suggerimenti. Con una piccola modifica a create_failed_column_after (dovresti anche rinominarlo) puoi far sì che aggiorni i valori invece di creare una nuova colonna con i valori.
Questo è un modo in cui puoi modificare lo script trovato da quel post
Visualizza altro...
Names Default To Here(1);
get_colored_cells = Function({dt, colname}, {Default Local},
colscript = Column(dt, colname) << Get Script;
l = Substitute(Name Expr(colscript), Expr(New Column()), List());
colored_cells = {};
Try(
colors = l["Color Cells"];
If(Type(colors[1]) == "List",
jmptrickery = 1,
jmptrickery = 0
);
For Each({color}, colors,
If(jmptrickery,
Insert Into(colored_cells, color[2]),
Insert Into(colored_cells, color)
)
);
);
Return(Matrix(colored_cells));
);
colored_to_pass_fail = function({dt, colname}, {Default Local},
failed_rows = get_colored_cells(dt, colname);
row_vals = J(1, N Rows(dt), 0);
row_vals[failed_rows] = 1;
Column(dt, colname) << set values(row_vals);
// dt[0, colname] = row_vals`; // or data table subscripting
);
dt = Open("$SAMPLE_DATA/Big Class.jmp");
wait(1);
dt << Select Rows([4,5,6,7, 10,11, 14, 15]);
:height << Color Cells(3);
dt << clear select;
wait(1);
dt << Begin Data Update;
For Each({colname}, dt << Get Column Names("String", Continuous),
colored_to_pass_fail(dt, colname);
);
dt << End Data Update;
wait(0);