使用“for every row”和嵌套“for”循環的條件格式(顏色)問題你好,
我正處於腳本的末尾,我在其中總結了各個列(數字和字符)中的一堆數據。
循環格式化滿足特定條件的數字單元格非常簡單,但我在為包含特定子字符串的字符列分配顏色時遇到一些問題。
例如,單元格(具有以下內容:1,1,2,1,1,2,3,3)應為紅色,因為它包含 1 次出現的字符“3”。
如果我指定單元格的全部內容,沒問題,但我嘗試查找“3”並相應地著色 - >失敗。
我添加了下面的腳本。
任何建議,將不勝感激。
最好的,
塞巴斯蒂安
Names Default To Here( 1 );
clear log();
dt = New Table( "test",
Add Rows( 8 ),
New Column( "unique_group_id",
Character,
"Nominal",
Set Values(
{"ELN-19-0588-A", "ELN-19-0588-B", "ELN-19-0588-C", "ELN-19-0588-D",
"ELN-19-0588-E", "ELN-19-0588-F", "ELN-19-0588-G", "ELN-19-0588-H"}
),
Set Display Width( 115 )
),
New Column( "FOB max",
Character,
"Nominal",
Set Selected,
Set Values(
{"0,0,0,0,0,0,0,0,0,0", "0,0,0,0,0,0,0,0", "0,0,0,0,0,0,0,0",
"0,0,3,0,0,1,0,2", "1,1,2,1,1,2,3,3", "0,0,0,0,0,0,0,0",
"4,2,2,3,2,3,3,4", "1,0,0,1,1,1,1,1"}
)
),
New Column( "glib1 % PBS - potatoe",
Numeric,
"Ordinal",
Format( "Best", 12 ),
Set Selected,
Set Values( [100, 113.39, 108.3, 156.38, 822.21, 768.51, 487.2, 222.56] )
),
New Column( "calb (IHC) cere",
Character,
"Nominal",
Set Values(
{"0,0,0,0,0,0,0,0,0,0", "0,0,0,0,0,0,0,0", "0,0,0,0,0,0,0,0",
"0,0,0,0,0,0,0,0", "3,4,3,4,3,3,3,4", "3,3,3,5,2,3,3,3",
"0,0,0,0,0,0,0,0", "0,0,0,0,0,0,1,0"}
)
)
);
wait(2);
col=dt <<GET column="" names="">200,
column(col[i]) << color cells( "Light Red", Row())
)
)));
//Does not work - it needs to be an exact match
c="FOB";
b={"3"};//trying to look for cells in columns labelled with FOB whihc contains the character '3'
For(i=1,i<=nc,i++, if( Contains( col[i], c ),
for each row(
If( contains(b,as column(col[i])),
column(col[i])<< color cells( "Light Red", Row())
)
)));
wait (2);
//Works when specifying exactly the content of the cell(s) to match
c="FOB";
b={"1,1,2,1,1,2,3,3"};
For(i=1,i<=nc,i++, if( Contains( col[i], c ),
for each row(
If( contains(b,as column(col[i])),
column(col[i])<< color cells( "Red", Row())
)
)));
</GET>自動化和腳本編寫消費者和市場研究內容組織大規模定制質量和工藝工程回复:使用“for every row”和嵌套“for”循環的條件格式(顏色)問題謝謝!回复:使用“for every row”和嵌套“for”循環的條件格式(顏色)問題你好,
更改您的代碼以匹配下面代碼中的第 67 行。
包含 () 允許您執行一些不同的操作,具體取決於您提供的參數。 例如:
Contains ( {"cat", "dog", "mouse", "dog", "horse"}, "dog" ) 返回 2,因為提供的列表中第一次出現的“dog”位於位置 2。
Contains ({"cattle", "dog", "mouse"}, "cat") 返回 0,因為列表中沒有出現“cat”。 如果我們想逐個元素搜索列表以查看“cat”是否是任何元素的子字符串,我們必須迭代列表。
您的原始代碼有點像最後一個示例:Contains (b, :col) 檢查列單元格值是否與 b 中您定義為 {"3"} 的任何元素匹配。 未找到匹配項。
相反,新代碼 Contains(:col, b[1]) 檢查列單元格值中是否包含列表 b 的第一個元素“3”b[1]。 使用這種方式, Contains (<>, <>) 函數在字符串 <> 中查找子字符串 <> - 我相信這就是您想要的。
乾杯,
布雷迪
包含 ({"cat", "dog", "mouse"}, "cat") 返回

回复:使用“for every row”和嵌套“for”循環的條件格式(顏色)問題您向後指定了 Contains() 函數,並且進行了 JMP 列表的比較。修復這些問題就可以正常工作了。

Names Default To Here( 1 );
clear log();
dt = New Table( "test",
Add Rows( 8 ),
New Column( "unique_group_id",
Character,
"Nominal",
Set Values(
{"ELN-19-0588-A", "ELN-19-0588-B", "ELN-19-0588-C", "ELN-19-0588-D",
"ELN-19-0588-E", "ELN-19-0588-F", "ELN-19-0588-G", "ELN-19-0588-H"}
),
Set Display Width( 115 )
),
New Column( "FOB max",
Character,
"Nominal",
Set Selected,
Set Values(
{"0,0,0,0,0,0,0,0,0,0", "0,0,0,0,0,0,0,0", "0,0,0,0,0,0,0,0",
"0,0,3,0,0,1,0,2", "1,1,2,1,1,2,3,3", "0,0,0,0,0,0,0,0",
"4,2,2,3,2,3,3,4", "1,0,0,1,1,1,1,1"}
)
),
New Column( "glib1 % PBS - potatoe",
Numeric,
"Ordinal",
Format( "Best", 12 ),
Set Selected,
Set Values( [100, 113.39, 108.3, 156.38, 822.21, 768.51, 487.2, 222.56] )
),
New Column( "calb (IHC) cere",
Character,
"Nominal",
Set Values(
{"0,0,0,0,0,0,0,0,0,0", "0,0,0,0,0,0,0,0", "0,0,0,0,0,0,0,0",
"0,0,0,0,0,0,0,0", "3,4,3,4,3,3,3,4", "3,3,3,5,2,3,3,3",
"0,0,0,0,0,0,0,0", "0,0,0,0,0,0,1,0"}
)
)
);
wait(2);
col=dt <<GET column="" names="">200,
column(col[i]) << color cells( "Light Red", Row())
)
)));
//Does not work - it needs to be an exact match
c = "FOB";
b = "3";//trying to look for cells in columns labelled with FOB whihc contains the character '3'
For( i = 1, i <= nc, i++,
If( Contains( col[i], c ),
For Each Row(
If( Contains( As Column( col[i] ), b ),
Column( col[i] ) << color cells( "Light Red", Row() )
);
)
)
);
wait (2);
//Works when specifying exactly the content of the cell(s) to match
c = "FOB";
b = "1,1,2,1,1,2,3,3";
For( i = 1, i <= nc, i++,
If( Contains( col[i], c ),
For Each Row(
If( Contains( As Column( col[i] ), b ),
Column( col[i] ) << color cells( "Red", Row() )
)
)
)
);</GET>