Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

What would make a string not act normally? please help

Status
Not open for further replies.

TeaAddictedGeek

Programmer
Apr 23, 1999
271
US
I have this string that's being produced from a query.&nbsp;&nbsp;It's a string of a single name, or a comma-delimited list of a few names.&nbsp;&nbsp;It's usually not more than two names given by this variable.<br><br>I am comparing this string to another string, but the ASP claims even when they are identical, they are different.&nbsp;&nbsp;I have a ListFind function written for ASP that I am using so I am also able to find individual names within the string (no there is nothing wrong with this function; we've used it for years).<br><br>The problem is this:&nbsp;&nbsp;there is something wrong with this variable and for the life of me I can't figure out what.&nbsp;&nbsp;If I place it into another query to be analyzed, the query spits out an error that goes something like this:&nbsp;&nbsp;&quot;Either BOF or EOF is true, et cetera&quot;&nbsp;&nbsp;If I compare the string with an identical string, say this variable reads &quot;Joe Smith&quot; and I compare it with another string called &quot;Joe Smith.&quot;&nbsp;&nbsp;ASP reads these two string as not being identical!<br><br>Please help.&nbsp;&nbsp;I'm at my wits end.&nbsp;&nbsp;I've tried everything, and no one can help me.&nbsp;&nbsp;I've done a TypeName on this variable from the query, and it's no different than any of the other strings.&nbsp;&nbsp;I can't figure out what's wrong.<br><br><br>Thanks!
 
The two strings you specified are not identical.&nbsp;&nbsp;One contains a period.&nbsp;&nbsp;Assuming this was a typo in your question,&nbsp;&nbsp;what method are you using to compare the strings? Can you post some code? <p>nick bulka<br><a href=mailto:nick@bulka.com>nick@bulka.com</a><br><a href= > </a><br>
 
The two strings you specified are not identical.&nbsp;&nbsp;One contains a period.&nbsp;&nbsp;Assuming this was a typo in your question,&nbsp;&nbsp;what method are you using to compare the strings? Can you post some code? <p>nick bulka<br><a href=mailto:nick@bulka.com>nick@bulka.com</a><br><a href= > </a><br>
 
The two strings you specified are not identical.&nbsp;&nbsp;One contains a period.&nbsp;&nbsp;Assuming this was a typo in your question,&nbsp;&nbsp;what method are you using to compare the strings? Can you post some code? <p>nick bulka<br><a href=mailto:nick@bulka.com>nick@bulka.com</a><br><a href= > </a><br>
 
NO.<br><br>ARRGGG<br><br>It's just an example.&nbsp;&nbsp;NONE of the strings that I'm comparing contain a period, and when I output them, they are IDENTICAL.<br><br><br>*bangs her head against the wall*<br><br>Can someone PLEASE help me? <p> <br><a href=mailto:aberman@thebiz.net>aberman@thebiz.net</a><br><a href= > </a><br>Database programmer and developer, fueled by peach snapple.
 
Method of comparison, this is what I use to test.&nbsp;&nbsp;Here goes:<br><br><br>dim sTest <br>sTest = &quot;Andrea Berman&quot; <br>if trim(cstr(AName)) = cstr(sTest) then <br>response.write (&quot;It worked:&quot;&AName&&quot; = &quot; &sTest&&quot;&lt;br&gt;&quot; )<br>else <br>response.write (&quot;Didn't work:&quot;&AName&&quot; = &quot; &sTest&&quot;&lt;br&gt;&quot; )<br>end if<br><br>AName is the variable.&nbsp;&nbsp;Yes, at several points in the query, they ARE identical, and I even output them as above to show when they are identical but still returning that they're not.<br><br>Does this help?&nbsp;&nbsp;:) <p> <br><a href=mailto:aberman@thebiz.net>aberman@thebiz.net</a><br><a href= > </a><br>Database programmer and developer, fueled by peach snapple.
 
