'===========================================================================
' Subject: VISUAL PASSWORD PROGRAM            Date: 05-30-97 (21:06)       
'  Author: Ian Campbell                       Code: QB, QBasic, PDS        
'  Origin: dm.campbell@ns.sympatico.ca      Packet: MISC.ABC
'===========================================================================
'PASSWORD.BAS
'28 May, 1997
'Ian Campbell
'
'       This is a compact visual password program. It's fairly fast and can
' easily be changed to suit anyones needs. To change positioning adjust the
' X and Y variables. To change the password, change the Password$ string. To
' change the Max password length, you also might have to change the display
' but it shouldn't be too difficult.
'
' This source can be used anywhere but please give credit where credit is due
'

CLS

0
placehold$ = "*"           'Placeholder
password$ = "mouse"        'Password
pass$ = ""                 'Don't change this...
plen = 0                   'or this...
maxlen = 10                'feel free to change this...
x = 11                     'this...
y = 11                     'or this.
LOCATE x - 3, y: PRINT "ÉÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍ»"
LOCATE x - 2, y: PRINT "º  Password Protected  º"
LOCATE x - 1, y: PRINT "ÌÍÍÍÍÍÍÍÍÍÍÍÍËÍÍÍÍÍÍÍÍÍ¼"
LOCATE x - 0, y: PRINT "º            º"
LOCATE x + 1, y: PRINT "ÈÍÍÍÍÍÍÍÍÍÍÍÍ¼"

1
DO                                     'This is the main loop where it waits
a$ = INKEY$                            'For [ENTER], [BACKSPACE] or any other
IF a$ = CHR$(13) THEN GOSUB pfreeze    'key, It's pretty simple.
IF a$ = CHR$(8) THEN GOSUB del
IF a$ <> "" THEN GOTO 10
LOOP

10
IF ASC(a$) = 8 THEN GOTO 1           'If you remove this line, it makes the
plen = LEN(pass$)                    'password different if backspace is
IF plen = maxlen - 1 THEN            'pressed. Don't touch. The rest of this
pass$ = pass$ + a$                   'is easy to understand. It just adds the
GOTO pfreeze                         'pressed key to pass$
END IF
pass$ = pass$ + a$
LOCATE x, y + 2 + plen: PRINT placehold$  'Print placeholder.
GOTO 1

del:                                'This is the tricky part.
plen = LEN(pass$)
IF plen = 0 THEN RETURN             'There's nothing to delete.
plen = plen - 1                     'Adjust plen
pass$ = LEFT$(pass$, plen)          'Delete one character of pass$
LOCATE x, y + 2 + plen: PRINT " "   'Get rid of placeholder
RETURN

pfreeze:                            'Enter was pressed...
IF pass$ = password$ THEN END       'If it was right then end.
IF pass$ <> password$ THEN GOTO 0   'If not go back to loop...
