Hi,
I am in the early stages of a project that used a TFT display with some menus.
So, function_one would present the menu, with choices.
The user would select, via click, function_two.
function_two would select function_three.
Finally function_three must call function_one to show the starting screen.
Unfortunately I do not have any code yet, as I am structuring the program on paper.
Why use recursion? If 1 calls 2 and 2 calls 3 and 3 is supposed to go back to 1. Instead, drop out of 3, returning to 2 and then drop out of 2 to end up back at 1.
Hi
thanks again.
I think I understand now.
So function_one must always be reached by a return , otherwise the program will crash.
Is that correct?
Regards
void function_MainMenu()
{
// Display the main menu and on selection of a sub-menu, call its funciton
function_MenuLevelTwo();
}
void function_MenuLevelTwo()
{
// Display the second-level menu and on the selection
// of an action, call its function
function_ActionLevelThree();
return; // Go back to function_MainMenu
}
void function_ActionLevelThree()
{
// Perform the action
return; // Go back to function_MenuLevelTwo which goes back to MainMenu
}