exit status 1 expected primary-expression before '[' token

hey, any idea what this means? and what I can do to rectify it?

thanks

exit status 1 expected primary-expression before '[' token

here is my code

#include  // include the library SoftwareSerial.h to allow another serial connection

SoftwareSerial GPRS(7, 8); //RX, TX serial connections to SMS module
boolean MagSwitch; // Pin 2
boolean MomentButton; // Pin 3
boolean Relay; // Pin 4
const int MagSwitchPin = 2;
const int MomentButtonPin = 3;
const int RelayPin = 4;
String AdminNumber; // admin mobile no.

struct User // standard phone used to unlock the lock, not able to add new users
{
  String Number; // user mobile no.
  boolean Temporary; // will the user have full access or a single use code? 1 = single use
  boolean ActiveUser; // will help the program figure out if the current address is storing a user
};

User Users[4];


void setup() // runs through this function once after power up, used to set pin values etc.
{
  pinMode(MagSwitchPin, INPUT); // MagSwitch
  pinMode(MomentButtonPin, INPUT); // MomentButton
  pinMode(RelayPin, OUTPUT); // Relay
  
  GPRS.begin(9600); // Starts a serial communication with the SMS module
  Serial.begin(9600); // Starts a serial communication with the connected USB COM port
  
  GPRS.println("AT + CMGF = 1"); // Puts the modem in a mode ready to send an SMS
  delay(1000); // wait 1000ms
  //GPRS.println("AT + CPIN = "0000" "); // unlocks SIM if protected by a PIN code (replace "0000" with code) otherwise comment this line

  delay(1000); // wait 1000ms
}

void loop() // consecutively run this function over and over hence the identifier "loop"
{
  
}

void PairNewAdmin() // Puts the program in a state where it scans the last recieved message for 30 seconds and if the SMS content is PAIR then sets the sender as Admin
{
  int i = 0; // temporary variable to store count
  {
    sendSMS(AdminNumber, "request to pair new device"); // tels the existing admin the lock is being paired to a new device
  }
  
  do
  {
    String SMSRecieved = recieveSMS();
    String Sender = SMSRecieved.substring(0,12); // takes the first 13 characters from SMSRecived and sets as the value of Sender
    String Content = SMSRecieved.substring(13,33); // takes characters 13 to 33 and sets them as the value of Content
        
    delay(1000); // wait 1000ms
    i++; // i + 1

    if (Content == "PAIR")
    {
      AdminNumber = Sender;
      i = 30;
      sendSMS(AdminNumber, "DEVICE PAIRED TO LOCK"); // tell the requester that they have been successfull
      Serial.println("New device paired - " + Sender); // inform the serial moniter of the new admin
    }
  }while(i < 30); // loops for 30 seconds unless i is changed by anything other than i++
}

