Math primitives 5 (WinRunner, TSL)
Service Functions – Math / WinRunner
Find and retrieve subrange, defined by RegEx
public function mx_subrange_regex(inout mxTable[], inout mxRange[], in regex_from_str, in regex_to_str, in regex_col, in flExtend, in start_row, in end_row) { auto rc, i, j, row_index; auto col_count, row_count; auto flFound; col_count = mxTable[0, "sys", "colCount"]; row_count = mxTable[0, "sys", "rowCount"]; if (flExtend != FALSE) flExtend = TRUE; if (regex_col == "") regex_col = 1; if (regex_col > col_count) regex_col = col_count; if (regex_col < 1) regex_col = 1; if (start_row == "") start_row = 1; if (end_row == "") end_row = row_count; if (start_row > row_count) start_row = row_count; if (end_row > row_count) end_row = row_count; if (start_row > end_row) start_row = end_row; # Search for REGEX_FROM flFound = FALSE; for (i=start_row;i<=end_row;i++) { rc = match(mxTable[i,regex_col], regex_from_str); if (rc>0) { flFound = TRUE; if (flExtend) { start_row = i; break; } else { start_row = i+1; break; } } } if (!flFound) return(E_NOT_FOUND); # Search for REGEX_TO flFound = FALSE; for (i=start_row+1;i<=end_row;i++) { rc = match(mxTable[i,regex_col], regex_to_str); if (rc>0) { flFound = TRUE; if (flExtend) { end_row = i; break; } else { end_row = i-1; break; } } } if (!flFound) return(E_OUT_OF_RANGE); # Copy sub range row_index = 0; delete mxRange[]; for (i=start_row;i<=end_row;i++) { row_index++; for (j=1;j<=col_count;j++) { mxRange[row_index, j] = mxTable[i,j]; } } mxRange[0, "sys", "colCount"] = col_count; mxRange[0, "sys", "rowCount"] = row_index; return(E_OK); }