안녕,
첨부된 데이터 테이블에서 실패한 셀을 모두 바꾸려고 합니다. 빨간색으로 1 로 강조표시되고 통과하는 셀은 0으로 표시됩니다.

이것을 찾았지만 뭔가 작동하지 않습니다.
JSL을 사용하여 데이터 테이블의 특정 셀 색상을 어떻게 얻습니까?
셀 값을 바꾸는 더 좋은 방법이 있습니까?
내가 시도한 것은 다음과 같습니다.
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;감사해요,
열에서 색상이 지정된 셀의 행 번호를 가져오고 새로 생성된 열에 태그(예: "1")를 할당하는 방법은 무엇입니까? 다른 제안을 제공할 수도 있습니다. create_failed_column_after 를 약간 수정하면(이름도 바꿔야 함) 값으로 새 열을 생성하는 대신 값을 업데이트하도록 할 수 있습니다.
이는 해당 게시물에서 찾은 스크립트를 수정하는 방법 중 하나입니다.
더보기...
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);