Posted by Albert Gareev on Mar 23, 2008
Parent page: Service Functions – Math (QTP, VBScript) Check whether an item is in set Public Function isItemInSet(ByVal stSet, ByVal sItem, ByVal sSetSeparator) Dim dvArray If sItem = "" Then isItemInSet = False Exit Function End If dvArray = Set2Array(stSet, sSetSeparator) isItemInSet = isItemInArray(dvArray) End Function ...
Posted by Albert Gareev on Mar 22, 2008
Parent page: Service Functions – Math (QTP, VBScript) Check whether a set consists of numeric values Public Function isSetNumeric(ByVal stSet, ByVal sSetSeparator) Dim dvArray dvArray = Set2Array(stSet, sSetSeparator) isSetNumeric = isArrayNumeric(dvArray) End Function Check whether a set consists of date/time values Public Function isSetDate(ByVal stSet, ByVal sSetSeparator) Dim dvArray [...] ...
Posted by Albert Gareev on Mar 20, 2008
Parent page: Service Functions – Math (QTP, VBScript) Convert set to typed array Public Function Set2TypedArray(ByVal stSet, ByVal sSetSeparator, ByVal sFormat) Dim Iter, dvArray If sSetSeparator = "" Then sSetSeparator = chrSetSeparator End If stSet = Replace(stSet, "\,", Chr(176)) stSet = Replace(stSet, "\ ", Chr(187)) dvArray = Split(stSet, sSetSeparator) [...] ...
Posted by Albert Gareev on Feb 19, 2008
Parent page: Service Functions – Math (QTP, VBScript) Convert array to set Public Function Array2Set(ByVal dvArray, ByVal sSetSeparator) Dim Iter Dim stResult If Not isArray(dvArray) Then Array2Set = "" Exit Function End If If UBound(dvArray) = -1Then Array2Set = "" Exit Function End If [...] ...
Posted by Albert Gareev on Feb 17, 2008
Parent page: Service Functions – Math (QTP, VBScript) Check whether an item is in array Public Function isItemInArray(ByVal dvArray, ByVal sItem) Dim Iter If sItem = "" Then isItemInArray = False Exit Function End If If Not isArray(dvArray) Then isItemInArray = False Exit Function [...] ...
Posted by Albert Gareev on Feb 15, 2008
Parent page: Service Functions – Math (QTP, VBScript) Check whether an array consists of numeric values Public Function isArrayNumeric(ByVal dvArray) Dim Iter If Not isArray(dvArray) Then isArrayNumeric = False Exit Function End If If UBound(dvArray) = -1 Then isArrayNumeric = False Exit Function End If [...] ...
Posted by Albert Gareev on Jan 20, 2008
In the code examples I present I often refer to routine functions. In my framework I have specialized libraries to call from. In my blog I maintain the similar structure. Array Functions Sort Data Array Sort Typed Data Array Check Array Type Check Item in Array Convert Array to Set Set Functions Convert Set to Array [...] ...
Posted by Albert Gareev on Jan 14, 2008
Parent page: Service Functions – Math (QTP, VBScript) Description Sorts one-dimentional array in ascending / descending order with typecasting. Implementation Public Function TypedArraySort(ByRef dvArray, ByVal sFormat, ByVal boolAscending) Dim Iter, Jter, aValue, boolRC If Not isArray(dvArray) Then dvArray = Array(dvArray) ArraySort = dvArray End If sFormat = UCase(sFormat) [...] ...
Posted by Albert Gareev on Jan 12, 2008
Parent page: Service Functions – Math (QTP, VBScript) Description Sorts one-dimentional array in ascending / descending order. Implementation Public Function ArraySort(ByRef dvArray, ByVal boolAscending) Dim Iter, Jter, aValue If Not isArray(dvArray) Then dvArray = Array(dvArray) ArraySort = dvArray End If For Jter = 0 To UBound(dvArray) For Iter = [...] ...
Posted by Albert Gareev on Apr 25, 2007
Math primitives In the code examples I present I often refer to routine functions. In my framework I have specialized libraries to call from. In my blog I maintain the similar structure. Math primitives 1 (WinRunner, TSL) Absolute value (Modulus) Check if a value has a multiple Check if a value belongs to range Check if [...] ...
Posted by Albert Gareev on Apr 23, 2007
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", ...
Posted by Albert Gareev on Apr 21, 2007
Service Functions – Math / WinRunner Add new column to a matrix public function mx_add_col_value(inout mxTable[], in col_value) { auto rc, i; auto col_count, row_count; col_count = mxTable[0, "sys", "colCount"]; row_count = mxTable[0, "sys", "rowCount"]; # create new col index col_count++; for (i=1;i<=row_count;i++) mxTable[i,col_count] = col_value; mxTable[0, ...
Posted by Albert Gareev on Apr 19, 2007
Service Functions – Math / WinRunner Convert matrix to text table public function mx_array_2_table(inout mxTable[], inout dtTable[], in separator, in skip_empty) { auto col_count, row_count, i,j; auto row, s_value; if (skip_empty != TRUE) skip_empty = FALSE; if (separator == "") separator = "\t"; col_count = mxTable[0, "sys", "colCount"]; row_count = mxTable[0, "sys", ...
Posted by Albert Gareev on Apr 17, 2007
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 = [...] ...
Posted by Albert Gareev on Apr 15, 2007
Service Functions – Math / WinRunner Absolute value (Modulus) public function mx_val_mod(in value) { if (value < 0) return(-1*value); else return(value); } Check if a value has a multiple public function mx_val_multiple(in value1, in value2) { auto k; if (value2 == 0) return(TRUE); k = value1 / value2; return(int(k) == k); } Check if a [...] ...