2.2.3.75 wxt

Brief Information

Extract worksheet data using a condition

Command Line Usage

1. wxt test:="mod(col(c),2)==1" ow:=<new>;
2. wxt test:="col(1)<5" sel:=1;

X-Function Execution Options

Please refer to the page for additional option switches when accessing the x-function from script

Variables

Display
Name
Variable
Name
I/O
and
Type
Default
Value
Description
Test Condition test

Input

string

Specify the test condition string.
Worksheet to Extract iw

Input

Worksheet

<active>
Specify the input worksheet.
Column From c1

Input

int

1
Specify the beginning column of the range to perform the extraction.
Column To c2

Input

int

-1
Specify the end column of the range to perform the extraction.
Row From r1

Input

int

1
Specify the beginning row of the range to perform the extraction.
Row To r2

Input

int

-1
Specify the end row of the range to perform the extraction.
Mark passed Cells sel

Input

int

0
Specify the way to mark the passed block of cells (cells that meet the test condition).

Option list:

  • none:None
    Don’t select or mark the passed block of cells.
  • sel:Select Cells
    Select/highlight the passed rows.
  • mask:Mask Cells
    Mask the passed block of cells.
Extracted ow

Output

Worksheet

<optional>
Specify the worksheet for output.

See the syntax here.

On Off for Pass val

Output

vector

<optional>
The X-Function can output a vector to indicate whether the condition is satisfied for each row in the input worksheet: 1 for true and 0 for false. For example, if this vector has two elements, 1 and 0, it will mean that the first row in the input worksheet satisfies the test condition while the second row does not. You can specify this vector with the val variable.
Indices of Pass pass

Output

vector

<optional>
Specify a vector which will hold the indices of the passed rows.
Number of rows that pass num

Output

int

<optional>
Specify the output for the number of rows that pass.


Examples

  • Code Sample-1
//There are special considerations when the condition involves text strings. The following example shows a more complicated condition to select based on both a text column and a numeric column.
//import a sample file that has make of cars and their various characteristics
fname$=system.path.program$ + "Samples\Statistics\automobile.dat";
newbook;
impasc options.sparklines:=0;
// Select all rows in worksheet with make=Acura and Gas Mileage > 11
// Use range variable to make query more readable than "col(Make)[i]$"
range car=col(Make);
// Using string variable to avoid having to write "Acura" inside " " 
string str="Acura";

//wxt will translate "=" to "==", "and" to "&&"
wxt "car=str$ and col(Gas Mileage)>11" sel:=1; // Select the rows
wcellcolor c:=color(green); // Color those rows
wcellsel; // Clear the selection
  • Code Sample-2
/*
This example uses the wxt X-Function to extract records for females at the age of 14.
1. Import the sample data into a book in Origin;
2. Extract the found rows to a new sheet, output the row 
indexes and count the total number of these rows.
*/
//Create a new workbook
newbook result:=bkname$;	
//Import a file
path$ = system.path.program$ + "Samples\Statistics\";
fname$ = path$ + "body.dat";
impasc;
//Define two ranges for age column and gender column
range a=col(age), g=col(gender);

//Worksheet data extraction
wxt test:="g=="F" & a==14" ow:=<new> pass:=<new> num:=PassCount;

type -b Number of found rows is $(PassCount);