void CommandRecieved(String Sender, String Content)
{
  String Command = Content.substring(0,3);
  String Number = Content.substring(4,16);
  String Temporary = Content.substring(17,18);

  if (Sender == AdminNumber || Sender == User[1].Number || Sender == User[2].Number || Sender == User[3].Number || Sender == User[4].Number)
  {
    if (Command == OPEN)
    {
      Unlock();
        if (Sender == User[1].Number && User[1].Temporary == 1)
          DeleteUser(1);
        else if (Sender == User[2].Number && User[2].Temporary == 1)
          DeleteUser(2);
        else if (Sender == User[3].Number && User[3].Temporary == 1)
          DeleteUser(3);
        else if (Sender == User[4].Number && User[4].Temporary == 1)
          DeleteUser(4);
    }
    else if (Command == DLTE && Sender == AdminNumber)
    {
      if (Number == User[1].Number)
        DeleteUser(1);
      else if (Number == User[2].Number)
        DeleteUser(2);
      else if (Number == User[3].Number)
        DeleteUser(3);
      else if (Number == User[4].Number)
        DeleteUser(4);
    }
    else if (Command == EKEY && Sender == AdminNumber)
    {
      int i = 1;
      boolean a = 0;
      
      while (i < 5 && a!= 1)
      {
        if (User[i].ActiveUser == 0)
        {
          User[i].Number == Number;
          if (Temporary == 1)
          {
            User[i].Temporary == 1;
          }
          else
          {
            User[i].Temporary == 0;
          }
          User[i].ActiveUser == 1;
          a == 1;
        }
        i++;
      }
      if (a != 1)
      {
        sendSMS(AdminNumber, "Sorry but all avalable accounts are currently in use, please remove an account with the command DLTE before attempting to add a new user."
      }
    }
  }
  else
  {
    sendSMS(Sender, "Sorry, your number has not been recognised by the lock or the command used was invalid. Please contact your system administrator on " + AdminNumber + " for more support.");
    sendSMS(AdminNumber, "An invalid attempt from (" + Sender + ") was just recieved with the content " + Content); // inform the admin of another number trying to access lock
  }
}

void sendSMS(String SendTo, String Content) // the function that will be used to send an SMS to the number given in parameter "SendTo" with the content in parameter "Content"
{
  GPRS.println("AT + CMGF = 1"); // Puts the modem in a mode ready to send an SMS
  GPRS.println("AT & CMGS = " + SendTo + "+"); // tells the modem who to send the SMS to, should return >
  GPRS.println(Content); // Sends the content of the SMS to the modem
  GPRS.write( 0x1a ); // Hexadecimal ctrl+Z character used to send an SMS
}

String recieveSMS() // the function that will be used to view incoming and recieved SMS messages with "MessageLocation" being the address on the SIM card where the desired message is stored
{
  String Sender; // 13 chars
  String Message; // message content
  
  GPRS.println("AT+CNMI=2,2,0,0,0"); // AT Command to receive a live SMS
  delay (1000); // wait 1000ms

  Message = (GPRS.read());

  String SMSRecieved = (Sender + Message);
  
  return SMSRecieved;
}

void ClearMemory(byte MemoryAddress) // the function that wil be used to remove the content from address X on the SIM card with "SIMAddress being location X"
{
  GPRS.println("AT CMGR + " + MemoryAddress + " ="); // removes the message from "SIMAddress" on the SIM card
  Serial.println("Cleared message from address " + MemoryAddress + " on the primary storage device"); // prints a new line on the serial monitor to confirm that address X has been cleared
}

void DeleteUser(int UserToDelete)
{
  User[UserToDelete].Number == x;
  User[UserToDelete].Temporaray == 0;
  User[UserToDelete].ActiveUser == 0;
}

void Unlock(String User) // this function opens the lock and sends a notification to the admin stating which user unlocked the lock
{
  delay(1000); // wait 1000ms
  Serial.println("System unlocking"); // prints into the serial monitor for debugging purposes
  delay(100); // wait 100ms
  digitalWrite(RelayPin, HIGH); // apply 5v to the relay causing the solonoid to activate releasing the lock
  delay(4000); // leave the door unlocked for 4000ms
  digitalWrite(RelayPin, LOW); // stop applying 5v to the relay
  sendSMS(Admin[Number], "The lock was opened by " + User); // send an SMS to Admin informing which user unlocked door
}
struct User 
{ ... };

User Users[4];


   if (Sender == AdminNumber || Sender == User[1].Number || Sender == User[2].Number || Sender == User[3].Number || Sender == User[4].Number)
  1. User Vs. Users: which is the type and which is the variable?
  2. The subscripts for a 4-element array are 0 to 3.

You have a heap of errors, not just a single one. These are the ones that came up for me in 1.6.9 after fixing the first issue oqibidipo pointed out. Some of them are really basic so it might be simpler if you look through them and try to fix the obvious ones first.

C:\Arduino-1.6.9\Sketchbook\sketch_nov30a\sketch_nov30a.ino: In function 'void CommandRecieved(String, String)':

sketch_nov30a:77: error: 'OPEN' was not declared in this scope

     if (Command == OPEN)

                    ^

sketch_nov30a:79: error: too few arguments to function 'void Unlock(String)'

       Unlock();

              ^

C:\Arduino-1.6.9\Sketchbook\sketch_nov30a\sketch_nov30a.ino:172:6: note: declared here

 void Unlock(String User) // this function opens the lock and sends a notification to the admin stating which user unlocked the lock

      ^

sketch_nov30a:89: error: 'DLTE' was not declared in this scope

     else if (Command == DLTE && Sender == AdminNumber)

                         ^

sketch_nov30a:100: error: 'EKEY' was not declared in this scope

     else if (Command == EKEY && Sender == AdminNumber)

                         ^

sketch_nov30a:110: error: invalid conversion from 'int' to 'const char*' [-fpermissive]

           if (Temporary == 1)

                            ^

In file included from C:\Arduino-1.6.9\hardware\arduino\avr\cores\arduino/Arduino.h:223:0,

                 from sketch\sketch_nov30a.ino.cpp:1:

C:\Arduino-1.6.9\hardware\arduino\avr\cores\arduino/WString.h:143:16: error:   initializing argument 1 of 'unsigned char String::operator==(const char*) const' [-fpermissive]

  unsigned char operator == (const char *cstr) const {return equals(cstr);}

                ^

sketch_nov30a:126: error: expected ')' before '}' token

       }

       ^

