Ha-ha! Found the code.
Again, this is a quick fix, with a bit of work you could break it. But it
gives enough hassle for discouraging most people.
Ok, here it goes:
I use 2 fields, one called "PasswordEntryField" (where I store the password)
and "CharMirrorField" (where i display the '*').

-- Simple password entry by [evildonut] 08/2000 (I think)
-- keyDown behaviour applied on "CharMirrorField"
on keyDown
  thatList = "ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789"

  case the key of
    BACKSPACE :
      mirror_text = member("CharMirrorField").text
      password_text  = member("PasswordEntryField").text

      if password_text.chars.count <= 1 then
        member("CharMirrorField").text = ""
        member("PasswordEntryField").text = ""
      else
        -- if not done, then mirror and password field content differ
        mirror_text = mirror_text.char[1..mirror_text.chars.count-1]
        password_text = password_text.char[1..mirror_text.chars.count-1]
        member("CharMirrorField").text = mirror_text
        member("PasswordEntryField").text = password_text
      end if

    RETURN :
      checkPassword()

    otherwise
      if thatList contains the key then
        member("CharMirrorField").text = member("CharMirrorField").text &
"*"
        member("PasswordEntryField").text =
member("PasswordEntryField").text & the key
      else
        pass
      end if
  end case
end keyDown


-- checkPassword() function. Does what itsays on the tin!
-- I'm assuming here that the password has already been loaded onto the
global "expectedPassword".
-- Modify as appropriate (loading the password onto a global is obviously
not safe)
on checkPassword
  global expectedPassword

  theGivenPassword = member("PasswordEntryField").text
  if theGivenPassword = expectedPassword then
    alert "We have a winner!"
  else
    member("CharMirrorField").text = ""
    member("PasswordEntryField").text = ""
    alert "Incorrect password." & RETURN & "Please try again."
  end if
end checkPassword

Have fun!

... Alex ...
----------------------------------------------------------------------------
--------
"Accept that some days you are the pigeon and some days the statue"
Dilbert
----------------------------------------------------------------------------
--------



[To remove yourself from this list, or to change to digest mode, go to
http://www.penworks.com/LUJ/lingo-l.cgi  To post messages to the list,
email [EMAIL PROTECTED]  (Problems, email [EMAIL PROTECTED])
Lingo-L is for learning and helping with programming Lingo.  Thanks!]

Reply via email to