Math primitives 2 (WinRunner, TSL)
Service Functions – Math / WinRunner
Check a value exists in array
public function mx_val_exists(in value, inout dtSet[]) { auto i; for (i in dtSet) if (value == dtSet[i]) return(TRUE); return(FALSE); }
Sort one-dimensional array
public function mx_sort_vector(inout mxVector[], in flAscending) { auto i,j,c,v; if (flAscending != FALSE) flAscending = TRUE; c = mxVector[0]; for (j=1;j<=c;j++) { for (i=1;i<c;i++) { v = mxVector[i]; if (flAscending) { if (v > mxVector[i+1]) { mxVector[i] = mxVector[i+1]; mxVector[i+1] = v; } } else { if (v < mxVector[i+1]) { mxVector[i] = mxVector[i+1]; mxVector[i+1] = v; } } } } }
Convert array to simple set (enumeration)
public function mx_vector2enum(inout mxVector[], out enumstr) { auto i,c; c = mxVector[0]; enumstr = ""; for (i=1;i<=c;i++) enumstr = str_list_add(enumstr, mxVector[i], ","); }