The wcol(colNumExpression) function can be used either on the left side or on the right side of an assignment. The wcol function always expects an argument evaluating to a column number (1 .. N).

When wcol() is on the left side of the assignment, the right hand side should normally be a vector, not a scalar value. In the special case where a column has an assigned size you can assign a scalar value which gets replicated for the entire column:

wcol(1) = data(0,100,5); // Fills column one 0 to 100 in increments of 5
wcol(2) = 1; // Does nothing if column 2 is empty
wcol(2) = wcol(int(pi)-2); // expression int(pi)-2 is 1, therefore this is same as wcol(2)=wcol(1); 
wcol(2) = 1; // Since there is already value in wol(2), it will replace all values with 1

Note: In the Wcol(colNumExpression) function , since the argument is always interpreted as an expression, you can use any expression which evaluates to a positive integer making it useful for looping over columns with a variable for example. This is different than the col(colNameOrNum) function where the argument must a column name or a literal number.

Function Form:



for (ii = 3; ii <= 10; ii += 1) 
      wcol(ii) = data(ii, ii+10);

In this case, if the worksheet contains only two columns, Origin creates new columns - the third to tenth column - as needed. Prior to Origin 8, this script would not create columns if they did not exist.

The following case shows how to set data, Long Name, Comments, and user parameters.

wcol(1) = data(0, 6.3, 0.1);
wcol(2) = sin(wcol(1));
// Set Long Name
wcol(1)[L]$ = X;
wcol(2)[L]$ = Sine;
// Set Comments
wcol(1)[C]$ = "X Values";
wcol(2)[C]$ = "Sine Function";
// Show the 1st user parameter row
wks.userParam1 = 1;
// Rename the user-defined worksheet header row
wks.userParam1$ = Purpose;
// Set the first parameter
wcol(2)[Purpose]$ = Graphing;

See Also