Page 1 of 1

String Query

Posted: Thu Jan 05, 2012 11:39 pm
by cobra1
Hi

Im having a problem with something im working on using strings.

Basically what im doing is receiving data using the RXINT, each character received is being put into an array. The upon receiving <CR> the string is processed.

So i have a string variable set like this STRING[20]

After processing the string i fill the array with 255 values (i think that makes it blank ????)

To process the string its a case of finding out what was sent, so lets say i send "SEND TEMP" Thats 9 characters out of 20.
I have another string called SEND_TEMP[9] which = "SEND TEMP"
Now heres where im a bit stumped, i try to compare these strings to see if what was received matches any of the commands, so i compare STRING, and SEND_TEMP but they dont show as a match.

The only way they show as a match is is STRING[20] is changed to STRING[9] in the variables list. As you can imagine this sort of limits the about of characters i can now receive, especially since one of the commands is "STCH" thus potentially limiting me down to 4 character arrays.

Is there something i am doing wrong here or is this just how it is?

Re: String Query

Posted: Fri Jan 06, 2012 12:28 am
by medelec35
Hi cobra1,
I used a different method than Compare string function for 232 comms.
Maybe this may help?
http://www.matrixmultimedia.com/mmforum ... 877#p21243

Martin

Re: String Query

Posted: Fri Jan 06, 2012 9:23 am
by Steve
cobra1 wrote:After processing the string i fill the array with 255 values (i think that makes it blank ????)
Try filling with zeros, or at least setting the final (i.e. 10th) character of the STRING variable to zero.

Re: String Query

Posted: Fri Jan 06, 2012 10:01 am
by cobra1
How do I send 0 through hyperterminal?

Re: String Query

Posted: Fri Jan 06, 2012 10:10 am
by Steve
If I understand correctly, the CR character signifies the end of the string when you send it. In this case, Flowcode should add the NULL character to the end of the string when the CR is received.

Re: String Query

Posted: Fri Jan 06, 2012 10:41 am
by cobra1
Ahh I get what you mean now. I will try it when I get home from work and let you know if it works

Re: String Query

Posted: Fri Jan 06, 2012 4:58 pm
by cobra1
Hi

Filling the rest of the array with zeros works a treat, i can carry on now lol