Home AMX User Forum NetLinx Studio

Multiple Instances of Single Include File

I have written and include file to control an Onkyo Professional tuner. I have two tuners in the same system and would like to control them both independently. What is the best way to reuse my include file? The only thing I can think of is renaming it and then changing the names of all the variables within so that I do not get an already defined error when I compile. Is there a better way to do this?

Comments

  • a_riot42a_riot42 Posts: 1,624
    remeolb wrote: »
    I have written and include file to control an Onkyo Professional tuner. I have two tuners in the same system and would like to control them both independently. What is the best way to reuse my include file? The only thing I can think of is renaming it and then changing the names of all the variables within so that I do not get an already defined error when I compile. Is there a better way to do this?

    Turn it into a module that will control an arbitrary amount of tuners using an arbitrary amount of UIs. The multiple include way with slightly different variable names in each is the path to madness.
    Paul
  • DHawthorneDHawthorne Posts: 4,584
    Convert it to a module. You can't instance an include file, it will just paste the identical code in your program twice, and you will get a huge number of compile errors for duplicate definitions. Modules automatically deal with that, and most includes will convert fairly easily.
  • ipssheldonipssheldon Posts: 106
    If your include file is a function that you pass parameters into, then you can include a single copy of the include file and pass whatever pointers you need to into the function call. Use arrays to store parameters for each device so that you can update the parameters uniquely by device but still access those parameters outside of the function. That is something that you can't easily do with a module (unless you send values via SEND_STRINGS and SEND_COMMANDS in and out of the module.

    I do this all the time and it works fine.

    Just 2 different ways to write code.
Sign In or Register to comment.