cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
Try the Materials Informatics Toolkit, which is designed to easily handle SMILES data. This and other helpful add-ins are available in the JMP® Marketplace
Choose Language Hide Translation Bar
KinKame
Level IV

loop for and if for column name change

all,

I would like to rename column name depending on some condition using a for loop with a if conditional.

But doesn't work.

If I set up the function out of the for loop then no issue.

code as below

For( i = 1, i <= 100, i++,

  If(i > 0 ,

  Column(i) << set name( char(munger(Column name(i), 1, "::try::", "-" ) ) ) );

);

4 REPLIES 4
txnelson
Super User

Re: loop for and if for column name change

The Column Name() function returns an expression, not a literal string.  So if you use:

    Column(i) << set name( char(munger(char(Column name(i)), 1, "::try::", "-" ) ) ) );

it should work

Jim
KinKame
Level IV

Re: loop for and if for column name change

hello Jim,

yes it works.

thank you very much for the code correction and also object property explanation. Very interesting.

Re: loop for and if for column name change

You might have a look at xan@jmp 's  Column Name Utility add-in for some tips on how to do this.

If you download the add-in and change the file suffix to .zip,  you can unzip it and see what he's doing.

Best,

M

KinKame
Level IV

Re: loop for and if for column name change

Hello Michael,

thank you for the resource. It seems good to me but preferable to use  script and not add on.

but good for learning thank you!!