home *** CD-ROM | disk | FTP | other *** search
/ RBBS in a Box Volume 1 #3.1 / RBBSIABOX31.cdr / qbas / pword.sc < prev    next >
Encoding:
Text File  |  1988-10-01  |  2.0 KB  |  38 lines

  1. proc pword()
  2.  private key, pwordvar
  3.   key = 0                                   ;initialize
  4.   pwordvar = ""                             ;
  5.   beep beep
  6.   @24,48 ?? "ENTER PASSWORD: ..............."
  7.   @24,64
  8.   while (key <> 13)                         ;while user has not pressed [Enter]
  9.     key = getchar()
  10.     if (col() = 79 and key <> 13 and key <> 27 and key <> 8) then
  11.       beep                                  ;check for last col on screen and
  12.       @24,79                                ;if so, only allow user to press
  13.     else                                    ;[Enter],[Esc] or [BackSpace]
  14.       switch
  15.         case key = 8 : if (col() <> 64) then ;user pressed [BackSpace]
  16.                          @24,col() - 1
  17.                          ?? "."
  18.                          @24,col() - 1
  19.                          pwordvar = substr(pwordvar,1,len(pwordvar) - 1)
  20.                         else                 ;remove a char from password
  21.                           beep
  22.                         endif
  23.         case key = 13: quitloop              ;user pressed [Enter], leave proc
  24.         case key = 27: return ""             ;user pressed [Esc], return blank
  25.                        quitloop              ;leave proc
  26.  
  27.       endswitch
  28.       if (key <> 8) then                     ;if user didn't hit [BackSpace],
  29.         pwordvar = pwordvar + chr(key)       ;add inputted char to password
  30.         ?? "*"
  31.       endif
  32.     endif
  33.   endwhile
  34.   return pwordvar
  35. endproc
  36.  
  37. message pword() sleep 2000