Posted by Albert Gareev on Mar 28, 2007
String / Text/ Date Functions 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. String/Text functions (WinRunner, TSL) Trim text line Check format String/Text functions 2 (WinRunner, TSL) Replace characters in a string Replace [...] ...
Posted by Albert Gareev on Mar 26, 2007
Parent page: Service Functions – String / WinRunner Date to Dictionary public function str_date_split(in date, inout dtVector[]) { delete dtVector[]; date = str_date_align(date); dtVector["month"] = substr(date,1,2); dtVector["day"] = substr(date,4,2); dtVector["year"] = substr(date,7,4); } Date comparison # suppose dates are aligned # format is mm/dd/yyyy public function str_date_compare(in date1, in ...
Posted by Albert Gareev on Mar 24, 2007
Parent page: Service Functions – String / WinRunner Month Name/Number conversion static const month_number[] = { "JAN" = "01", "FEB" = "02", "MAR" = "03", "APR" = "04", "MAY" = "05", "JUN" = "06", "JUL" = "07", "AUG" = "08", "SEP" = "09", ...
Posted by Albert Gareev on Mar 22, 2007
Parent page: Service Functions – String / WinRunner CheckBox status value conversion static const string_cb_state[] = { "ON" = ON, "OFF" = OFF, "DIMMED" = DIMMED, "TOGGLE" = TOGGLE }; ### static const integer_cb_state[] = { ON = "ON", OFF = "OFF", DIMMED = "DIMMED", TOGGLE = "TOGGLE" }; ### public function int_cb_state(in cb_state) { [...] ...
Posted by Albert Gareev on Mar 20, 2007
Parent page: Service Functions – String / WinRunner Find a substring defined by 2 tokens public function str_get_text(in s, in text_before, in text_after) { auto index1, index2; auto result; if (text_before == "") index1 = 1; else index1 = index(s, text_before); if (index1 == 0) return(""); else index1 = index1 + length(text_before); [...] ...
Posted by Albert Gareev on Mar 18, 2007
Parent page: Service Functions – String / WinRunner Remove extra space and tab characters within a string public function str_shrink(in s, in separator) { auto res, i, c, StringArray[]; res = str_trim(s); if (res == "") return(res); res = str_replace(res, "\t", " "); c = split(s, StringArray, " "); if (c == 1) return(StringArray[1]); [...] ...
Posted by Albert Gareev on Mar 16, 2007
Parent page: Service Functions – String / WinRunner Replace characters in a string public function str_replace(in s, in sub1, in sub2) { auto loc, start, sub1_len; auto src, result; src = s; sub1_len = length(sub1); result = ""; while (1) { loc = index(src, sub1); if (loc == 0) break; else { result = [...] ...
Posted by Albert Gareev on Mar 14, 2007
Parent page: Service Functions – String / WinRunner Trim text line public function str_trim(in value) { auto StringArray[]; if (length(value) == 0) return (""); #if we have space chars only - let's do it quickly if (index(value,"\t") == 0) { if (split(value, StringArray, " ") == 1) return(StringArray[1]); } return str_rtrim(str_ltrim(value)); } ### [...] ...
Posted by Albert Gareev on Mar 10, 2007
VB Helper: Tips, tricks, & example programs for Visual Basic developers Hey, Scripting Guy! Great collection of VBScript examples with step by step explanations. Search archives. ...