This may be a really simple question but after a lot of searching and testing I can't figure it out. How do I get the column number for a given column if all i know is the column name from a column dialog box?
Minimized code:
dlg = Column Dialog( dlg_firstParam = ColList( "First Parameter"));
firstParam = dlg["dlg_firstParam"][1];
i = 5; // this is a test case. Assume i am going to select the fifth column in the dialog above. If this works, I would write a loop for i = 1 to ncol() and test Column Name ( i ) against the first parameter name... but it doesn't work.
show(column(i)); // returns: Column("Date");
show(firstParam); // returns: :Date;
show(columnName(i)); //returns: Date;
//Ok, so given the above two lines, i think I should be able to strip out the colon at the beginning of the string in :Date; and compare to Date; as below. Almost looks like it will work...
a = parse(right(expr(firstParam),length(expr(firstParam))));
show (a); // Returns: Date;
// Ok, so the colon gets stripped out.
if(columnName(i)==a,b = 1, columnName(i)!=a, b = 0);
show (b); // returns 0
//////////////////
The above code is a test to see if i can loop through and test if column name ( i ) = a function of firstParam. Looks like it should work, but doesn't. Any ideas?
The preferred method would be to just return the column number directly. If you can help me with that I would appreciate it.
(Edit: Just a note to change the last variable in your code from colnumber to some non-JMP keyword. colnumber is reserved. Otherwise works fine.)