home *** CD-ROM | disk | FTP | other *** search
- ; Contains Licensed Material Copyright (C) 1987 Ansa Software -- MJP
-
- ; This procedure will accept an alphanumeric string. It differs from the
- ; ACCEPT command in that it doesn't display the string as it is being entered,
- ; but rather displays user-definable characters.
- ;
- ; The procedure is called by invoking the command: GetPassword(MaxLen,DispKey),
- ; where MaxLen is the maximum length of the string to be accepted and DispKey
- ; the character string to be displayed after each keystroke. If no string is
- ; entered (ESC is pressed) then GetPassword will return a blank string.
- ;
- ; NOTE: It is up to the programmer to make sure that the input given by the
- ; user will fit entirely on one line, as this procedure does not support
- ; wrap-around.
- ;
- Proc GetPassword(MaxLen,DispKey)
- Private;MaxLen, ;Stores the maximum acceptable string length
- ;DispKey, ;Character(s) to display upon each keystroke
- Pass, ;Stores the actual password
- Char ;Stores the last keystroke entered
- Pass=""
- Char=getchar()
- While (Char<>13 or isblank(Pass)) and Char<>27 ;Accept until ENTER or ESC
- Switch
- Case Char=127: ;CtrlBackspace
- @row(),col()-len(Pass)*len(DispKey)
- ?? spaces(len(Pass)*len(DispKey))
- @row(),col()-len(Pass)*len(DispKey)
- Pass=""
- Case Char>32 and len(Pass)<MaxLen: ;Acceptable character
- ?? DispKey
- Pass=Pass+chr(Char)
- Case Char=8 and match(Pass,"..@",Pass): ;Backspace
- @row(),col()-len(DispKey)
- ?? spaces(len(DispKey))
- @row(),col()-len(DispKey)
- Case Char=13:
- Message "The password may not be left blank."
- Otherwise: ;Illegal character
- Beep
- Endswitch
- Char=getchar()
- Endwhile
- If Char=27
- Then Return ""
- Else Return Pass
- Endif
- Endproc