I'm fairly new to the For Each() function, so bear with me. The script below does what I need, except that I'd like to restrict the columns it acts on. I'd like to act on columns 3 and above only? Straightforward enough with a For() function, not sure how it works here?
For Each({colnames, index}, dt << Get Column Names("String"),
rows_to_color = dt << Get Rows Where((Column(dt, colnames)[]<100));
Column(dt, colnames) << Color Cells("Red", rows_to_color);
);
Remove the values from the list before you start going over it
Names Default To Here(1);
dt = open("$SAMPLE_DATA/Big Class.jmp");
collist = dt << Get Column Names("String");
Remove From(collist, 1, 3);
show(collist);
For Each({colnames, index}, collist,
rows_to_color = dt << Get Rows Where((Column(dt, colnames)[] < 100));
Column(dt, colnames) << Color Cells("Red", rows_to_color);
);
Remove the values from the list before you start going over it
Names Default To Here(1);
dt = open("$SAMPLE_DATA/Big Class.jmp");
collist = dt << Get Column Names("String");
Remove From(collist, 1, 3);
show(collist);
For Each({colnames, index}, collist,
rows_to_color = dt << Get Rows Where((Column(dt, colnames)[] < 100));
Column(dt, colnames) << Color Cells("Red", rows_to_color);
);
You can also do it inside the for each when you define the list, but in my opinion it is better to do it before (easier to read and debug)
Names Default To Here(1);
dt = open("$SAMPLE_DATA/Big Class.jmp");
For Each({colname, index}, Remove(dt << Get Column Names("String"), 1, 3),
show(colname);
);
Or if you collect list before, you can just loop over specific items
Names Default To Here(1);
dt = open("$SAMPLE_DATA/Big Class.jmp");
collist = dt << Get Column Names("String");
For Each({colname, index}, collist[4::N Items(collist)],
show(colname);
);
Nice! Works well.