Best Way to Cycle Through Screens

I’m using a Mega2560 with an LCD Touchscreen from here: http://imall.iteadstudio.com/im120417021.html. Currently, I have a program that was already written that takes input a few different times to fill different variables. This program cycles through a couple of screens to gather this information based on which series of information is needed. Basically, you start at a screen with 3 options. Each option takes you to another screen. Options 1 and 2 have 3 screens in their series and option 3 only has 1. I’m looking for an efficient way to move back and forth through these screens. I was thinking of using something like this:

int branchSelect = 0;
int screenSelect = 0;
int screen[3][5] = {
  { 0, 1, 2, 3, 4 },
  { 0, 1, 2, 3, 4 },
  { 0, 1, 0, 0, 0 }
};
int screenNavigation = screen[branchSelect][screenSelect];


void enterButton()
{
  if (screenSelect < 5)
     screenSelect++;
  else if (screenSelect == 5)
     screenNavigation = screen[0][0];
}
void backButton()
{
  if (screenSelect > 0)
     screenSelect--;
  else if (screenSelect == 0)
     screenNavigation = screen[0][0];    
}

And then building my loop function to check the values of branchSelect and screenSelect to determine which screen to show. I originally thought I should use pointers to do this, but after I wrote it out, I realized I could just use regular variables. I think this should work, but before I go about rewriting this entire program I was looking for some input from you guys. Is there a better way to do this? Am I on the right track? Am I making this way too difficult? Thanks for all your help everyone!

If you want an easy method, but are ok with some maintenance(ensure this stops when it should, do have things overlap . . . etc), use case statement.

If you want a good menu system, then look into the Menu library. It may be difficult to learn how it works at first , but once you get the hang of it, your good to go.

The menu library looks pretty daunting. I'll take a look into it, though, as it sounds like exactly what I'm looking for.

If I were to use switch cases, what would be the best way to go back? I suppose you could change the value of the variable to transition between cases, is that correct? If I have multiple screens within a case, would it be best to use nested cases to navigate, or would I be better off with some other method? I'm going to try to use the switch case later, if for no other reason than to become familiar with such a useful tool. Thanks for the tip.

Any other suggestions are still appreciated. I'd love to hear what everyone thinks.

If I were to use switch cases, what would be the best way to go back? I suppose you could change the value of the variable to transition between cases, is that correct?

Correct, you would need to call the variable in each case statement to change it.

If I have multiple screens within a case, would it be best to use nested cases to navigate, or would I be better off with some other method?

You can have nested case statements. What I would do is make each screen its own function and just use the case statements to switch through the functions.

Another thing I would maybe do is use void pointers in a nested structure.

struct
{
  struct 
  {
    void(*myFunctions)();
  }Child[5]; // 5 child screens per main screen
}Main[3]; // 3 main screens
.
.
.
Main[ i ].Child[ j ](); // make i and j global and/or volatile.
int branchSelect = 0;
int screenSelect = 0;
int screen[3][5] = {
  { 0, 1, 2, 3, 4 },
  { 0, 1, 2, 3, 4 },
  { 0, 1, 0, 0, 0 }
};
int screenNavigation = screen[branchSelect][screenSelect];

You plan on expanding the menu structure to allow for 30,000 menus? If you are a bit more realistic, quit using int as the default type for everything.