Jump to content

  •  

UPGRADE DEADLINE - SEPTEMBER 26, 2014!
FileMaker Inc. has a deadline for users of version 10,11, 12 as Individual box or volume licenses (with expired maintenance).
If you don't renew your maintenance and upgrade to FMP 13 you will no longer be eligible to upgrade, at the discount pricing.

Volume Licensing upgrade pricing for FileMaker Pro 13, FileMaker Pro 13 Advanced and FileMaker Server 13 will be discontinued.
Individual upgrade pricing for FileMaker Pro 13 and FileMaker Pro 13 Advanced will increase after September 26, 2014.
As of 27-September-2014, FileMaker 10 products will no longer be available for purchase or support.

http://help.filemaker.com/app/answers/detail/a_id/13865


Photo

A password dialogue input function


  • Please log in to reply
No replies to this topic

#1 john renfrew  enthusiast, with a bit of geek

john renfrew
  • Members
  • 406 posts
  • LocationUK
  • FM Application:13 Advance
  • Platform:Cross Platform
  • Skill Level:Intermediate
  • Certification:11, 12, 13
  • Membership:TechNet, FileMaker Business Alliance
  • Time Online: 10d 4h 25m 39s

Posted 21 February 2012 - 02:34 PM

Has a bit of help from Sam Barnum on StackOverflow with this but have a function which either gives you three chances to enter the correct password, or returns the password you enter into the box.
Just a bit of practice for me with SwingBuilder but might be a useful starting point for others.

Some of this has been enabled by the latest Groovy 1.8.4 version in the current Scriptmaster

// PasswordSwing ( title ; message ; type ; password ; returnPass )
// 12_02_21 JR
// v1.0
// type -1 plain, 0 error, 1 information, 2 warning, 3 question
// if returnPass then displays a dialogbox with a password field and returns the passsword on OK
// and uses title and password parameters and returns entered text
// else gives three attempts to enter a password which matches password parameter
// returns true if match if not or dialog cancelled returns false


import javax.swing.JComponent
import groovy.swing.SwingBuilder

type = type.toInteger()
i = 0
left = ''
swing = new SwingBuilder()

if(returnPass){
swing.edt{
  passwordField = passwordField()
  JComponent[] components = [label(message), passwordField]
  result = optionPane().showConfirmDialog(null, components, title, 2, type)
}
return passwordField.getPassword().toString()
} else {
swing.edt{
  passwordField = passwordField()
  while(i < 3){
   JComponent[] components = [label('Password'+left), passwordField]
   result = optionPane().showConfirmDialog(null, components, title, 2, -1)
   if (passwordField.getPassword().toString() == password || result == -1 || result == 2){
    i=3
   } else if (passwordField.getPassword().toString() != password && i==2) {
    result = optionPane().showMessageDialog(null, '<html><h1><font color="red">WRONG PASSWORD</font></h1><h3>Script halted</html>', 'ERROR', 2)
    i=3
   } else {
    result = -1
    i++
    message = i == 2 ? ' try':' tries'
    left = ' - ' + (3-i) + "${message}" + ' left'
    passwordField = passwordField()
   } //end if
  } //end while
} //end swing
return result == 0 ? true:false
}


  • 0




FMForum Advertisers