Cpmpare SMS sender no. with no. stored in .txt file
| Wed, 2007-09-19 10:40 | |
|
Hello friends, I'm developing SMS inteceptor. I want to intercept only those sms which comming from pertucular no. (Eg. 123456) I'm able to intercept sms & read its text body. I'm comparing it with no. stored in .txt file, for that i used IF loop but still it not comparing Here is code.... ......Please let me know what wrong in that IF LOOP condition? |
|






Forum posts: 80
Hi,
SDK Help says:
CompareC()
TInt CompareC(const TDesC16& aDes) const;
Description
Compares data using the standard collation method.
Compares this descriptor's data with the specified descriptor's data using the standard collation method appropriate to the current locale.
Return value
TInt Positive, if this descriptor is greater than the specified descriptor. Negative, if this descriptor is less than the specified descriptor. Zero, if the content of both descriptors match.
So if both numbers are different, the return value will be anything but 0. So if you want to verify if both numbers are same,then you should write:
if( Sender_no.CompareC(Stored_No) == 0 ) //compare nos..
{
.....
......
........
}
Note: Why is there a semi-colon in your code after the If statement??
Moreover, you can simply do with Compare(). Why use CompareC() ?
Forum posts: 1242
Well, yes, but what is the *deeper* reason it does not work, i.e. the if block gets executed with 0 *and* the if gets also executed with values other than 0 (something that is probably surprising and confusing)?
It is because in the way the condition is written the "!" operator will work with all the bits of the value, so e.g. !3 does not give 0 but -4, right?
René Brunner