Trouble with Heads Tails program from Purdums' book

Hi everyone,
I've attempted to write my own heads / tails program as suggested by Purdums' book so this is what i've written:

// My design for a Heads or Tail program

#define IOPIN12 12
#define IOPIN13 13
Long Number;
int OddorEven;
int led1 = IOPIN12;
int led2 = IOPIN13;

void setup() {
randomSeed(analogRead(A0));
pinMode(led1, OUTPUT);
pinMode(led2, OUTPUT);

Serial.begin(9600);
}

void loop() {
digitalWrite(led1, LOW);
digitalWrite(led2, LOW);
Number = random(0-255);
OddorEven = (Number % 2);
// Serial.println(OddorEven);
if (OddorEven == 0) {
// Serial.println(OddorEven);
digitalWrite(led1, HIGH);
}else {
digitalWrite(led2, HIGH);
delay(1000);
}

I can see in the serial window that the OddorEven variable creates 1's and 0's after I mod the random number variable, 'Number'. But when I check the same variable again after the if statement, I see all 0's, hence only one LED lights and stays lit. Why is this happening?

Additionally i then looked at Purdums' program and when I load that in, it gets a compiler error because it doesn't recognize the generateRandomNumber variable. Why?

Thanks in advance!
Bryan

This is Purdum's program:

/*
Heads or Tails
Turns on an LED which represents head or tails. The LED
remains on for about 3 seconds and the cycle repeats.
Dr. Purdum, July 12, 2012
*/
// define the pins to be used.
// give it a name:
#define HEADIOPIN 13 // Which I/O pins are we using?
#define TAILIOPIN 12
#define PAUSE 3000 // How long to delay?
#define REST 2000
int head = HEADIOPIN;
int tail = TAILIOPIN;
long randomNumber = 0L; // Use the "L" to tell compiler it's a long data type, not an int.
// the setup routine runs once when you press reset:
void setup() {
// initialize each of the digital pins as an output.
pinMode(head, OUTPUT);
pinMode(tail, OUTPUT);
randomSeed(analogRead(0)); // This seeds the random number generator
}
// the loop routine runs over and over again forever:
void loop() {
randomNumber = generateRandomNumber();
digitalWrite(head, LOW); // Turn both LEDs off
digitalWrite(tail, LOW);
delay(PAUSE - REST); // Let them see both are off for a time slice
if (randomNumber % 2 == 1) { // Treat odd numbers as a head
digitalWrite(head, HIGH);
} else {
digitalWrite(tail, HIGH); // Even numbers are a tail
}
delay(PAUSE); // Pause for 3 seconds
}
long generateRandomNumber()
{
return random(0, 1000000); // Generate random numbers between 0 and one million
}

I loaded the code you posted and it compiled without error on 1.6.0 of the IDE. I added a Serial object to the program so you can see the output on the Serial monitor. I also removed the delay so it would run faster.

/*
 Heads or Tails
 Turns on an LED which represents head or tails. The LED
 remains on for about 3 seconds and the cycle repeats.
 Dr. Purdum, July 12, 2012
 */
// define the pins to be used.
// give it a name:
#define HEADIOPIN 13 // Which I/O pins are we using?
#define TAILIOPIN 12
#define PAUSE 3000 // How long to delay?
#define REST 2000

int head = HEADIOPIN;
int tail = TAILIOPIN;
long randomNumber = 0L; // Use the "L" to tell compiler it's a long data type, not an int.
// the setup routine runs once when you press reset:

void setup() {
  // initialize each of the digital pins as an output.
  Serial.begin(9600);
  pinMode(head, OUTPUT);
  pinMode(tail, OUTPUT);
  randomSeed(analogRead(0)); // This seeds the random number generator
}
// the loop routine runs over and over again forever:
void loop() {
  randomNumber = generateRandomNumber();
  digitalWrite(head, LOW); // Turn both LEDs off
  digitalWrite(tail, LOW);
  //delay(PAUSE - REST); // Let them see both are off for a time slice
  if (randomNumber % 2 == 1) { // Treat odd numbers as a head
    digitalWrite(head, HIGH);
    Serial.println("Odd");
  } else {
    digitalWrite(tail, HIGH); // Even numbers are a tail
    Serial.println("Even");
  }
 // delay(PAUSE); // Pause for 3 seconds
}

long generateRandomNumber()
{
  return random(0, 1000000); // Generate random numbers between 0 and one million
}

BTW, you should read Nick Gammon's two posts at the top of this Forum on how to use code tags for posting your code. Without using code tags, the source code often gets mangled.

Thank you Econ. I'm not quite sure why it works now vs not before. But i have a suspicion that previous programs running required me to reload a new program more than once. At any rate it works now. And i will read up on code tags !