Replacing UNIT_x with variable

Not sure if I should post this here as it is more of a newby programming question but since it is within X10 topic here it is:

I want to cycle through 12 UNIT_number so I have this array:

char* devices[]={
"UNIT_1", // dining room
"UNIT_2", // front outside
"UNIT_3", // back deck
"UNIT_4", // stairs up
"UNIT_5", // front window
"UNIT_6", // hut
"UNIT_7", // back garage
"UNIT_8", // entrance
"UNIT_9", // Stairs down
"UNIT_10", // basement ceiling
"UNIT_11", // basement lamps
"UNIT_12"}; // basement over TV

how would I go about replacing UNIT_1 with device[i]

for (int i=0; i<11; i++){
  
   if timenow == Ontime[i] && stat[i] == 0;
     myHouse.write(HOUSE_J, UNIT_1, 1);
     myHouse.write(HOUSE_J, ON, 1);
    
  }

As written in that for loop, UNIT_1 isn't a string, it's probably a #define or a const. You need to figure out the data type and create an array of those. Lets say it's an int:

int devices[]={
  UNIT_1, // dining room
  UNIT_2, // front outside
  UNIT_3, // back deck
  UNIT_4, // stairs up
  UNIT_5, // front window
  UNIT_6, // hut
  UNIT_7, // back garage
  UNIT_8, // entrance
  UNIT_9, // Stairs down
  UNIT_10, // basement ceiling
  UNIT_11, // basement lamps
  UNIT_12 // basement over TV
};

Then in the code:

myHouse.write(HOUSE_J, devices[i], 1);

You should also fix that if statement, as it's completely wrong in numerous aspects (missing parenthesis and braces, erroneous semi-colon)

Yes I am aware of my if statement, I just wrote this here quickly.
as for my issue it doesn't work.

I am using

#include <x10.h>
#include <x10constants.h>

Looking into the source of these I see that it is byte data type.
I tried:

byte devices[]={
  UNIT_1, // dining room
  UNIT_2, // front outside
  UNIT_3, // back deck
  UNIT_4, // stairs up
  UNIT_5, // front window
  UNIT_6, // hut
  UNIT_7, // back garage
  UNIT_8, // entrance
  UNIT_9, // Stairs down
  UNIT_10, // basement ceiling
  UNIT_11, // basement lamps
  UNIT_12 // basement over TV
};

but when I try to compile I get error:
too many initializers for 'byte []'

Post your full code and full error message.

The following:

#include <x10.h>
#include <x10constants.h>

byte devices[]={
  UNIT_1, // dining room
  UNIT_2, // front outside
  UNIT_3, // back deck
  UNIT_4, // stairs up
  UNIT_5, // front window
  UNIT_6, // hut
  UNIT_7, // back garage
  UNIT_8, // entrance
  UNIT_9, // Stairs down
  UNIT_10, // basement ceiling
  UNIT_11, // basement lamps
  UNIT_12 // basement over TV
};

void setup()
{
  
}

void loop()
{
  
}

Compiles just fine for me.

Well... here is my complete code and getting the error.
Note, this code may appear a little funny to people on here, it is an ongoing process...

#include <Time.h>
#include <x10.h>
#include <x10constants.h>

#define zcPin 2
#define dataPin 3

String timenow;

byte devices[]={
"UNIT_1", // dining room
"UNIT_2", // front outside
"UNIT_3", // back deck
"UNIT_4", // stairs up
"UNIT_5", // front window
"UNIT_6", // hut
"UNIT_7", // back garage
"UNIT_8", // entrance
"UNIT_9", // Stairs down
"UNIT_10", // basement ceiling
"UNIT_11", // basement lamps
"UNIT_12"}; // basement over TV

char* Ontime[]={"8:0","8:30","8:30","8:10","8:10","8:10","8:30","8:10","8:10","","",""};

char* Offtime[]={"8:1","3:0","3:0","0:30","0:30","0:30","3:0","0:30","0:30","","",""};

// t for on/off from timer, m for manual, will figure something better later...
char* mode[]={"t","t","t","t","t","t","t","t","t","m","m","m"};

// 0= on/off lights, >0 = Dimmed lights
int val[]={10,0,0,30,0,0,0,30,30,30,0,0};

// 0=off, 1=on
int stat[]={0,0,0,0,0,0,0,0,0,0,0,0};

x10 myHouse =  x10(zcPin, dataPin);

void setup()
{
  Serial.begin(9600);
// will get time from NTP when I receive Ethenet shield, for now...
  setTime(7,59,55,6,7,13); // set time to noon Jan 1 2011
//  myHouse.write(HOUSE_B, UNIT_1, 1);
//  myHouse.write(HOUSE_B, OFF, 1);
}

void loop()
{
// check what time it is
  timenow = String(hour()) + ":" + String(minute());
  
  for (int i=0; i<11; i++){
  
// Turn on or off devices that are timed
    if (mode[i] == "t"){
      if (timenow == Ontime[i] && stat[i] == 0){
        myHouse.write(HOUSE_B, devices[i], 1);
          if (val[i] > 0){
            myHouse.write(HOUSE_B, ON, 1);
            myHouse.write(HOUSE_B, DIM, val[i]);
            stat[i] = 1;
            Serial.print("dim ");
            Serial.print(val[i]);
            Serial.print(" and stat = ");
            Serial.print(stat[i]);
            Serial.println("");
        }
      }
    }

    if (mode[i] == "t"){
      if (timenow == Offtime[i] && stat[i] == 1){
        myHouse.write(HOUSE_B, devices[i], 1);
        myHouse.write(HOUSE_B, OFF, 1);
        stat[i] = 0;
        Serial.print("off ");
        Serial.print(val[i]);
        Serial.print(" and stat = ");
        Serial.print(stat[i]);
        Serial.println("");
       }
    }
 
// if button1 pressed set TV time
  
  
// if button2 pressed set good night time
    
  
// check door switches and beep if open
  }

}

I am getting this error:

HouseControl:22: error: too many initializers for 'byte []'

oh my God...
I put quotes on my values!

JABfreak:
oh my God...
I put quotes on my values!

Good example of why copying and pasting your whole code from the start is the better than posting from memory, or assuming what the other person posted is what your wrote into your code.

Totally agree and will do better next time!

Thanks for your help.