用于检查单个单元格值是否在列表中的 JSL 脚本给定一个包含有限值列的数据表(参见下面的示例),我想编写一个脚本来查看第一个单元格并检查它是否在值列表中。 目的是使用第一个值作为 IF 语句的条件,然后该语句将指向一组特定的任务。
有人知道如何做到这一点吗?
谢谢
例如
或者
回复:JSL 脚本检查单个单元格值是否在列表中谢谢@pmroz和@tx尼尔森以获得脚本帮助。 更具体地说,我正在寻找的是使用检查第一个单元格的值是否在列表中作为 if 语句的条件,该语句将驱动一些其他操作。 我认为你的两个脚本都填充了另一个数组,但它们不是严格的 T/F。 我会尝试使用它们并让您知道会发生什么。
回复:JSL 脚本检查单个单元格值是否在列表中这可能会有所帮助:
dt = New Table( "test", Add Rows( 5 ),
New Column( "CAT", Character, "Nominal",
Set Values( {"A", "B", "C", "D", "E"} ) ),
New Column( "time", Numeric, "Continuous", Format( "Best", 12 ),
Set Values( [1, 2, 3, 4, 5] ) )
);
look_for_list = {"B", "D"};
found_rows = dt << get rows where(contains(look_for_list, as column(dt, "CAT")));
print(found_rows);
[2, 4]
回复:JSL 脚本检查单个单元格值是否在列表中我不确定您到底要什么,但是,下面的脚本可能会为您指明正确的方向
Names Default To Here( 1 );
dt = Open( "$SAMPLE_DATA/big class.jmp" );
theList = {59, 66};
For( i = 1, i <= N Rows( dt ), i++,
If( N Rows( Loc( theList, :height[i] ) ) > 0,
Show( i )
)
);回复:JSL 脚本检查单个单元格值是否在列表中偶然发现了这个帖子,想找一些类似的方法,用于在测试代码时关闭残留打开的数据表。我用了你上面的简单代码。想发一下,希望对看到这个帖子的人有用:
// list of table names that I want to make sure are closed before running the script
tname = { "TABLE1", "TABLE2", "TABLE3", "TABLE4" };
// loop to see if open tables match the name in the list above, then close them
// need to restart the i counter to i = 0 because it seems closing a table changes the 'i' number associated with the table
For( i = 1, i <= N Table(), i++,
If( N Rows (Loc( tname, Data Table(i) << Get Name ) ) > 0,
Close(Data Table(i), no save);
i = 0;
)
);