Site hosted by Angelfire.com: Build your free website today!

Lesson 7 - Getky statements



    Getky statements are essential to BASIC video games.  They will do something if a certain key is pressed or something else if another key is pressed.  Refer to the key code diagram on page 217 of your 86 manual to get all of the keys and their codes.  Note: "On" has no code in BASIC because othewise the programmer could prevent the interrupt that "On" is assigned to.

Example of a getky statement

:Lbl Top                                  ;Establishes a label Top
:getky->A                              ;Initializes getky and stores to A
:If A==22                               ;If A equals 22 (exit key) stop
:Then
:Stop
:End
:If A==26                               ;If A equals 26, disp the message otherwise goto the top
:Then
:Disp "You hit right key"
:Pause
:ClLCD
:Else
:Goto Top
:End

Notice the "Ends" to mark the end of a Then statement - these are necessary!

    That's the basic getky sequence.  The else at the end was unnecessary, but I added it to show how to use an else staement.