not declared in scope error.

I was using examples and copying them into one program to work and it was sating that some functions in the Librarys wren't declared in the scope. I went back to the example and It worked perfectly.

Here is the code

const int chipSelectPin = 10;
const int NRSTPD = 5;

int StatoSwitch = 0;
int i = 0; 
int val = LOW; 
int pre_val = LOW; 
int state = 0; 
int RFID_val;

#define MAX_LEN 16

void setup(){

  Serial.begin(9600);
  SPI.begin();
  
  pinMode(chipSelectPin,OUTPUT);              // Set digital pin 10 as OUTPUT to connect it to the RFID /ENABLE pin 
  digitalWrite(chipSelectPin, LOW);         // Activate the RFID reader
  pinMode(NRSTPD,OUTPUT);                     // Set digital pin 10 , Not Reset and Power-down
  digitalWrite(NRSTPD, HIGH);
  pinMode(ALARMSOUNDER, OUTPUT); 
  

  myRFID.AddicoreRFID_Init();  

}

void loop()

{
  myRFID.AddicoreRFID_Init();  
  //Find tags, return tag type
  status = myRFID.AddicoreRFID_Request(PICC_REQIDL, str);  
  if (status == MI_OK)
  {
            Serial.println("RFID tag detected");
          Serial.print(str[0],BIN);
            Serial.print(" , ");
          Serial.print(str[1],BIN);
            Serial.println(" ");
  }

  //Anti-collision, return tag serial number 4 bytes
  status = myRFID.AddicoreRFID_Anticoll(str);
  if (status == MI_OK)
  {
            checksum1 = str[0] ^ str[1] ^ str[2] ^ str[3];
            Serial.println("The tag's number is  : ");
          //Serial.print(2);
          Serial.print(str[0]);
            Serial.print(" , ");
          Serial.print(str[1],BIN);
            Serial.print(" , ");
          Serial.print(str[2],BIN);
            Serial.print(" , ");
          Serial.print(str[3],BIN);
            Serial.print(" , ");
          Serial.print(str[4],BIN);
            Serial.print(" , ");
            Serial.println(checksum1,BIN);

  if(str[0] == 156)                      //You can change this to the first byte of your tag by finding the card's ID through the Serial Monitor
           {
               RFID_val = HIGH;
           } 

         


  
  StatoSwitch = digitalRead(pinSwitch);
  if (StatoSwitch == LOW && RFID_val = LOW) { 

  Serial.println("HIGH!");
  for(i = 0; i < 255; i = i + 2)
        {
            analogWrite(ALARMSOUNDER, i);
            delay(10);
        }
        for(i = 255; i > 1; i = i - 2)
        {
            analogWrite(ALARMSOUNDER, i);
            delay(5);
        }
        for(i = 1; i <= 10; i++)
        {
            analogWrite(ALARMSOUNDER, 200);
            delay(100);
            analogWrite(ALARMSOUNDER, 25);
            delay(100);
        }

  }
  else if (StatoSwitch == HIGH && RFID_val == HIGH)
    {
        analogWrite(ALARMSOUNDER, 0);
        delay(5000);
        RFID_val = LOW;
    }
  pre_val = val; 
  myRFID.AddicoreRFID_Halt();  
}

Basically I need help on If it's my problem or the compiler error.

In Nick Gammon's first post at the top of this Forum is a post for useful links to C topics. One broad heading is C++ Programming and has a sub-topic called Scope. Give that a read and see if it helps answer your question.

There are loads of things wrong with this program.
Here are the error messages

Arduino: 1.5.6-r2 (Windows 7), Board: "Arduino Uno"

sketch_may17a.ino: In function 'void setup()':
sketch_may17a:16: error: 'SPI' was not declared in this scope
sketch_may17a:22: error: 'ALARMSOUNDER' was not declared in this scope
sketch_may17a:25: error: 'myRFID' was not declared in this scope
sketch_may17a.ino: In function 'void loop()':
sketch_may17a:32: error: 'myRFID' was not declared in this scope
sketch_may17a:34: error: 'status' was not declared in this scope
sketch_may17a:34: error: 'PICC_REQIDL' was not declared in this scope
sketch_may17a:34: error: 'str' was not declared in this scope
sketch_may17a:35: error: 'MI_OK' was not declared in this scope
sketch_may17a:46: error: 'MI_OK' was not declared in this scope
sketch_may17a:48: error: 'checksum1' was not declared in this scope
sketch_may17a:72: error: 'pinSwitch' was not declared in this scope
sketch_may17a:73: error: lvalue required as left operand of assignment
sketch_may17a:78: error: 'ALARMSOUNDER' was not declared in this scope
sketch_may17a:83: error: 'ALARMSOUNDER' was not declared in this scope
sketch_may17a:88: error: 'ALARMSOUNDER' was not declared in this scope
sketch_may17a:97: error: 'ALARMSOUNDER' was not declared in this scope
sketch_may17a:103: error: expected `}' at end of input

  This report would have more information with
  "Show verbose output during compilation"
  enabled in File > Preferences.

Libraries not #included, variables not declared and syntax errors

Where did you get it from ?