How to compare string..
-
Hi!!! I have one simple question.. How i can compare strin.. code is if(x1.compareNocase(s1 || s2) { do something } Here if x1 is equal to s1 or s2 then do something in my code.. How i can compare..?? as in || is right or wrong?? Shah Satish
-
Hi!!! I have one simple question.. How i can compare strin.. code is if(x1.compareNocase(s1 || s2) { do something } Here if x1 is equal to s1 or s2 then do something in my code.. How i can compare..?? as in || is right or wrong?? Shah Satish
-
Hi!!! I have one simple question.. How i can compare strin.. code is if(x1.compareNocase(s1 || s2) { do something } Here if x1 is equal to s1 or s2 then do something in my code.. How i can compare..?? as in || is right or wrong?? Shah Satish
Shah Satish wrote:
if(x1.compareNocase(s1 || s2) { do something }
if ((x1.CompareNoCase(s1)== 0) || (x1.CompareNoCase(s2)== 0))
{
//do something
}Shah Satish wrote:
as in || is right or wrong??
Here it is wrong, using your way.
Prasad Notifier using ATL | Operator new[],delete[][^]
-
Hi, You trying to be too fast ;-) if ( x1.CompareNoCase( s1 ) || x1.CompareNoCase( s2 ) ) { ... }
----------- Mila
I have code.. If(Loopname.CompareNocase(x1)==0 || Loopname.CompareNocase(mytext->contents)==0). but its not working
-
Shah Satish wrote:
if(x1.compareNocase(s1 || s2) { do something }
if ((x1.CompareNoCase(s1)== 0) || (x1.CompareNoCase(s2)== 0))
{
//do something
}Shah Satish wrote:
as in || is right or wrong??
Here it is wrong, using your way.
Prasad Notifier using ATL | Operator new[],delete[][^]
I have code.. If(Loopname.CompareNocase(x1)==0 || Loopname.CompareNocase(mytext->contents)==0). but its not working..
-
I have code.. If(Loopname.CompareNocase(x1)==0 || Loopname.CompareNocase(mytext->contents)==0). but its not working..
Shah Satish wrote:
but its not working..
Means what ? Can you try modifying it to,
If( (Loopname.CompareNocase(x1)==0) || (Loopname.CompareNocase(mytext->contents)==0))
{
//do something
}Prasad Notifier using ATL | Operator new[],delete[][^]
-
Shah Satish wrote:
but its not working..
Means what ? Can you try modifying it to,
If( (Loopname.CompareNocase(x1)==0) || (Loopname.CompareNocase(mytext->contents)==0))
{
//do something
}Prasad Notifier using ATL | Operator new[],delete[][^]
No..Not modified..This is my actual code..But i dont know its not working.
-
Shah Satish wrote:
but its not working..
Means what ? Can you try modifying it to,
If( (Loopname.CompareNocase(x1)==0) || (Loopname.CompareNocase(mytext->contents)==0))
{
//do something
}Prasad Notifier using ATL | Operator new[],delete[][^]
ie only one case is wroking properly..Both together is not working.. If( (Loopname.CompareNocase(x1)==0)---This is working (Loopname.CompareNocase(mytext->contents)==0))--This is working If( (Loopname.CompareNocase(x1)==0) || (Loopname.CompareNocase(mytext->contents)==0))--But together is not working..
-
I have code.. If(Loopname.CompareNocase(x1)==0 || Loopname.CompareNocase(mytext->contents)==0). but its not working
Hi, hm... interesting - and what type are x1 and mytext->contents -> is it CString too ? (I'm thinking about e.g. you use VS2005 where default is UNICODE defined and you try to compare default CString with char *) Besides you can check what exactly return particular comparing functions (if equal should returns NULL)
----------- Mila
-
ie only one case is wroking properly..Both together is not working.. If( (Loopname.CompareNocase(x1)==0)---This is working (Loopname.CompareNocase(mytext->contents)==0))--This is working If( (Loopname.CompareNocase(x1)==0) || (Loopname.CompareNocase(mytext->contents)==0))--But together is not working..
you are using a logical OR operator, which returns TRUE if one of the 2 operands is TRUE. so if its 1st part (1st comparison) is TRUE, then the 2nd one is not executed... are you sure you want to use a OR ? don't you need a AND (
&&
) instead ?
Don't know where to start ?
Refer the Forums Guidelines and ask a friend -
ie only one case is wroking properly..Both together is not working.. If( (Loopname.CompareNocase(x1)==0)---This is working (Loopname.CompareNocase(mytext->contents)==0))--This is working If( (Loopname.CompareNocase(x1)==0) || (Loopname.CompareNocase(mytext->contents)==0))--But together is not working..
Shah Satish wrote:
But together is not working..
What does this mean ? Remember,
Loopname.CompareNocase(mytext->contents)
will not be called ifLoopname.CompareNocase(x1)
returns 0. (or
rule)Prasad Notifier using ATL | Operator new[],delete[][^]
-
Shah Satish wrote:
But together is not working..
What does this mean ? Remember,
Loopname.CompareNocase(mytext->contents)
will not be called ifLoopname.CompareNocase(x1)
returns 0. (or
rule)Prasad Notifier using ATL | Operator new[],delete[][^]
mytext->contents is a pointer.. as in AcDbMtext *mytext ; mytext->Contents; what to do?? How t compare it?
-
Shah Satish wrote:
But together is not working..
What does this mean ? Remember,
Loopname.CompareNocase(mytext->contents)
will not be called ifLoopname.CompareNocase(x1)
returns 0. (or
rule)Prasad Notifier using ATL | Operator new[],delete[][^]
Ya..I have to use only "or" function.. but among them one is pointer and one is string.. mytext->contents is a pointer.. as in AcDbMtext *mytext ; mytext->Contents; If( (Loopname.CompareNocase(x1)==0) || (Loopname.CompareNocase(mytext->contents)==0)) x1 is cstring and (mytext->contents)is a pointer.. what to do?? How t compare it?
-
you are using a logical OR operator, which returns TRUE if one of the 2 operands is TRUE. so if its 1st part (1st comparison) is TRUE, then the 2nd one is not executed... are you sure you want to use a OR ? don't you need a AND (
&&
) instead ?
Don't know where to start ?
Refer the Forums Guidelines and ask a friendYa..I have to use only "or" function.. but among them one is pointer and one is string.. mytext->contents is a pointer.. as in AcDbMtext *mytext ; mytext->Contents; If( (Loopname.CompareNocase(x1)==0) || (Loopname.CompareNocase(mytext->contents)==0)) x1 is cstring and (mytext->contents)is a pointer.. what to do?? How t compare it?
-
mytext->contents is a pointer.. as in AcDbMtext *mytext ; mytext->Contents; what to do?? How t compare it?
you didn't read the answers :zzz:
Don't know where to start ?
Refer the Forums Guidelines and ask a friend -
Ya..I have to use only "or" function.. but among them one is pointer and one is string.. mytext->contents is a pointer.. as in AcDbMtext *mytext ; mytext->Contents; If( (Loopname.CompareNocase(x1)==0) || (Loopname.CompareNocase(mytext->contents)==0)) x1 is cstring and (mytext->contents)is a pointer.. what to do?? How t compare it?
Loopname is a CString, right ? then look at the signature of CString::CompareNoCase(). it gets a PCXSTR parameter (so, pointer to char). so ther's no problem in doing so. if your code doesn't work, it is because of what i notified you previously. have you tried inverting the two statements in the OR operation (C-style string compared first) ?
Don't know where to start ?
Refer the Forums Guidelines and ask a friend -
Shah Satish wrote:
if(x1.compareNocase(s1 || s2) { do something }
if ((x1.CompareNoCase(s1)== 0) || (x1.CompareNoCase(s2)== 0))
{
//do something
}Shah Satish wrote:
as in || is right or wrong??
Here it is wrong, using your way.
Prasad Notifier using ATL | Operator new[],delete[][^]
if this does not work, split the CompareNoCase and the if in different statements and debug each statement separatly.
bool b1 = (x1.CompareNoCase(s1)== 0);
bool b2 = (x1.CompareNoCase(s2)== 0);
if ( b1 || b2 )
{
}
Maximilien Lincourt Your Head A Splode - Strong Bad
-
mytext->contents is a pointer.. as in AcDbMtext *mytext ; mytext->Contents; what to do?? How t compare it?
What you've shown in now way indicates that
contents
is a pointer. Whilemytext
is indeed a pointer, you've shown nothing of itscontents
member. Ifcontents
is indeed a pointer, what's it a pointer to?
"Approved Workmen Are Not Ashamed" - 2 Timothy 2:15
"Judge not by the eye but by the heart." - Native American Proverb
-
I have code.. If(Loopname.CompareNocase(x1)==0 || Loopname.CompareNocase(mytext->contents)==0). but its not working
Shah Satish wrote:
but its not working
What is this supposed to mean? If one of the calls to
CompareNocase()
is returning a non-zero value, which you have yet to verify, that indicates the strings do not match. Whether the strings match or not, your code is syntactically correct.
"Approved Workmen Are Not Ashamed" - 2 Timothy 2:15
"Judge not by the eye but by the heart." - Native American Proverb
-
Ya..I have to use only "or" function.. but among them one is pointer and one is string.. mytext->contents is a pointer.. as in AcDbMtext *mytext ; mytext->Contents; If( (Loopname.CompareNocase(x1)==0) || (Loopname.CompareNocase(mytext->contents)==0)) x1 is cstring and (mytext->contents)is a pointer.. what to do?? How t compare it?
Come on Satish ! You are still not reading answers well and replying to our queries well. 1. What does not working mean ? You need to be very clear. 2. Have you taken in to consideration when using
||
operator second operand will be looked only when first isfalse
?Shah Satish wrote:
x1 is cstring and (mytext->contents)is a pointer..
It should not matter here.
Prasad Notifier using ATL | Operator new[],delete[][^]