osx - Applescript a "Retry" button -
i'm coding application password field:
set password1 text returned of (display dialog "to continue please enter special passcode below." buttons {"cancel", "continue"} default button 2 default answer "" cancel button 1 hidden answer) if password1 "passwordhere" display dialog "you have entered password right! right password was: passwordhere entered password was: " & password1 buttons {"cancel", "continue"} default button 2 cancel button 1 else if password1 "" set password1 "empty passwordfield" end if display dialog "you have entered password wrong! right password was: ******** entered password was: " & password1 buttons {"cancel", "try again"} default button 2 cancel button 1 end if end
now question is: how make "try again" button return first display dialog? possible? if not please in answer.
also question: possible 2 normal dialogs? in second dialog "back" button? , if press button you'll return first dialog?
thanks reading,
jort
consider placing password prompt/dialog in applescript handler:
on get_password() -- password , return true if good, false if bad end get_password
this way can 're-call' handler anywhere else in script needed.
here example of code repeats prompt password question asked:
local goodpassword, password1, tryagain, proceed set goodpassword false -- initial set set tryagain true -- initial set on getpassword() return text returned of (display dialog "to continue please enter special passcode below." buttons {"cancel", "continue"} default button 2 default answer "" cancel button 1 hidden answer) end getpassword repeat while tryagain = true set proceed true set password1 getpassword() -- calls prompt first time if password1 "passwordhere" set goodpassword true set tryagain false try display dialog "you have entered password right! right password was: passwordhere entered password was: " & password1 buttons {"cancel", "continue"} default button 2 cancel button 1 on error number -128 set proceed false end try else set goodpassword false if password1 "" set password1 "empty passwordfield" end if try display dialog "you have entered password wrong! right password was: ******** entered password was: " & password1 buttons {"cancel", "try again"} default button 2 cancel button 1 on error number -128 set tryagain false end try end if end repeat
Comments
Post a Comment