preload

How to “Save As” text template

Posted by Albert Gareev on Oct 26, 2010
0
Parent page: Service Functions – System (QTP, VBScript) Question I need to modify text file template (add a few lines) and “Save as”. Answer One of the typical challenges that people face while trying to automate work tasks, is “procedure – result” confusion. Here, the end result* is confused with a way** to do the [...] ...

Inserting breaks into text line

Posted by Albert Gareev on Aug 19, 2010
0
Parent page: Service Functions – String (QTP, VBScript) Description Based on the maximum allowed length of  the string (strMsgText) insert space characters. Implementation Public Function BreakTextLine(ByVal strMsgText, ByVal intMaxLen)  Dim intLoc, intMaxLen, strResult  If Len(strMsgText) < intMaxLen Then   BreakTextLine = strMsgText   Exit Function  End If  strResult = ""  While Len(strMsgText) > 0   intLoc = ...

How to wrap text line (QTP, VBScript)

Posted by Albert Gareev on Feb 25, 2010
0
Parent page: Service Functions – String (QTP, VBScript) Question The question was asked here. Hi Albert! Can you email me a QTP function that wraps line of text without breaking words? Thank you!  Answer Proper text alignment is important. The whole layout of CSS block or HTML table could be broken if a text line [...] ...

How to trim words inside a text line (QTP, VBScript)

Posted by Albert Gareev on Feb 22, 2010
0
Parent page: Service Functions – String (QTP, VBScript) Question The question was asked here. What QTP function i can use to trim inside string? For e.g. “text text text text” – i want only 1 space between. Answer I believe the sample string provided in the question originally contained multiple space characters inside but was [...] ...

Generating text file from XML template (QTP, VBScript)

Posted by Albert Gareev on Dec 09, 2009
1
Parent page: Service Functions – System (QTP, VBScript) Description If you need to generate text file with values you don’t know ahead you may do it dynamically, by utilizing the function below. Make sure you designed template first. The current logic is oriented to executable text files generation, like Dexterity Macro or OS Shell batch files. Code lines are data-driven, [...] ...

Text File Compare Report example (XML, XSL, HTML)

Posted by Albert Gareev on Dec 03, 2009
1
Root page: Service Functions – XML (QTP, VBScript) Parent page: XSL introduction and references Related post: Text File compare in “WDIFF” style (QTP, VBScript, XML, XSL) – Instructions and XSL script Sample task After line by line (and word by word) text file comparison has been performed, XML log was produced. Review the log, identify and report found issues. [...] ...

Service Functions – String (QTP, VBScript)

Posted by Albert Gareev on Oct 01, 2009
2
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. Matching string with a pattern (Regular Expression, RegEx) Public Function Regex_Test(ByVal strSrc, ByVal strRegEx)  Dim objRegEx  Dim boolRC, intRC  Set objRegEx = New RegExp   objRegEx.Pattern = [...] ...

Text File compare in “WDIFF” style (QTP, ...

Posted by Albert Gareev on May 27, 2009
0
Original date: N/A The post has been mostly recompiled from the comments. Displaying Text File comparison results in an embedded report. Refer to Text File Compare functions used to see how XML file is generated. Sample requirements to show comparison results stored in XML as a web-page (HTML). 1. Show file stats saved in xml file. [...] ...

Text File compare in “WDIFF” style (QTP, ...

Posted by Albert Gareev on May 26, 2009
0
Original date: 26 Jan 2009, 1:30pm Line by line, and word by word comparison isn’t a big problem. But how conveniently show the results? With WinRunner comparison and reporting has been implemented utilizing WDIFF program. With QTP we can do the same using XML-XSL technology. The function below performs comparison of 2 text files generating [...] ...

Service Functions – String / WinRunner

Posted by Albert Gareev on Mar 28, 2007
0
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 [...] ...

String/Date functions 2 (WinRunner, TSL)

Posted by Albert Gareev on Mar 26, 2007
0
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 ...

String/Date functions (WinRunner, TSL)

Posted by Albert Gareev on Mar 24, 2007
0
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", ...

String/Text functions 5 (WinRunner, TSL)

Posted by Albert Gareev on Mar 22, 2007
0
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) { [...] ...

String/Text functions 4 (WinRunner, TSL)

Posted by Albert Gareev on Mar 20, 2007
0
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);    [...] ...

String/Text functions 3 (WinRunner, TSL)

Posted by Albert Gareev on Mar 18, 2007
0
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]); [...] ...

String/Text functions 2 (WinRunner, TSL)

Posted by Albert Gareev on Mar 16, 2007
0
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 = [...] ...

String/Text functions (WinRunner, TSL)

Posted by Albert Gareev on Mar 14, 2007
0
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));  } ### [...] ...
Creative Commons Attribution-NonCommercial-NoDerivs 3.0 Unported
This work by Albert Gareev is licensed under a Creative Commons Attribution-NonCommercial-NoDerivs 3.0 Unported.