Constant Declaration
cbailey
Posts: 15
I am confused by how the Netlinx compiler interprets the following code for constant declaration:
I would also expect that const ACCEPT would evaluate to a string of length 3 with the value = OK,$0D.
This is not the case. Through the debug window it appears that ACCEPT has length 14 with value = 'OK',DELIMITER (NOTE: both the single quotes and comma are part of the value of ACCEPT).
Does anyone have some insight as to why the compilier interprets this code in this way?
DEFINE_CONSTANT CONSTANT CHAR DELIMITER = $0D; CONSTANT CHAR ACCEPT[] = "'OK',DELIMITER";I would expect that const DELIMITER would evaluate to a char with value = 13 (or $0D in ascii).
I would also expect that const ACCEPT would evaluate to a string of length 3 with the value = OK,$0D.
This is not the case. Through the debug window it appears that ACCEPT has length 14 with value = 'OK',DELIMITER (NOTE: both the single quotes and comma are part of the value of ACCEPT).
Does anyone have some insight as to why the compilier interprets this code in this way?
0
Comments
Basically, you can't use double quotes in constant delcarations, so that's probably messing up your efforts the most.
- Chip
That tech note does explain quite a bit on the subject. I guess I shouldn't just assume that the standards of Netlinx code carry over from one section of the code to the next.
For future reference, here's the updated code that behaves properly:
--D
I do the same, especially when declaring multiple Define_Variable sections that can be managed with code folding.