can you see what I am doing wrong?

I am fairly new to this and trying to write a small program
this is a small section of it :-

1  if (latch3 == 0) {    //stops this repeating for the time loop below
2   if (switchState3 == LOW) {     //if switch three is pressed
3      // turn  b1yel1 b1yel2  b2yel1 and b3red red on:
4      latch3 = (1);
5      digitalWrite(b1yel1, HIGH);   //  I have put this line in to prove b1yel1 is high
6      if (b1yel1 == HIGH)  
7        digitalWrite(b1yel2, HIGH);    //if b1yel1 is on put b1yel2 on
8        
9      digitalWrite(b2red, LOW);      //turn signal 2 red off
10      digitalWrite(b2yel1, HIGH);    //turn signal 2 yel on
11      digitalWrite(b3red, HIGH);     //turn signal 3 to red
12      digitalWrite(b3grn, LOW); 
13     }    //put a time loop in here to stop it repeating then turn latch low (not made yet)
14   }
15     if (switchState3 == HIGH)
16     latch3 = (0);

I must be missing something. I have included the line numbers for this forum. For some reason line 7 doesn't execute?
If I rem line six out it does ( // ), but I only want it to turn b1yel2 on if b1yel1 is on?
Can you see what I am doing wrong?
Thanks,
Bob.

It appears b1yel1 is a pin number not a LOW/HIGH value, so the if statement will fail on any pin number that isn't 1 and skip line 7

5      digitalWrite(b1yel1, HIGH);   //  I have put this line in to prove b1yel1 is high
6      if (b1yel1 == HIGH)  
7        digitalWrite(b1yel2, HIGH);

You could check the pin is high, but you just set it high, so only an interrupt could change it, which you probably aren't using.

5      digitalWrite(b1yel1, HIGH);   //  I have put this line in to prove b1yel1 is high
6      if (b1yel1 == HIGH)

Is the pin number in b1yel1 equal to 1? That is the ONLY way that the if statement will be true.

thank you pYro_65 that solves my problem

      test = digitalRead(b1yel1);
      if (test == 1)  
        digitalWrite(b1yel2, HIGH);    //if b1yel1 is on put b1yel2 on

I don't know how tidy you think this is or whether there is a shorter option but it now works.
Thank you.
Bob.

sorry pauls I was making a reply when you added yours

5      digitalWrite(b1yel1, HIGH);   //  I have put this line in to prove b1yel1 is high
6      if (b1yel1 == HIGH)  
7        digitalWrite(b1yel2, HIGH);

Why doesn't it work if I just change line 6 to
if (b1yel1 == 1)
?

What pin are you setting high, http://arduino.cc/forum/index.php/topic,160932.msg1204291.html#msg1204291

There is a difference between pin numbers and pin values You are comparing a pin number with HIGH, completely illogical,
just remove the 'if' dang nabbit, the pin is high cos you set it high, there is no need to assume it has changed unless you typed the code below inside an interrupt.

digitalWrite(b1yel1, LOW);

matelot:
Why doesn't it work if I just change line 6 to
if (b1yel1 == 1)
?

Because that if statement is checking the value of b1yel1, which is a pin number.
What you're trying to do is to check the state of that pin, not it's value.

matelot:

5      digitalWrite(b1yel1, HIGH);   //  I have put this line in to prove b1yel1 is high

6      if (b1yel1 == HIGH) 
7        digitalWrite(b1yel2, HIGH);



Why doesn't it work if I just change line 6 to 
if (b1yel1 == 1)
?

Because the value of b1yel1 is the number of pin you defined in your setup, and not it state.

What you can do if you still need that "IF" is this.

if (digitalRead(b1yel1) == HIGH)  {
digitalWrite(b1yel2, HIGH);
}