Loading fixed data into a structure array
sijones
Posts: 16
Hi,
I've got the following structure defined:
STRUCTURE _Button_Command
{
INTEGER Button_Number // Button number
CHAR Button_Command[20] // RS232 Command
}
_Button_Command _sButton_Command[]
Is there a shorthand method of loading fixed data into the structure array?
An example of the data I want to load is:
1 , $02,'3','0','0','5','A','2',$00,'1',$00,$03
2 , $02,'3','0','0','5','A','2',$00,'2',$00,$03
3 , $02,'3','0','0','5','A','2',$00,'3',$00,$03
4 , $02,'3','0','0','5','A','2',$00,'4',$00,$03
5 , $02,'3','0','0','5','A','2',$00,'5',$00,$03
Thanks for looking.
Steve
I've got the following structure defined:
STRUCTURE _Button_Command
{
INTEGER Button_Number // Button number
CHAR Button_Command[20] // RS232 Command
}
_Button_Command _sButton_Command[]
Is there a shorthand method of loading fixed data into the structure array?
An example of the data I want to load is:
1 , $02,'3','0','0','5','A','2',$00,'1',$00,$03
2 , $02,'3','0','0','5','A','2',$00,'2',$00,$03
3 , $02,'3','0','0','5','A','2',$00,'3',$00,$03
4 , $02,'3','0','0','5','A','2',$00,'4',$00,$03
5 , $02,'3','0','0','5','A','2',$00,'5',$00,$03
Thanks for looking.
Steve
0
Comments
Probably for ease of viewing, I'd just do it in the define_start section.
Thanks for your reply.
What I'm trying to find out is if there is a way of loading the data into the structure array when it is first declared?
Something like:
Button_Command _sButton_Command[] =
{
1 , $02,'3','0','0','5','A','2',$00,'1',$00,$03,
2 , $02,'3','0','0','5','A','2',$00,'2',$00,$03,
3 , $02,'3','0','0','5','A','2',$00,'3',$00,$03,
4 , $02,'3','0','0','5','A','2',$00,'4',$00,$03,
5 , $02,'3','0','0','5','A','2',$00,'5',$00,$03,
}
I've tried lots of ways of doing it but none of them compile.
Kind regards,
Steve
but I think you need to make your integer declaration differently.
STRUCTURE _Button_Command
{
INTEGER Button_Number[how ever many commands] // Button number
CHAR Button_Command[how ever many commands][20] // RS232 Command
}
If you want to copy data into an array of structures you will need a structure to copy it from.
_Button_Command init
init.Button_Number = 1
init.Button_Command = "$02,'3','0','0','5','A','2',$00,'1',$00,$03"
_sButton_Command[1] = init
You might want to rethink your variable names though as its a little confusing. I don't see the point of the variables having the word button prepended since you already know its part of a button-command structure. IE:
STRUCTURE _BtnCmd
{
INTEGER Btn
CHAR Cmd[20]
}
Steve