Catching Input Errors

Anything Sinclair ZX Basic related; history, development, tips - differences between BASIC on the ZX80 and ZX81
Post Reply
MrVertigo
Posts: 105
Joined: Fri May 27, 2022 9:06 pm

Catching Input Errors

Post by MrVertigo »

I am writing a simple program where the user is asked to input the integers 1 or 2.

To catch the error of them putting in a different integer I put in a line: If X <> 1 or X etc

But I’ve noticed that if I input another key that isn’t an integer the program ends. Terminates at the Input X line.

How do I catch this error?
User avatar
mrtinb
Posts: 1906
Joined: Fri Nov 06, 2015 5:44 pm
Location: Denmark
Contact:

Re: Catching Input Errors

Post by mrtinb »

You can use INKEY$.
Martin
https://zx.rtin.be
ZX81, Lambda 8300, Commodore 64, Mac G4 Cube
User avatar
1024MAK
Posts: 5103
Joined: Mon Sep 26, 2011 10:56 am
Location: Looking forward to summer in Somerset, UK...

Re: Catching Input Errors

Post by 1024MAK »

I suggest using either a string with INPUT or better yet, program your own input routine using INKEY$.

For example:
Choice using INKEY$
Choice using INKEY$
(Choice using INKEY$)

Mark
ZX81 Variations
ZX81 Chip Pin-outs
ZX81 Video Transistor Buffer Amp

:!: Standby alert :!:
There are four lights!
Step up to red alert. Sir, are you absolutely sure? It does mean changing the bulb :!:
Looking forward to summer later in the year.
MrVertigo
Posts: 105
Joined: Fri May 27, 2022 9:06 pm

Re: Catching Input Errors

Post by MrVertigo »

Inkeys sounds like it will be ideal, thanks!
Last edited by MrVertigo on Mon Aug 08, 2022 3:39 pm, edited 3 times in total.
User avatar
XavSnap
Posts: 1940
Joined: Sat May 10, 2008 4:23 pm
Location: 'Zx81 France' Fb group.

Re: Catching Input Errors

Post by XavSnap »

Cap0000.jpg
Cap0000.jpg (10.52 KiB) Viewed 1369 times
Xavier ...on the Facebook groupe : "Zx81 France"(fr)
Post Reply