String Literals
sonny
Posts: 208
Anyone know if there is a difference in the following commands...
SEND_STRING someDevice, 'Hello World'
and
SEND_STRING someDevice, "'Hello World'"
Thanks
SEND_STRING someDevice, 'Hello World'
and
SEND_STRING someDevice, "'Hello World'"
Thanks
0
Comments
SEND_STRING someDevice, "'Hello ', StringVar, 13"
My habit is to always use the double quotes in any case.
The second "HelloWorld'" is a pre-defined variable
The first command will work if it is all you want to send but if you want to add a variable with it, then you must use the " ". It's good practice to ALWAYS use the " " in all command like:
SEND_STRING someDevice, " 'Hello World' "
with VARIABLE:
SEND_STRING someDevice, " 'Hello World', someVAR"
Hope this helps!
I've seen documentation with the literal within single ticks by themselves, and with double quotes around the single ones. Didn't think there was a difference, just wasn't sure.
DEFINE_CONSTANT
CHAR EF_2280[] = 'F01'
CHAR PGM_VOLUME_UP[] = "EF_2280,'MACROX4'"
BUTTON_EVENT[dvTPANEL,51]
{
PUSH:
{
SEND STRING dvA_CONF,"PGM_VOLUME_UP"
}
}
it ended up sending "EF_2280,'MACROX4'" out of the RS-232 port.
Assigning CHAR PGM_VOLUME_UP[12] in the DEFINE_VARIABLE section instead, and then adding the statement PGM_VOLUME_UP = "EF_2280,'MACROX4'" in the DEFINE_START section fixed the issue and sent "F01MACROX4".
Have not researched further why this is the case, but I have become very careful with strings in the DEFINE_CONSTANT section.
just a guess, but the statement "EF_2280,'MACROX4'" is an executable statement that happens during runtime to dynamically build a string. Stuff that goes in the DEFINE_CONSTANT section gets resolved at compile time, and the compiler is treating this differently.