通常情况下,我使用标签时只想将其添加到列中。但是,像这样添加标签……
dtTag:my_column << Set Property( Tags, {"New Tag"} );
……会覆盖列中已有的所有标签。有没有办法在 JSL 中轻松添加标签,同时又不删除任何现有标签?我可以先获取列标签,然后修改要分配的标签列表,但我想知道是否有更简单的方法。
我找不到任何可以直接添加标签的内置方法。我打算为此定义一个函数。
Names Default To Here( 1 );
add_tag = Function( {col, tag_name, this_dt = Current Data Table()},
og_tags = Column( this_dt, col ) << Get Property( "Tags" );
Column( this_dt, col ) << Set Property( "Tags", Eval( If( Is Empty( og_tags ), {}, og_tags ) || Eval List( {tag_name} ) ) );
);
//demo
dt = Open( "$SAMPLE_DATA/Big Class.jmp" );
add_tag( "name", "cheeses", dt );
Wait( 1 );
add_tag( "name", "weirdness" );
Show( dt:name << Get Property( "Tags" ) ); //dt:name << Get Property("Tags") = {"cheeses", "weirdness"};
<BR />