This should do it:
/* Each 'PRE' should start (in this example) 3 rows before the 'Event'-row and
stop 1 row before the 'Event'
Each 'POST' should start 1 row after the event and stop 5 rows after the 'Event'
Thank you! */
dt = New Table( "pre-post example", Add Rows( 23 ),
New Column( "Column 1", Character, "Nominal",
Set Values(
{"", "", "", "", "Event", "", "", "", "", "", "", "", "", "", "", "", "",
"Event", "", "", "", "", ""}
)
),
New Column( "Column 2", Character, "Nominal",
Set Values(
{"", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "",
"", "", "", "", ""}
)
)
);
event_rows = dt << get rows where(dt:Column 1 == "Event");
nr = nrows(event_rows);
if (nr > 0,
for (i = 1, i <= nr, i++,
start_row = maximum(event_rows[i] - 3, 1); // Keep from trying to set a negative row
for (k = start_row, k < event_rows[i] , k++,
dt:column 2[k] = "PRE";
);
end_row = minimum(event_rows[i] + 5, nrows(dt)); // Prevent setting higher rows than are in the table
for (k = event_rows[i] + 1, k <= end_row, k++,
dt:column 2[k] = "POST";
);
dt:column 2[event_rows[i]] = "Event";
);
);