Hi @MFVIT,
You need to make sure the values of X1 and Y1 are evaluated in your script, rather than looking for something in the data table itself. This problem is illustrated in Insert one expression into another using Eval Insert, Eval Expr, Parse, and Substitute. You can ensure this happens by using Eval( Eval Expr( ) ). Here is an example using your code with an example data table.
Names default to here(1);
dt = New Table( "Example Data",
Add Rows( 10000 ),
New Column( "X", Numeric, "Continuous", Format( "Best", 12 ),
Formula( Random Uniform( 0, 10000 ) ) ),
New Column( "Y", Numeric, "Continuous", Format( "Best", 12 ),
Formula( Random Uniform( 0, 10000 ) ) )
);
X0 = 2332;
Y0 = 558;
n_patch = 0;
delta_x = 100;
delta_y = 100;
dist_y = 488;
dist_x = 656;
L_x = 500;
L_y = 500;
For( n_x = 1, n_x <= 4, n_x++,
For( n_y = 1, n_y <= 5, n_y++,
Xc = X0 - (n_x - 1) * (dist_x) + L_x / 2;
Yc = Y0 + (n_y - 1) * (dist_y) + L_y / 2;
n_patch = n_patch + 1;
X1 = Xc - delta_x;
X2 = Xc + delta_x;
Y1 = Yc - delta_y;
Y2 = Yc + delta_y;
Eval( Eval Expr(
dt << Row Selection(
Select where( (:X >= Expr( X1 ) & :X <= Expr( X2 )) & (:Y >= Expr( Y1 ) & :Y <= Expr( Y2 ) ) )
);
) );
dt << run formulas;
dt << Name Selection in Column(
Column Name( "Patch#" || char( n_patch ) ),
Selected( "n_patch = " || char( n_patch ) ),
Unselected( "" )
);
)
);