Ask a Question

String comparison methods

Frequent Contributor

String comparison methods


I have a window for which I need to verify that the caption .the value is "Report: C:\Program Files (x86)\Report2Web Client Tools\BursterWatch\PQ5.mfd  Profile: PQ5.mfdProfile - Report2Web Burster" .

The variable "b" returns substring as 'C:\Program Files (x86)\ReportWeb2Client Tools\BursterWatch\PQ5.mfd'.I tried to use aqstring.Find,aqstring.Compare but soemhow it is not able to compare correctly as it should return true.Instead it returns false.In the below code I simply used the comparison operator but still it returns with an error .Why are these methods not working for this string . Please tell me the correct way to do it.Most of my scripts have compare string operation and all have the same problem.For some it works,for some it doesn't.

The code looks like this:

BurstWnd = Sys.Process("Burster").VBObject("frmPDFView").WndCaption;

b = aqString.SubString(BurstWnd,8,68);

if (b == 'C:\\Program Files (x86)\\ReportWeb2Client Tools\\BursterWatch\\PQ5.mfd')







Hi Sumedha,

I've observed that, after executing the following code snippet

  BurstWnd = "Report: C:\\Program Files (x86)\\Report2Web Client Tools\\BursterWatch\\PQ5.mfd  Profile: PQ5.mfdProfile - Report2Web Burster";  

  b = aqString.SubString(BurstWnd,8,68);

the "b" variable's value is equal to "C:\Program Files (x86)\Report2Web Client Tools\BursterWatch\PQ5.mfd " (an extra space at the end) instead of "C:\Program Files (x86)\ReportWeb2Client Tools\BursterWatch\PQ5.mfd".

In any case, as you are using JScript, I suggest that you implement the verification by using the indexOf method. Here is an example:

function Test()


  var BurstWnd = "Report: C:\\Program Files (x86)\\Report2Web Client Tools\\BursterWatch\\PQ5.mfd  Profile: PQ5.mfdProfile - Report2Web Burster";

  Log.Message(Verify(BurstWnd, "C:\\Program Files (x86)\\Report2Web Client Tools\\BursterWatch\\PQ5.mfd"));


function Verify(Str, Substr)


  return (Str.indexOf(Substr) != -1) ? true : false


For additional information about the indexOf method, please see the "indexOf Method (Windows Scripting - JScript)" MSDN Library article.
Dmitry Nikolaev

Did my reply answer your question? Give Kudos or Accept it as a Solution to help others. ⬇️⬇️⬇️
Showing results for 
Search instead for 
Did you mean: