View Single Post
  #3   Spotlight this post!  
Unread 20-02-2005, 10:07
Ryan M. Ryan M. is offline
Programming User
FRC #1317 (Digital Fusion)
Team Role: Programmer
 
Join Date: Jan 2004
Rookie Year: 2004
Location: Ohio
Posts: 1,508
Ryan M. has much to be proud ofRyan M. has much to be proud ofRyan M. has much to be proud ofRyan M. has much to be proud ofRyan M. has much to be proud ofRyan M. has much to be proud ofRyan M. has much to be proud ofRyan M. has much to be proud ofRyan M. has much to be proud of
Re: C: Cascading for Aliases?

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.
__________________