Origin Ver. and Service Release (Select Help-->About Origin): 9.0
I want to find the maximum value of a worksheet and write it to a new column. Here's my script:
// Filling the two columns from empty worksheet with some data
range activeCol = 1;
activeCol = {1:14};
range activeCol = 2;
activeCol = {15:28};
//maxValue is set to max of first column
double maxValue;
range activeCol = 1;
maxValue = max(activeCol);
// Cycle through the remaining columns and update maxValue if necessary
for ( ii = 2; ii <= wks.ncols; ii++)
{
range activeCol = ii;
if (maxValue < max(activeCol)) maxValue = max(activeCol);
}
// Create new column and write maxValue to it
range normalizedCol = Col("Normalized");
normalizedCol[1] = maxValue;
// Output the variable for testing purposes
type -b $(maxValue);
I have two problems/questions.
First of all, to fill the columns with data, do I really need to declare activeCol each time? I wasn't able to switch activeCol to the second column by doing activeCol = 2.
More importantly, after running the script, I end up with 14 being written to Col(Normalized). It seems like range activeCol = ii; doesn't work as supposed. Because if I substitute it with range activeCol = 2; everything works fine.