Your idea should work. My team is doing it in basically the same way. Here's what I'd do.
commands.h
Code:
extern struct commands *command_list;
/* externs for the actual command lists */
extern struct command_list_1[];
extern struct command_list_2[];
commands.c
Code:
#include "commands.h"
struct commands *command_list;
/* actual command lists */
struct commands command_list_1 = {
/* commands */
{NULL, 0, 0, 0}
}
struct commands command_list_2 = {
/* different command list */
{NULL, 0, 0, 0}
}
user_routines_fast.c (at top of file)
Code:
#include "commands.h"
user_routines_fast.c (in autonomous function, before the while loop begins)
Code:
if(dipswitch == 0)
command_list = command_list_1; // This makes the command_list pointer look at command_list_1. Because arrays in C are pointers anyways, this _should_ work... Should. :)
else if(dipswitch == 1)
command_list = command_list_2;
Then, add the newly created commands.c to the project.
So yeah, your idea works.