How would i do this on Saturn C?

How would i make this program in Saturn C? (with SGL)

If i push button C the program goes to line x and if i push Z it would go to line y. In basic it would look something like:

IF buttonpress = "X" THEN GOTO 10 ELSE GOTO 15

I don´t know much about Saturnprogramming yet, but i´ll try to learn! Please help me with this.
You could do something like that in C, but it's not generally considered to be good programming practice; using function calls or a switch statement (or a combination of the two) would generally be preferable. In fact, some introductory texts on C don't cover the goto statement for this reason, even though there are cases where it is the cleanest way to transfer control (e.g. jumping out of a deep nested loop).

Here's what it would look like using the goto statement (these might not be 100% correct; my Saturn isn't hooked up for testing ATM and I'm not very familiar with SGL):

if (Smpc_Peripheral[0].data & PER_DGT_TC == 0) // C button is pressed

goto cbuttoncode;

else if (Smpc_Peripheral[0].data & PER_DGT_TZ == 0) // Z button is pressed

goto zbuttoncode;


// Code for C button press goes here


// Code for Z button press goes here

With this code however, you would have to use additional statements to make the button handling code terminate itself somehow, otherwise the program would just keep running past the end of the button code (but then again this behavior is similar to BASIC, so maybe it's what you want)

With function calls it would look like this:

if (Smpc_Peripheral[0].data & PER_DGT_TC)


else if (Smpc_Peripheral[0].data & PER_DGT_TZ)




  // Code for C Button press goes here




  // Code for C Button press goes here


The advantage of using function calls is that they will return to where the program was before, similar to a GOSUB in basic. Anyway, if you're tempted to use goto in a C program, I recommend reading more about C; it's designed so that you generally shouldn't have to use goto, and works better if you use the other program control statements/constructs. Also, the button constants are all listed in sl_def.h if you want to look them up.