SmsText

Hi!!!

With this command wm_strGetParameterString ( dst, smsText, Position ) the position is used to select the parameter

Ex: +CMTI:x,y

if i give position as 1, then only x will be copied in dst and
if 2, then only y.

Try this,

With Regards,
SUNIL RAO.M

@colin-tfe

//char stringToCompare="comm=1,comm=2";
char *token;
token = strtok(SmsText,",");
while (token != NULL)
{
	TRACE((1, "The token is: "));
	TRACE((1,  token));
	token = strtok(NULL,",");
}

If (token == "comm=1")
{ 
  TRACE ((1,"comm1=comm1"));
}
else if (token == "comm=2")
{
  TRACE ((1,"comm2=comm2"));
}
else{
  TRACE ((1,"not equal"));
}

The result
The token is:
comm=1
The token is:
comm=2

but there is no comparation.
I know that this is the wrong approach but this is the only that i can think of :cry:

@SunilRao
I tryed with wm_strGetParameterString but without success.
wm_strGetParameterString ( dst, smsText, 1 )
{
TRACE ((1,“compare”));
TRACE ((1,dst));
}
The result, “compare” and dst are not in the trace.

What do you mean by that?

Note that the ‘==’ operator in ‘C’ does not work for seeing if two strings contain the same text!
For that, you need the strcmp or strncmp standard library function.

See your ‘C’ textbook.

Your approach here needs to be:
1. Isolate the components (tokens) of the message;
2. Determine the content of each component.

Hi !

As said Awneil, to compare 2 strings you need to use the strcmp function. This is how to use it :

if( strcmp( token , “comm=1” ) == 0)
{

}

By the way, the test : token == “comm=1”, compare the pointers of the strings…

strcmp returns zero if the strings are the same - it is left as an exercise for the student to look-up what strcmp returns if the strings differ…

As a further exercise, look-up strncmp, and consider how this may be advantageous.

Note that strcmp and strncmp are both standard ‘C’ library functions - so any ‘C’ textbook should provide the answers…

I can’t remember if you said these commands were to be typed manually by people?
If they are, they will be a lot easier to use if they are not case-sensitive…

In some cases, but this will be rare. There is one PC program running on the internet and thru this program you can send defined patterns.

Thank you guys for your replay !