Password Routine

Date: 1986
Type: Program
Platform(s): TS 2068
Tags: Utility

A password prompt to put at the start of a BASIC program. Line 10 sets ON ERR GO TO 30, so any error, including entering STOP at the INPUT prompt or pressing BREAK, sends the program back to the password prompt instead of stopping it. A FOR/NEXT loop allows three attempts; after the third wrong password the program erases itself with NEW. The password as printed is QTS (in capitals); change line 40 to use your own, and put your program from line 100 on.

ON ERR is a TS2068 keyword, so the routine does not work on a ZX Spectrum. Line 90 (LIST) can never run, because NEW in line 80 clears the program first. ON ERR stays in force after the right password is given, so an error later in your program also goes back to the password prompt. No author is printed.

Published in Sinc-Link May/June 1986 (Password Routine).

Related Articles

Use ON ERR and GOTO to password protect a program.

Image Gallery

Source Code

 10 ON ERR GO TO 30
 20 FOR x=1 TO 3
 30 INPUT "Password please";a$
 40 IF a$="QTS" THEN GO TO 100
 50 PRINT "Incorrect, try again"
 60 PAUSE 60: CLS
 70 NEXT x
 80 NEW
 90 LIST
100 PRINT "You are now past the Password"

Note: Type-in program listings on this website use ZMAKEBAS notation for graphics characters.