行状态选择和颜色好吧,我已经尝试了各种方法来尝试让它工作,但到目前为止我所得到的只是一个功能上不太可用的脚本。 删除脚本工作得很好,但是虽然行状态脚本工作正常,但它并不完全按照我想要的方式工作,我希望有一种方法可以稍微清理它。
dt << New Column ( "Row State 1",
Row State,
Set Formula ( If( :Alarm ID == "'00000D06", Color State(70))),
);
dt << New Column ( "Row State 2",
Row State,
Set Formula ( If( :Alarm ID == ("'000000B2"| "'000000BE"| "'0000013C"| "'0000013D"),
Color State(6))),
);
dt << New Column ( "Row State 3",
Row State,
Set Formula ( If( :Alarm ID == ("'0000000E"| "'00000144"| "'0000000A"| "'00000021"|
"'00000025"| "'00000027"| "'000000E9"| "'00000145"| "'000001E1"| "'00000F7C"),
Color State(1))),
);
dt << New Column ( "Row State 4",
Row State,
Set Formula ( If( :Alarm ID == "'00000E6E", Color State(38))),
);
dt << New Column ( "Row State 5",
Row State,
Set Formula ( If( :Alarm ID == ("'00000D3B"| "'00000230"| "'00000D42"), Color State(73))),
);
dt << New Column ( "Row State 6",
Row State,
Set Formula ( If( :Alarm ID == ("'0000003B"| "'00000072"| "'00000E8C"), Color State(37))),
);
dt << New Column ( "Row State 7",
Row State,
Set Formula ( If( :Alarm ID == "'00000DB6", Color State(78))),
);
dt << New Column ( "Row State 8",
Row State,
Set Formula ( If( :Alarm ID == "'00000E99", Color State(75))),
);
dt << New Column ( "Row State 9",
Row State,
Set Formula ( If( :Alarm ID == ("'00000E68"| "'00000E71"| "'00000E72"| "'00000E9A"),
Color State(72))),
);
dt << New Column ( "Row State 10",
Row State,
Set Formula ( If( :Alarm ID == ("'0000004E"| "'0000005C"| "'0000011C"| "'00000143"|
"'00000148"| "'000001D9"| "'00000DE9"| "'00000E41"), Color State(12))),
);
dt << New Column ( "Row State 11",
Row State,
Set Formula ( If( :Alarm ID == "'00000D2F", Color State(19))),
);
dt << New Column ( "Row State 12",
Row State,
Set Formula ( If( :Alarm ID == "'00000D2D", Color State(28))),
);
基本上,选择在“警报 ID”列中包含特定值的行,并将行状态设置为所选颜色。 我想要它做的是设置行状态并突出显示行状态的颜色,大概我可以在设置所有行状态后通过附加来做到这一点。
它的作用是,它创建一个行状态但不应用它,我必须手动应用它,它还为每一行创建一个单独的行状态,这很快就会变得混乱,我怀疑我可以使用 else 来至少删除不存在的行,这会有帮助。 看起来具有多个选项的行实际上并没有工作,我希望我能让它工作,这样我就不必为每个代码制作 1 行。
希望有人能帮助我,当我有时间的时候仍然会继续努力,谢谢!
回复:行状态选择和颜色这个效果很好,谢谢! 这个系统的优点之一(有时是诅咒)是有多种不同的方法来解决同一问题。 下一个将非常具有挑战性,我可能会在下周尝试解决它,哈哈(或者它可能非常简单,我只是还不知道!)回复:行状态选择和颜色我认为这对你有用。这假设您还没有颜色状态并且没有任何项目重叠。
Names default to here(1);
dt = open("$SAMPLE_DATA\Big Class.jmp");
color_aa = associative array(
{
// list of values are the first item, color state is the second in each list.
{{12, 13, 16}, 3},
{{14, 15}, 4},
{{17}, 5}
}
);
dt << Select Rows([1, 5, 9]);
rs = dt << Get Row States;
for(values = color_aa << First, !isempty(values), values = color_aa << Next(values),
rows = dt << Get Rows Where(Contains(values, :age));
color = color_aa[values];
rs[rows] = rs[rows] + 2^8*color;
);
dt << Set Row States(rs);
回复:行状态选择和颜色如果您想根据您的选择更改每行的颜色状态,以下部分脚本适用于您要用于进行更改的结构
Names Default To Here( 1 );
dt = Current Data Table();
For( i = 1, i <= N Rows( dt ), i++,
If(
N Rows( Loc( {"'00000D06"}, :Alarm ID[i] ) ) > 0, Row State( i ) = Color State( 70 ),
N Rows( Loc( {"'000000B2", "'000000BE", "'0000013C", "'0000013D"}, :Alarm ID[i] ) ) > 0, Row State( i ) = Color State( 6 ),
N Rows(
Loc(
{"'0000000E", "'00000144", "'0000000A", "'00000021", "'00000025", "'00000027", "'000000E9", "'00000145", "'000001E1", "'00000F7C"},
:Alarm ID[i]
)
) > 0, Row State( i ) = Color State( 1 ),
N Rows( Loc( {"'00000E6E"}, :Alarm ID[i] ) ) > 0, Row State( i ) = Color State( 38 ),
N Rows( Loc( {"'00000D3B", "'00000230", "'00000D42"}, :Alarm ID[i] ) ) > 0, Row State( i ) = Color State( 73 )
)
);回复:行状态选择和颜色显然我也无法让我的公式发挥作用^.^
简而言之,我希望 X 值突出显示一种颜色的行
Y 和 Z 值的行突出显示另一种颜色
ETC...
特定的颜色已经在脚本中,显然是 |或者争论是选择这些的问题,我只是不确定表达它的正确方式。
回复:行状态选择和颜色我可能没有正确理解你的问题。但这是我的最佳猜测。首先,我从来没有打算让你的公式发挥作用。 你不能做 "something" == ("stuff"|"something") 并让它评估为真。至少据我所知。我举了一个我认为你正在尝试做的例子,但我可能离你很远。
Names default to here(1);
dt = open("$SAMPLE_DATA\Big Class.jmp");
// this doesn't work
dt << New Column("Test", formula(:age == (12 | 14 | 16)));
//this should
values = {12, 14, 16};
rows = dt << Get Rows Where(Contains(values, :age));
//assuming they don't have color
dt << Select Rows([1, 5, 9]);
wait(1);
rs = dt << Get Row States;
//2^8*3 = color state(3) = red
rs[rows] = rs[rows] + 2^8*3;
dt << Set Row States(rs);