4 Replies Latest reply on Aug 7, 2007 1:25 AM by Mike Crisp

    Nice and simple password question

    Mike Crisp
      Hi I am using the code below combined with fileio to type in / save and open a password. However the password script I am using converts the abcdefg....... into * - when I save using fileio obviously it saves and reads the* rather than the abcd....

      Please help me remove the * part from the script below

      --Director TechNote
      --How can I make a password entry field where they type asterisks?
      --Here's a Director behavior which can do this. Drag it atop a system textfield to enable the behavior. You'll be able to choose the password, how many attempts can be made, and what happens with success.

      --(Tip: Whenever copying scripts from another source, make sure that linebreaks made the transition correctly. After you paste this script into an editing window, press the TAB key and make sure that lines are indented as they should be. If not, then a long line of script may have been broken in two durings its journeys.)

      --============= BEGIN BEHAVIOR =============================

      -- Text Password bullets
      -- This is a straightahead behavior. Usage instructions are in the
      -- behavior description, and the scripting can be modified as you see fit.
      -- History:
      -- Aug 13 97 jd Added prompt options, submitted to KB.
      -- May 8 97 jd Cleaned up and copied into library from newsgroup reply.

      property spriteNum, myMember, myCurrentEntry, myCurrentTries
      property myPrompt, myPassword, myCorrectAction, myNumberOfTries

      on beginSprite me
      set myMember to the member of sprite spriteNum
      put myPrompt into field myMember
      set the editable of sprite spriteNum to TRUE
      set myCurrentEntry to ""
      set myCurrentTries to 0

      on keyDown me
      case (the key) of
      if myCurrentEntry = myPassWord then PasswordAccepted me
      else PasswordRejected me
      put myPrompt into field myMember
      set myCurrentEntry to ""
      set permittedChars to "abcdefghijklmnopqrstuvwxyz 1234567890"
      if permittedChars contains the key then
      if field myMember = myPrompt then put "*" into field myMember
      else put "*" after field myMember
      put the key after myCurrentEntry
      end if
      end case

      on PasswordAccepted me
      do myCorrectAction

      on PasswordRejected me
      if myCurrentTries >= myNumberOfTries then
      alert "You seem to have forgotten your password. Contact your administrator for assistance."
      set myCurrentTries to myCurrentTries + 1
      end if
      put myPrompt into field myMember
      set myCurrentEntry to ""
      beep myCurrentTries

      on getPropertyDescriptionList me
      set theProps to [:]

      set c to "What password?"
      set d to "enter here"
      addProp theProps, #myPassword, [#comment: c, #format: #string, #default: d]

      set c to "What Lingo to do?"
      set d to "go next"
      addProp theProps, #myCorrectAction, [#comment:c, #format: #string, #default: d]

      set c to "How many attempts?"
      addProp theProps, #myNumberOfTries, [#comment: c, #format: #integer, #default: 3]

      set c to "What default text?"
      set d to "Enter password now"
      addProp theProps #myPrompt, [#comment:c, #format:#string, #default:d]

      return theProps

      on getBehaviorDescription me
      set line1 to " This behavior can be dragged atop a system textfield to create a blind password entry. "
      set line2 to "When they type they will see asterisks." & RETURN
      set line3 to " Parameters include the password, then Lingo action that occurs with success, the number of incorrect attempts they can make, and the message they see in the field as a prompt. "
      set line4 to "The default action is to go to the next marker. You'd likely wish to loop within the frames that contain this field sprite."& RETURN
      return line1 & line2 & line3 & line4

      --============= END BEHAVIOR =============================

      Many thanks