Kyrene,<br>&nbsp;&nbsp;&nbsp;Try it this way:<br>if strcomp(cstr(AName),cstr(sTest),1) = 0 then<br>&nbsp;&nbsp;&nbsp;response.write &quot;strings are the same&quot;<br>else<br>&nbsp;&nbsp;&nbsp;response.write &quot;strings are different&quot;<br>end if<br><br> <p>nick bulka<br><a href=mailto:nick@bulka.com>nick@bulka.com</a><br><a href= > </a><br>
 
It claims that the strings are different every time, even when they're not. <p> <br><a href=mailto:aberman@thebiz.net>aberman@thebiz.net</a><br><a href= > </a><br>Database programmer and developer, fueled by peach snapple.
 
Very String indeed!&nbsp;&nbsp;I guess the next step is to find out exactly where the difference is. Try this:<br><br>dim string1,string2,char1,char2,i<br>string1=cstr(AName)<br>string2=cstr(sTest)<br>if len(string1) &lt;&gt; len(string2) then<br>&nbsp;&nbsp;&nbsp;&nbsp;response.write &quot;Different lengths&quot;<br>else<br><br>&nbsp;&nbsp;&nbsp;&nbsp;for i=1 to len(string1)<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;char1=mid(string1,i,1)<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;char2=mid(string2,i,1)<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Response.Write asc(char1) & &quot; - &quot; & asc(char2) _<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;& &quot;&lt;br&gt;&quot;<br>&nbsp;&nbsp;&nbsp;&nbsp;next<br>end if<br><br>Let us know what you find out.<br> <p>nick bulka<br><a href=mailto:nick@bulka.com>nick@bulka.com</a><br><a href= > </a><br>
 
Yup, this is so weird--I have it outputting each variable as it changes, and when it's the same, it claims it's a different length!<br><br>very string ;) <p> <br><a href=mailto:aberman@thebiz.net>aberman@thebiz.net</a><br><a href= > </a><br>Database programmer and developer, fueled by peach snapple.
 
Obviously there's a non-printing character in one of the strings.&nbsp;&nbsp;Just modify the code to display every character of both strings, even if they're different lengths<br> <p>nick bulka<br><a href=mailto:nick@bulka.com>nick@bulka.com</a><br><a href= > </a><br>
 
How do I do that? <p> <br><a href=mailto:aberman@thebiz.net>aberman@thebiz.net</a><br><a href= > </a><br>Database programmer and developer, fueled by peach snapple.
 
dim string1,string2,char1,char2,i,len1,len2,j<br>string1=cstr(AName)<br>string2=cstr(sTest)<br>len1 = len(string1)<br>len2 = len(string2)<br>if len1 &gt;len2 then<br>&nbsp;&nbsp;&nbsp;&nbsp;j = len1<br>else<br>&nbsp;&nbsp;&nbsp;&nbsp;j = len2<br>end if <br>for i=1 to j<br>&nbsp;&nbsp;&nbsp;&nbsp;if i &lt;= len1 then<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;char1=asc(mid(string1,i,1))<br>&nbsp;&nbsp;&nbsp;&nbsp;else<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;char1 = &quot;NONE&quot;<br>&nbsp;&nbsp;&nbsp;&nbsp;end if<br>&nbsp;&nbsp;&nbsp;&nbsp;if i &lt;= len2 then<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;char2=asc(mid(string2,i,1))<br>&nbsp;&nbsp;&nbsp;&nbsp;else<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;char2 = &quot;NONE&quot;<br>&nbsp;&nbsp;&nbsp;&nbsp;end if<br>&nbsp;&nbsp;&nbsp;&nbsp;Response.Write char1 & &quot; - &quot; & char2 _<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;& &quot;&lt;br&gt;&quot;<br>next<br><br>This is untested, so you might need to tweak it a little.<br> <p>nick bulka<br><a href=mailto:nick@bulka.com>nick@bulka.com</a><br><a href= > </a><br>
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top