home *** CD-ROM | disk | FTP | other *** search
/ Power-Programmierung / CD1.mdf / magazine / nvdc87 / thinkpal / passwd.sc < prev   
Text File  |  1987-08-31  |  2KB  |  55 lines

  1. ; Checkpass procedure to check passwords and user names
  2. : NOTE: Requires Paradox 2.0
  3. ;
  4. PROC Checkpass()                ; header contains name of proc
  5. PRIVATE nameok, pass, username  ; variables private to proc
  6. PASSWORD "dontshowit"           ; present password for protected
  7.                                    ;  "secrets" table 
  8. VIEW "secrets"                  ; places secrets table on workspace
  9. MOVETO FIELD "name"             ; makes "name" field current 
  10. FOR i FROM 1 TO 3               ; top of FOR loop to check name
  11.   @2,4 ? "Enter your name: "    ; prompt user   
  12.   ACCEPT "A15" TO username      ; get input
  13.   CURSOR OFF
  14.   @5,5 CLEAR EOS
  15.   CURSOR NORMAL
  16.   LOCATE username               ; is name in the table?
  17.   IF retval                     ; Yes, so
  18.     THEN nameok = True          ;  go on to the
  19.       QUITLOOP                  ;  next step
  20.     ELSE                        ; No, so
  21.       BEEP                      ;  tell the user about it
  22.       MESSAGE "That name can't be found"
  23.       nameok = False
  24.     ENDIF
  25. ENDFOR
  26.  
  27. IF nameok                       ; was a valid name presented?
  28.   THEN                          ; Yes, so
  29.     FOR i FROM 1 TO 3           ; check for valid password
  30.       @2,4 ? "Enter your password: "
  31.       ACCEPT "A15" TO pass
  32.       IF [password] = pass      ; password is good
  33.         THEN
  34.           CLEARALL        ; clear table from workspace
  35.           UNPASSWORD "dontshowit" ; reprotect table
  36.           RETURN True     ; set value and return
  37.         ELSE              ; password no good
  38.           BEEP
  39.           MESSAGE "Invalid password"
  40.        ENDIF   
  41.     ENDFOR
  42.     CLEARALL                  ; user failed after 3 tries
  43.     UNPASSWORD "dontshowit"         
  44.     RETURN False
  45.   ELSE                        ; user presented an invalid name    
  46.     CLEARALL
  47.     UNPASSWORD "dontshowit"         
  48.     RETURN False 
  49. ENDIF
  50. ENDPROC                       ; end of procedure definition
  51.  
  52.  
  53. IF NOT Checkpass()            ; call Checkpass        
  54.   THEN EXIT                   ; if not True, then exit ENDIF
  55.