Error with Structure Array
normschaef
Posts: 17
All:
I've added a structure, then tried to create an array based on that structure. On compile I get: Symbol [ROOMARRAY] already defined in scope.
Here's my code
This seems to be the syntax in the help file. However, the file also mentions the array and elements should be in braces. I've tried several variations of braces, but then I get an "Initializer is not a constant" error.
TIA for any help.
Norm
I've added a structure, then tried to create an array based on that structure. On compile I get: Symbol [ROOMARRAY] already defined in scope.
Here's my code
DEFINE_TYPE STRUCTURE sRoomInfo { CHAR LongName [40] CHAR ShortName [40] CHAR IPAddress [40] } DEFINE_VARIABLE sRoomInfo RoomArray[4] RoomArray[1].LongName = 'Living Room' RoomArray[1].ShortName = 'LR' RoomArray[1].IPAddress = '192.168.1.100' RoomArray[2].LongName = Kitchen' RoomArray[2].ShortName = 'K' RoomArray[2].IPAddress = '192.168.1.101' RoomArray[3].LongName = 'Bedroom 1' RoomArray[3].ShortName = 'BR 1' RoomArray[3].IPAddress = '192.168.1.200' RoomArray[4].LongName = 'Bedroom 1' RoomArray[4].ShortName = 'BR2' RoomArray[4].IPAddress = '192.168.1.201'
This seems to be the syntax in the help file. However, the file also mentions the array and elements should be in braces. I've tried several variations of braces, but then I get an "Initializer is not a constant" error.
TIA for any help.
Norm
0
Comments
Hi Norm!
this section of code is the problem:
essnetially you are trying to re-define the variable.
The easiest way to keep what you have and not have to retype like crazy is to just put the code in the DEFINE_START section.
In this case, I couldn't trust the documentation ....
Thanks for setting me on the straight and narrow.
Norm