sketch_nov30a:126: error: expected ';' before '}' token

C:\Arduino-1.6.9\Sketchbook\sketch_nov30a\sketch_nov30a.ino: In function 'void ClearMemory(byte)':

sketch_nov30a:161: error: invalid operands of types 'const char*' and 'const char [3]' to binary 'operator+'

   GPRS.println("AT CMGR + " + MemoryAddress + " ="); // removes the message from "SIMAddress" on the SIM card

                                               ^

sketch_nov30a:162: error: invalid operands of types 'const char*' and 'const char [31]' to binary 'operator+'

   Serial.println("Cleared message from address " + MemoryAddress + " on the primary storage device"); // prints a new line on the serial monitor to confirm that address X has been cleared

                                                                    ^

C:\Arduino-1.6.9\Sketchbook\sketch_nov30a\sketch_nov30a.ino: In function 'void DeleteUser(int)':

sketch_nov30a:167: error: 'x' was not declared in this scope

   User[UserToDelete].Number == x;

                                ^

sketch_nov30a:168: error: 'struct Users' has no member named 'Temporaray'

   User[UserToDelete].Temporaray == 0;

                      ^

C:\Arduino-1.6.9\Sketchbook\sketch_nov30a\sketch_nov30a.ino: In function 'void Unlock(String)':

sketch_nov30a:180: error: 'Admin' was not declared in this scope

   sendSMS(Admin[Number], "The lock was opened by " + User); // send an SMS to Admin informing which user unlocked door

           ^

sketch_nov30a:180: error: 'Number' was not declared in this scope

   sendSMS(Admin[Number], "The lock was opened by " + User); // send an SMS to Admin informing which user unlocked door

                 ^

exit status 1
'OPEN' was not declared in this scope

saximus: You have a heap of errors, not just a single one. These are the ones that came up for me in 1.6.9 after fixing the first issue oqibidipo pointed out. Some of them are really basic so it might be simpler if look through them and try to fix the obvious ones first.

How on earth does people's code get into this state? Do they write the whole thing as a blob and then when they get to the end think "Hey! Must be about time to hit the compile button!" Are they just copy/pasting a blob of someone else's (wrong) code?

Newbies: write in small chunks, and compile.

Hahaha! I'm guilty of blob writing.

Its usually, get inspiration, write a bunch of code then "Comb out the snags with the compiler."

Different strokes.

-jim lee

write a bunch of code then "Comb out the snags with the compiler."

That works when you know what the compiler output means.

OP: That is NOT all of the error message. Part of the error message what you failed (again) to post is the line number and column number where the compiler threw up its hands and said "Hey, doofus, you've got a problem here". That information IS important.

hey thanks guys,

I got it sorted by changing the User bits to Users,

I think I need to be more careful about what I identify variables as.

also I think my new years resolution will be to stop blob writing!!!

Thanks again

Hope you changed this as well...

oqibidipo: 2) The subscripts for a 4-element array are 0 to 3.

yes I have done thanks.

I appreciate the help, This forum really is a great resource with such a great community!

Hi,
I have a similar issue but with a wav file I converted into hex. The beginning looks like this:

unsigned char PROGMEM cinco [783804] = {
0x7F, 0x7F, 0x80, 0x80, 0x81, 0x81, 0x81, 0x81, 0x81, 0x81, 0x81, 0x81, 0x81, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x81, 0x81, 0x81, 0x81, 0x81,
0x81, 0x81, 0x81, 0x81, 0x81, 0x81, 0x81, 0x80, 0x80, 0x80, 0x80, 0x7F, 0x7F, 0x80, 0x80, 0x80, 0x80, and so on.

The console tells me exit status one, expected primary expression before unsigned. It also gives me other messages, such as exected “,” or “;” before “unsigned”.

The thing is that the example from which I am copying this brings a file that looks exactly the same as mine at the beginning, meaning, it starts right away with unsigned char PROGMEM

but when I run the example, it does not throw any errors.

I’d appreciate any ideas…