Sending a Constant in a String
TurnipTruck
Junior Member
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.
Comments
-
Don't use double quote string expressions in define_constant -- it doesn't work as you would hope.
Try something like:
char cnPowerSet = {$A0,$60} -
Hedberg wrote:
Try something like:
char cnPowerSet = {$A0,$60}
Tried that too. Same result. -
Try to use it with a variable:
Some like that:
define_variable
CHAR astrPowerSet[]= {$A0,$60}
SEND_STRING dvDevice,"astrPowerSet,$0A,$0D" -
I made an error in my prior post.
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. -
define as a variable, then fill the variable in define_start?
-
just do this
Code:
DEFINE_CONSTANT
CHAR cnPowerSet[4] //four elements
DEFINE START
cnPowerSet = "$A0,$60,$0A,$0D" //fill array -
just do this
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. -
point taken, other side of the coin when doing string queing, I can change the element value lets say I need to do checksums, I know it needs 4 elements for power lets say, so for that I just declare a variable type array and fill it as I go along
Categories
- All Categories
- 2.5K AMX General Discussion
- 922 AMX Technical Discussion
- 514 AMX Hardware
- 502 AMX Control Products
- 3 AMX Video Distribution Products
- 9 AMX Networked AV (SVSI) Products
- AMX Workspace & Collaboration Products
- 3.4K AMX Software
- 151 AMX Resource Management Suite Software
- 386 AMX Design Tools
- 2.4K NetLinx Studio
- 135 Duet/Cafe Duet
- 248 NetLinx Modules & Duet Modules
- 57 AMX RPM Forum
- 228 MODPEDIA - The Public Repository of Modules for Everyone
- 943 AMX Specialty Forums
- 2.6K AMXForums Archive
- 2.6K AMXForums Archive Threads
- 1.5K AMX Hardware
- 432 AMX Applications and Solutions
- 249 Residential Forum
- 182 Tips and Tricks
- 146 AMX Website/Forums