I suggest changing your code a bit to make things easier in the long run.
It looks like you're checking every single time through your main loop what the currently selected tabber is, and then doing something with that. This might be easier:
1) Before your main loop, when you're creating your GUI, set the selected tabber to the one you want initially selected (probably 0, i.e. the first one, which is the default).
Remember that in a global variable or something, like "SelectedTabber%".
2) Only change "SelectedTabber" when the user clicks on a tabber and manually changes it. That way you don't have to constantly check which one is selected. You will know when a user selects a tabber because it will fire off a GadgetAction event.
So, in your WaitEvent() loop, check to see if the event was a GadgetAction event ($401). If so, then check to see if the EventSource() returns your mainTabber gadget. If so, then we can look at EventData() and it will return which tab page the user clicked on (0, 1, 2, etc). Then you can say "SelectedTabber = EventData()". You can also change anything else you want at this time regarding new tab pages.
This way you only have to deal with tab stuff when the user actually clicks on a tab, and not during every frame of your game or whatever. If you use the WaitEvent loop right, then it keeps CPU usage down to a minimum.
It looks like you're checking every single time through your main loop what the currently selected tabber is, and then doing something with that. This might be easier:
1) Before your main loop, when you're creating your GUI, set the selected tabber to the one you want initially selected (probably 0, i.e. the first one, which is the default).
Remember that in a global variable or something, like "SelectedTabber%".
2) Only change "SelectedTabber" when the user clicks on a tabber and manually changes it. That way you don't have to constantly check which one is selected. You will know when a user selects a tabber because it will fire off a GadgetAction event.
So, in your WaitEvent() loop, check to see if the event was a GadgetAction event ($401). If so, then check to see if the EventSource() returns your mainTabber gadget. If so, then we can look at EventData() and it will return which tab page the user clicked on (0, 1, 2, etc). Then you can say "SelectedTabber = EventData()". You can also change anything else you want at this time regarding new tab pages.
This way you only have to deal with tab stuff when the user actually clicks on a tab, and not during every frame of your game or whatever. If you use the WaitEvent loop right, then it keeps CPU usage down to a minimum.