SEND_STRING issue
ubernyako
Posts: 12
Alright, so I do AMX from time to time, and this time it was after really really long break, had an issu about this:
DEFINE_CONSTANT CHAR MitsubishiON232[] = "'00vP 1',$0D" // ... // And after some code SEND_STRING dvVidWall232, MitsubishiON232doesn't work. But this:
SEND_STRING dvVidWall232, "'00vP 1',$0D"works just fine. Unfortunatelly I didn't screencap the notification messages, but strings sent to device were the same. The result is totally different though. Point me where I'm wrong here please
0
Comments
Take a closer look at the Notifications and you’ll see that the strings sent to the device were not the same.
You’re first example:
Line 1 (05:14:02):: String To [5001:1:111]-
You’re second example
Line 3 (05:14:02):: String To [5001:1:111]-[00vP 1$0D]
Drop you constant into debug and you’ll see that it has a length of 12 and not the 7 characters you are expecting.
Try this:
SEND_STRING dvVidWall232, "MitsubishiON232"
Putting quotes around your variable tells the command explicitly that it's a string, and will be handled that way in terms of glyph translation, etc. I think what's happening is without the quotes it's handling the imbedded ' marks as literal characters, not as 'whatever is inside these is ASCII'.
CHAR MitsubishiON232[] = "'00vP 1',$0D"
To this:
CHAR MitsubishiON232[] = {'0','0','v','P',' ','1',$0D}
it will work the way you intended.
the RHS of the declaration/definition IS NOT a constant, it's a string expression. Apparently, the compiler interprets everything inside the double quotes as a string literal.
How to Initialize Character Strings in the DEFINE_CONSTANT and DEFINE_VARIABLE Sections
http://amx.com/techsupport/techNote.asp?id=531
This post reminded me that I always struggle with this question so I just added it to my current system and it will become part of all future systems like I do with this: in all systems. The more reminders for me the better!
Folded & Unfolded screenshots....