Help needed with substring comparison

I have an xml file on my sut whose text I need to search through for a string.

I copy the text over using remoteClipboard() and store it into a var

However my search string has quotes in it, which the offset function seems to have a little trouble with. Any ideas/suggestions on how I can get around this?

Here’s what I tried



put remoteClipboard() into sText

if offset("ComparisonStatus=\"1\"", sText) = 0 then
      put "Comparison Failed"
else 
      put "Comparison Succeded"
end if

Oh ok… nm I got it to work.

I just saved the search string into a variable like so

put "ComparisonStatus=" & <<">> & "1" & <<">> into str
if offset(str, sText) = 0 then
     put "Comparison failed"
end if

I’m glad you were able to solve your problem. For future reference, there are at least two other ways you could do this as well. The first is to use the predefined variable ‘quote’:

if offset("ComparisonStatus=" & quote & 1 & quote, sText) = 0 then 
      put "Comparison Failed" 
else 
      put "Comparison Succeded" 
end if 

Another would be to use the double-angle-bracket quotes around the whole string, which allows you to embed standard quotes:

if offset(<<ComparisonStatus="1">>, sText) = 0 then 
      put "Comparison Failed" 
else 
      put "Comparison Succeded" 
end if 

I hope this is helpful.