corey822 Posted January 4, 2008 Share Posted January 4, 2008 CODE#include <constants.au3> Global $Ini = @ScriptDir & "\PW.ini" If Not FileExists($Ini) then _setuser(1) _SetPass(1) Else $username = InputBox("security check","enter your username.","") if $username = IniRead($Ini,"security","username","") Then if $username = "" then exit $passwd = InputBox("Security Check", "Enter your password.", "", "*") if $passwd = INIRead($Ini, "Security", "Password", "") Then If $passwd = "" Then Exit MsgBox (0,"","Greetings") Else Exit EndIf EndIf Func _Setuser($atmpt) If $atmpt = 1 Then Exit;;; Change this to set how many attempts are allowed. $PPass = InputBox("Security Check", "Enter your username.", "") If StringLen($PPass) <5 Then MsgBox(4096, "Error", "Your username must be at least 5 characters") _Setuser($atmpt) EndIf $BPass = InputBox("Security Check", "Re-enter your username.", "") If $PPass <> $BPass Then $atmpt += 1 _Setuser($atmpt) Else IniWrite($Ini, "Security", "username", $BPass) EndIf EndFunc Func _SetPass($atmpt) If $atmpt = 3 Then Exit;;; Change this to set how many attempts are allowed. $iPass = InputBox("Security Check", "Enter your password.", "", "*") If StringLen($iPass) <4 Then MsgBox(4096, "Error", "Your password must be at least 4 characters") _SetPass($atmpt) EndIf $cPass = InputBox("Security Check", "Re-enter your password.", "", "*") If $iPass <> $cPass Then $atmpt += 1 _SetPass($atmpt) Else IniWrite($Ini, "Security", "Password", $cPass) EndIf EndFunc is this the right way the script should be handled or is it another way thats better C.Wnew rules:1.dont use plz in a post or title use please instead2.always use help file as it is now muchly over rated3. dont think where not watching u4.please wait 24 hours after last post ot bump XD i use to make that mistake Link to comment Share on other sites More sharing options...
PsaltyDS Posted January 5, 2008 Share Posted January 5, 2008 (edited) Are you working in SciTE? Run some Tidy on that mess! I got a headache trying to follow your recursive function and just redid it like this: expandcollapse popup#include <constants.au3> Global $Ini = @ScriptDir & "\PW.ini" If Not FileExists($Ini) Then _Setuser() _SetPass() Else $username = InputBox("security check", "enter your username.", "") If @error Then Exit If $username = IniRead($Ini, "security", "username", "") Then $passwd = InputBox("Security Check", "Enter your password.", "", "*") If @error Then Exit If $passwd == IniRead($Ini, "Security", "Password", "") Then MsgBox(0, "", "Greetings") Else Exit EndIf Else Exit EndIf EndIf Func _Setuser() While 1 Local $sUser = InputBox("Security Check", "Enter your username.", "") If @error Then Exit If StringLen($sUser) >= 5 Then If $sUser = InputBox("Security Check", "Re-enter your username.", "") Then IniWrite($Ini, "Security", "username", $sUser) ExitLoop Else MsgBox(16, "Error", "Did not correctly verify username. Try again...", 5) EndIf Else MsgBox(16, "Error", "Your username must be at least 5 characters. Try again...", 5) EndIf WEnd EndFunc ;==>_Setuser Func _SetPass() While 1 Local $sPass = InputBox("Security Check", "Enter your password.", "", "*") If @error Then Exit If StringLen($sPass) >= 4 Then If $sPass == InputBox("Security Check", "Re-enter your password.", "", "*") Then IniWrite($Ini, "Security", "Password", $sPass) ExitLoop Else MsgBox(16, "Error", "Did not correctly verify password. Try again...", 5) EndIf Else MsgBox(16, "Error", "Your password must be at least 4 characters", 5) EndIf WEnd EndFunc ;==>_SetPass Cheers! Edited January 5, 2008 by PsaltyDS Valuater's AutoIt 1-2-3, Class... Is now in Session!For those who want somebody to write the script for them: RentACoder"Any technology distinguishable from magic is insufficiently advanced." -- Geek's corollary to Clarke's law Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now