Hi there,
Maybe you can help me figure out what I am doing wrong here.
I have the following toy data table:

I have been having some trouble with refining a list of character column names becoming from the following script.
//get unique column names
cols = Current Data Table() << getColumnNames(Character);
//del columns I don't want
DELCOLS = {"Column 5", "Column 6"};
unique_col_names = Associative Array(cols) << Remove(Associative Array(DELCOLS)) << get keys;
//make a pop-up window
nw = New Window( "Set a Value",
<<MODAL></MODAL>
What I am getting is the following in the resulting modal pop-up window.

I want the following pop-up window only to have the following:

I think my problem may have to do with a gap in my knowledge of associative arrays that I am having some trouble understanding completely, even though what the JMP scripting guide says about associative array keys and the remove from, remove, loc, and contains functions make sense.
I want to make sure that the columns that are left in the resulting list that I used in the model window can be renamed by the user in the original dataset, so the column names that I want to remove will stay the same. Also, the arrangement of the columns in the data table is the same, but the associative array rearranges the values in ascending order.
I used the following methods already, according to these forums, and there must be something that I am not seeing here because I am new to the JSL language.
- removing elements from a list remove elements in a list
- getting the column name from the column number and inputting the columns I selected into a list to be used. How to get column number from column name? (JMP)
I have attached the toy dataset file which includes the script that I have referenced above.
Thanks so much! It worked great in my project and I learned what the Try() function is too.
Here is the way I would solve this issue
Names Default To Here( 1 );
//get unique column names
cols = Current Data Table() << getColumnNames( Character, string );
//del columns I don't want
DELCOLS = {"Column 5", "Column 6"};
For( i = 1, i <= N Items( DELCOLS ), i++,
Try( Remove From( cols, Contains( cols, DELCOLS[i] ) ) )
);
unique_col_names = cols;
//make a pop-up window
nw = New Window( "Set a Value",
<<MODAL></MODAL>