cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Discussions

Solve problems, and share tips and tricks with other JMP users.
Choose Language Hide Translation Bar
scott1588
Level IV

More Efficient Code for Assigning Tags to Multiple Columns

I have the following JSL code for assigning tags to a group of columns...

 

t1 = "Contaminants";
dt5 << Define Tag( t1, Color("Light Red") );
Data Table(dt5):CH4.ppm. <<
Set Property( Tags, {"Contaminants"} ),;
Data Table( dt5 ):CO2.ppm. <<
Set Property( Tags, {"Contaminants"} );
Data Table( dt5 ):H2O.per. <<
Set Property( Tags, {"Contaminants"} );
Data Table( dt5 ):CO.ppm. <<
Set Property( Tags, {"Contaminants"} );
Data Table( dt5 ):O3.ppb. <<
Set Property( Tags, {"Contaminants"} );
Data Table( dt5 ):NO2.ppb. <<
Set Property( Tags, {"Contaminants"} );
Data Table( dt5 ):NO.ppb. <<
Set Property( Tags, {"Contaminants"} );

It works fine but I'm wondering if there is a way to make this more efficient by eliminating the duplicate Data Table/Set Property functions. Is there a way to define a list of columns in the original Data Table command? I have tried defining a list with curly braces, parentheses, both curly braces and parentheses, with colons, without colons, etc, etc and I can't seem to hit on the right syntax. The scripting index doesn't seem to help here.

 

Also, I would like to define the name of the tag as a variable (t1). This seems to work for the Define Tag function but I can't seem to get it to work for the multiple Set Property functions.

 

Does anyone have insight here as to what I'm missing?

 

Thanks much.

2 ACCEPTED SOLUTIONS

Accepted Solutions
lwencx
Level II

Re: More Efficient Code for Assigning Tags to Multiple Columns

t1 = "Contaminants";
dt5 << Define Tag(t1, Color("Light Red"));

columns = {"CH4.ppm", "CO2.ppm", "H2O.per", "CO.ppm", "O3.ppb", "NO2.ppb", "NO.ppb"};

For Each(col, columns,
    Data Table(dt5) << Column(col) << Set Property("Tags", {t1});
);

View solution in original post

mmarchandFSLR
Level VI

Re: More Efficient Code for Assigning Tags to Multiple Columns

You can send the <<Set Property message to a list of columns.  Remember to evaluate the list inside of the message, or the "Tags" property will be {t1}.

 

-edit

 

Was not paying attention earlier.  There's no <<Define Tag message, unless that's a JMP Pro thing.  Where did this come from?

 

Names Default To Here( 1 );
t1 = "Contaminants";
dt5 << Define Tag( t1, Color( "Light Red" ) );  //Unknown message
cols = dt5 << Get Column Reference( {"CH4.ppm", "CO2.ppm", "H2O.per", "CO.ppm", "O3.ppb", "NO2.ppb", "NO.ppb"} );
cols << Set Property( "Tags", Eval List( {t1} ) );

 

View solution in original post

3 REPLIES 3
lwencx
Level II

Re: More Efficient Code for Assigning Tags to Multiple Columns

t1 = "Contaminants";
dt5 << Define Tag(t1, Color("Light Red"));

columns = {"CH4.ppm", "CO2.ppm", "H2O.per", "CO.ppm", "O3.ppb", "NO2.ppb", "NO.ppb"};

For Each(col, columns,
    Data Table(dt5) << Column(col) << Set Property("Tags", {t1});
);
mmarchandFSLR
Level VI

Re: More Efficient Code for Assigning Tags to Multiple Columns

You can send the <<Set Property message to a list of columns.  Remember to evaluate the list inside of the message, or the "Tags" property will be {t1}.

 

-edit

 

Was not paying attention earlier.  There's no <<Define Tag message, unless that's a JMP Pro thing.  Where did this come from?

 

Names Default To Here( 1 );
t1 = "Contaminants";
dt5 << Define Tag( t1, Color( "Light Red" ) );  //Unknown message
cols = dt5 << Get Column Reference( {"CH4.ppm", "CO2.ppm", "H2O.per", "CO.ppm", "O3.ppb", "NO2.ppb", "NO.ppb"} );
cols << Set Property( "Tags", Eval List( {t1} ) );

 

mmarchandFSLR
Level VI

Re: More Efficient Code for Assigning Tags to Multiple Columns

Oh, tags are a JMP 19 addition!  Nice.  Can't wait until my company lets us upgrade.

Recommended Articles