Hi,
I'm trying to add graphics (rectangles) to a graph box by using a for-loop. The expected outcome is a cross made of 31 rectangles. I have a working script where I wrote the code out line by line but would like to make it shorter and more scalable.
The script below is running but only the last rectangle will be displayed in the graph box.
When I write the script with 2 lines of "Add Graphics Script" (commented out at the bottom of the script) instead of the for-loop it does add 2 rectangles. I would have expected a for-loop to do the same. How can I get it do do so?
Names default to here(1);
//dt that holds the parameters for the rectangles
dt_loc = open (momo_dir || "rectangle_locations.csv" );
//create a graphic box
base_box = graph Box(
Frame Size( 400, 400 ),
XName(""), XScale(19,81), yScale(19,91), SuppressAxes, Pen Color( 1 );
);
//define the frame box in which the rectangles will e displayed
framebox = base_box[frame box( 1 )];
//ran a for loop for all 31 rectangles to be added to the Base_box
For( f = 1, f <= N Rows(dt_loc), f++,
//f=1;
//location/sizes of each box is defined here based on a csv file
rec_left = dt_loc:left[f];
rec_top = dt_loc:top[f];
rec_right = dt_loc:right[f];
rec_bottom = dt_loc:bottom[f];
//add the graphic script to the base_box for each row (aka rectangle) in the table
framebox << Add Graphics Script(Rect(rec_left, rec_top, rec_right, rec_bottom, fill = 0););
); //end f for loop
try(close(dt_loc, no save));
//Running the following 2 lines will add 2 rectangles
//framebox << Add Graphics Script(Rect(40,75,50,70, fill = 0););
//framebox << Add Graphics Script(Rect(40,70,50,65, fill = 0););
cross_rep = New window ("Cross", vlistbox(base_box));