You have made the script far more complex than it needs to be. Below are 2 reworks of your script. The first one is taking your flow, and just converting it into a working model. The second is making it very concise(small) as you also requested.
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( "" ),
X Scale( 19, 81 ),
Y Scale( 19, 91 ),
SuppressAxes,
Pen Color( 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++,
// 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];
// Draw the rectangle
Rect( rec_left, rec_top, rec_right, rec_bottom, fill = 0 );
);
);
Try( Close( dt_loc, no save ) );
cross_rep = New Window( "Cross", V List Box( base_box ) );
Names Default To Here( 1 );
//dt that holds the parameters for the rectangles
dt_loc = Open( momo_dir || "rectangle_locations.csv" );
cross_rep = New Window( "Cross",
//create a graphic box
base_box = Graph Box(
Frame Size( 400, 400 ),
XName( "" ),
X Scale( 19, 81 ),
Y Scale( 19, 91 ),
SuppressAxes,
Pen Color( 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++,
// location/sizes of each box is defined here based on a csv file
Rect( dt_loc:left[f], dt_loc:top[f], dt_loc:right[f], dt_loc:bottom[f] );
);
)
);
Try( Close( dt_loc, no save ) );
Jim