NEED HELP WITH chr$ ARGUMENTS

I have a game that uses the arrow keys, the ASCII numbers for arrow keys are 301 up arrow, 302 down arrow, 303 right arrow, and 304 left arrow. After I win or lose there is a "GET KEY PSE" statement, and if someone accidently hits an arrow key more than once then my program stops with an Error, chr$ argument must be between o and 200 something. I was hoping that someone could tell me how to fix this error. Other than pressing an arrow key 2 or more times at that specific moment this error does not show up, and my program works 100% with no other bugs.

Comments

GET KEY errors

Hi,

One of the easiest ways to bullet proof a program is to use TB error handling features, e.g.
DO
WHEN EXCEPTION IN
GET KEY pse
LET key$=chr$(pse) ! if pse is out of range then an error will occur
EXIT DO
USE
PRINT "Bad key press - try again"
END WHEN
LOOP

Big John

Idiot-proof TB program development ...

bubbachunck ... What you seem to be looking for is TB program development that is, what I call, idiot-proof. That is what I try - rarely - to accomplish with programs I develop for paying clients. When I was working in the aerospace electronics industry during my 40-year career as an electrical engineer, I practised what I'm preaching. One important thing I did was to never delete or lose any data that my programs created.

In my programs, I always stored data in a 1D or sometimes 2D array, in what are called "circular buffers". For a 1D or 2D array, I always dimensioned an array that had an extra column for recording an index number. And I always had the program line " OPTION BASE 0 " and enough columns for recording all of the variable values.

As variables were created and stored, the index number was incremented, using the MOD(x,y) function. The x value is the row index. The y value is the number of rows of program data you want to store in the data array before you jump the index back to the zero-th row of the array. "Old" data then starts to get over-written by new data. The 'height' of the data array is thus limited by your choice of variable y.

I'm going to end the discussion now. This message is getting to be too long. I need to write a short article about circular buffers someday. Anyway, you can write program code that can interrupt your program flow and regain program control after an accidental keypress - or a sudden power failure. Regards ... Tom M

P.S. I posted a Fibonocci number program in a Forum message that demonstrated the circular buffer.