Loading fixed data into a structure array
sijones
Junior Member
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
Comments
-
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
Probably for ease of viewing, I'd just do it in the define_start section. -
Hi Eric,
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 -
Nope, no can do.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? -
For that particular set of data you can do something like this: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,$03FOR (x=1; x<=5; x++) { _sButton_Command[x].Button_Number = x _sButton_Command[x].Button_Command = "$02,'3','0','0','5','A','2',$00,ITOA(x),$00,$03" } -
I'm not a my computer with NS to try this but it might look something like...
DEFINE_START _Button_Command.Button_Number[01]=1 _Button_Command.Button_Command[01]="$02,'3','0','0','5','A','2',$00,'1',$00,$03" _Button_Command.Button_Number[02]=2 _Button_Command.Button_Command[02]="02,'3','0','0','5','A','2',$00,'2',$00,$03" //ETC....
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
} -
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
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]
} -
I usually just use an include file to load quasi-static info into structures like that. I personally find having a separate file with the config data in it to be the best way to store and read the data.
-
Many thanks for all the replies.
Steve
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