Sending a Constant in a String
TurnipTruck
Posts: 1,485
DEFINE_CONSTANT CHAR cnPowerSet[]= "$A0,$60" SEND_STRING dvDevice,"cnPowerSet,$0A,$0D"
How come the , in the constant is being sent? I've used similar methods before and never had the , in the output.
Thanks.
0
Comments
Try something like:
char cnPowerSet = {$A0,$60}
Tried that too. Same result.
Some like that:
define_variable
CHAR astrPowerSet[]= {$A0,$60}
SEND_STRING dvDevice,"astrPowerSet,$0A,$0D"
this is what it should have been:
define_constant
char cnPowerSet[] = {$A0,$60}
That results in an array with two elements and appears as expected in debug.
This:
define_constant
char cnPowerSet[] = "$A0,$60"
results in an array with seven elements and appears to be identical to this:
char cnPowerSet[] = '$A0,$60'
It appears that trying to use double quotes to define a string expression in define_constant should cause a rhs error and not compile -- instead Netlinx misinterprets the syntax and gives an unintended result.
Code:
DEFINE_CONSTANT
CHAR cnPowerSet[4] //four elements
DEFINE START
cnPowerSet = "$A0,$60,$0A,$0D" //fill array
I'm not so sure that will give you the desired results - you are declaring a constant, then changing it's value in startup. So it's either not going to work, or it's not really a constant.
It's also unnecessarily cumbersome, in my opinion, when CHAR cnPowerSet[] = {$A0,$60,$A0,$0D} gives an identical result, and is on a single line, where you can see all you need without jumping around.