strcomp doesn't seem to evaluate right - Please help
Shane M
Posts: 58
I am basically reading from a serial port. (Currently just typing a word).
My routine should receive the string (it does), see if the string received (strin)·is DIFFERENT from the last time (using strlast) and if NOT the same I am having my EMIC text to speech chip say the word AND copy the strin to strlast.· If it IS the same it should simply ignore the block.
I was on support for a while and even the support guy was stumped.
Here is the code snippet:
Basically it always evaluates as if the strings don't match.
Can anyone help me?
Shane Merem
www.websiteforge.com
www.magnusoft.com
My routine should receive the string (it does), see if the string received (strin)·is DIFFERENT from the last time (using strlast) and if NOT the same I am having my EMIC text to speech chip say the word AND copy the strin to strlast.· If it IS the same it should simply ignore the block.
I was on support for a while and even the support guy was stumped.
Here is the code snippet:
repeat 'serial.RxStrTime(5000,@strin) serial.RxStr(@strin) 'if the string received is different then say the word if (not strcomp(@strin,@strlast)) emic.say(@strin, true) 'have emic say text serial.str(@strin) ' this is just a debug serial dump for myself emic.WaitNotBusy ' wait until emic is not busy CopyString(@strlast,@strin) ' copy the strin to strlast (this DOES work) emic.say(@strlast, true) 'have emic say text serial.dec(strsize(@strin)) ' I dumped this to make sure the strings were viewed as the same size serial.dec(strsize(@strlast)) emic.WaitNotBusy 'this is my copy routine. It does work. PUB CopyString(dest,src) byteMove(dest,src,15) dest[noparse][[/noparse]strsize(src)+1]:=0
Basically it always evaluates as if the strings don't match.
Can anyone help me?
Shane Merem
www.websiteforge.com
www.magnusoft.com
Comments
Byte strin[noparse][[/noparse]15]
Byte strlast[noparse][[/noparse]15]
Thanks for your help
strin[noparse][[/noparse] 0 ] := 0
strlast[noparse][[/noparse] 0 ] := 0
CopyString also has to be
bytemove(dest,src,strsize(src)+1)
You don't need to add another zero terminator since the bytemove copies the one from the source string.
The copystring change is what ultimately fixed it. Thank you!