String Literals
sonny
Junior Member
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
Comments
-
As stated, none. However, if you need to mix ASCII characters with variables, decimal or hex values, you need the quotes, as in:
SEND_STRING someDevice, "'Hello ', StringVar, 13"
My habit is to always use the double quotes in any case. -
The first 'HelloWorld' is a literal -ASCII
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! -
Thanks for the replies...
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. -
You will need to be a little carefull when dealing with variables in Netlinx as some may operate differently depending on the section of code you are in. Learned this the hard way. Here's a sample:
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. -
DEFINE_CONSTANT
CHAR EF_2280[] = 'F01'
CHAR PGM_VOLUME_UP[] = "EF_2280,'MACROX4'"
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.
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