WinBatch Tech Support Home

Database Search

If you can't find the information using the categories below, post a question over in our WinBatch Tech Support Forum.

TechHome

Strings

Can't find the information you are looking for here? Then leave a message over on our WinBatch Tech Support Forum.

Keywords:     strindex strreplace

Question:

I am doing some string compares and if I use strindexnc( varible, "hardcoded string", 1,@FWDSCAN) all works well. But if I replace the hardcoded string with a varible it is not working. I know the contents of the string varible ( I print it out to message box.) I thought it might have something to do with CRLF so I Chomped the string with StrFix.

I have to Strings (n & q) that are being assigned by a ItemExtract on a list. The list comes from text files.

If I print their values Using Message, I can see that the values are the same. However if I use either "if n == q" or strcmp(n,q) the strings always evaluate as not equal.

Answer:

Assuming your strings are in n and q:
        n1=StrReplace(n,@tab,"!")
        n1=StrReplace(n1," ","?")
		  n1=StrReplace(n1,@CR,"#")
		  n1=StrReplace(n1,@LF,"$")
        q1=StrReplace(q1,@tab,"!")
        q1=StrReplace(q1," ","?")
		  q1=StrReplace(q1,@CR,"#")
		  q1=StrReplace(q1,@LF,"$")

        n2=StrLen(n)
        q2=StrLen(q)

        Message(strcat(n2," ",q2),strcat(n1,@crlf,q1))
Look at that info. Is there a perfect match. Is everything the same case?
Article ID:   W13332
Filename:   Compare Two Strings.txt
File Created: 2001:01:09:09:26:26
Last Updated: 2001:01:09:09:26:26