Hi,
I've been trying to resolve this issue for a month, and finally decided to seek help.
I have a nested "switch" statement in a function. Every time I try to compile, I get the error "expected primary-expression before ')' token". The error points to line 430, the inner switch statement itself, ["switch(Sub_Mode_Set_Timers){"]. For the life of me, I can't find any syntax problem on that line or in the code up to there from the beginning of the function. If I comment out that one line and its related "case" statements, the program compiles.
The program itself is a fan control system for a 3D printer that I am building for a friend.
To give you some idea of my (low level of) programming experience, I have done a little C++ and some other program languages over the years, but am little more than a novice with C++.
The error message and code are below. Please note that the code is nowhere near done. I am trying to establish the framework for how it will be structured first. I have not included the entire program, but the portions that I think may be relevant without posting hundreds of lines.
Any help would be greatly appreciated!
Thank you!
Charlie
Error Message
C:\Users\Owner\Documents\Arduino\Software\3D Printer Fan Control\Fan_Control_Software\John_Fan_Control_V1_00a_8_2_20\John_Fan_Control_V1_00a_8_2_20.ino: In function 'void MenuKeyRightPressed()':
John_Fan_Control_V1_00a_8_2_20:430:29: error: expected primary-expression before ')' token
switch(Sub_Mode_Set_Timers)
^
Program Code
//-- Modes
enum Mode
{
Mode_Start_Pause_Resume_Clock,
Mode_Set_Timers,
Mode_Edit_Timers
};
enum Sub_Mode_Set_Timers
{
Sub_Mode_Set_Timers_Clear_Prev_Timers,
Sub_Mode_Set_Timers_Enter_New_Timer,
Sub_Mode_Set_Timers_Set_Power_Level,
Sub_Mode_Set_Timers_Add_Timer
};
enum Sub_Mode_Edit_Timers
{
Sub_Mode_Edit_Timers_Add_Timer,
Sub_Mode_Edit_Timers_Delete_Timer,
Sub_Mode_Edit_Timers_Edit_Timer,
Sub_Mode_Edit_Timers_Edit_Power
};
// SNIP... code from enum to this function not shown
//***********************************************************************
// BUTTON CLICK HANDLER - RIGHT
//***********************************************************************
void MenuKeyRightPressed()
{
// Some action
bool Button_flag;
Button_flag = true;
snprintf(LCD_Row_1, 17, "Right Row 1 "); //-- Store formatted version data for line 1
snprintf(LCD_Row_2, 17, "Right Row 2 "); //-- Store formatted version data for line 2
PrintToLCD();
switch(Mode)
{
case Mode_Start_Pause_Resume_Clock:
break;
case Mode_Set_Timers:
switch(Sub_Mode_Set_Timers)
{
case Sub_Mode_Set_Timers_Clear_Prev_Timers:
break;
case Sub_Mode_Set_Timers_Enter_New_Timer:
break;
case Sub_Mode_Set_Timers_Set_Power_Level:
break;
case Sub_Mode_Set_Timers_Add_Timer:
break;
}
break;
case Mode_Edit_Timers:
break;
}
Button_flag = true;
}