Ryuji5864 Posted May 4, 2009 Share Posted May 4, 2009 (edited) CODE $LoopB = 1 While $LoopB = 1 $newpw = InputBox("Change Student's Password", "Please type in a seven digit password for the student's account:", "", "¤") $slen = StringLen($newpw) If @error = 1 Then $LoopB = 0 Send("{TAB}{TAB}{TAB}{TAB}{SPACE}") sleep(550) Send("{ALTDOWN}c{ALTUP}") sleep(550) send("{ENTER}") sleep(550) Send("{ALTDOWN}{F4}{F4}{ALTUP}") exit Else If $slen < 7 AND $slen > 0 Then MsgBox(4096, "Error", "Password is too short - try again!") Else $LoopB = 0 Send($newpw) Send("{Tab}") Send($newpw) Send("{TAB}{TAB}{SPACE}") Sleep(550) Send("{ENTER}") Sleep(550) Send("{ALTDOWN}c{ALTUP}") Sleep(550) send("{ENTER}") Send("{ALTDOWN}{F4}{F4}{ALTUP}") EndIf EndIf WEnd For some reason the Inputbox is breaking and I do not know how to fix it. When a user presses cancel its supposed to exit. When a user enters a password less than 7 characters, it is supposed to prompt them to enter a password again. If the password is >= 7 its supposed to change their password to the newly entered value. I have tested the input box and when I press 'cancel' it changes their password. If the password is too short, it does prompt the user to re-enter a value. If they type in a password at least 7 characters or more it changes their password. Edited May 4, 2009 by Ryuji5864 Link to comment Share on other sites More sharing options...
Richard Robertson Posted May 4, 2009 Share Posted May 4, 2009 You need to check @error before doing anything else. You checked the length of the string, which did not error, so @error was not set. Also, you should not be checking for length greater than 0. You leave the open clause that the length may be zero and the program would skip right over your code. If someone hit OK with an empty box, you will set a blank password. Link to comment Share on other sites More sharing options...
Valuater Posted May 4, 2009 Share Posted May 4, 2009 You were checking the error for the inputbox after stringlen(), this is a fix While $LoopB = 1 $newpw = InputBox("Change Student's Password", "Please type in a seven digit password for the student's account:", "", "¤") $error = @error $slen = StringLen($newpw) If $error = 1 Then $LoopB = 0 Send("{TAB}{TAB}{TAB}{TAB}{SPACE}") Sleep(550) Send("{ALTDOWN}c{ALTUP}") Sleep(550) Send("{ENTER}") Sleep(550) Send("{ALTDOWN}{F4}{F4}{ALTUP}") Exit Else If $slen < 7 And $slen > 0 Then MsgBox(4096, "Error", "Password is too short - try again!") Else $LoopB = 0 Send($newpw) Send("{Tab}") Send($newpw) Send("{TAB}{TAB}{SPACE}") Sleep(550) Send("{ENTER}") Sleep(550) Send("{ALTDOWN}c{ALTUP}") Sleep(550) Send("{ENTER}") Send("{ALTDOWN}{F4}{F4}{ALTUP}") EndIf EndIf WEnd 8) Link to comment Share on other sites More sharing options...
Ryuji5864 Posted May 4, 2009 Author Share Posted May 4, 2009 You need to check @error before doing anything else. You checked the length of the string, which did not error, so @error was not set.Also, you should not be checking for length greater than 0. You leave the open clause that the length may be zero and the program would skip right over your code. If someone hit OK with an empty box, you will set a blank password.My first if statement is @error = 1, which returns the 'Cancel' button was pushed. The only reason why I am checking that the length is greater than zero is because it is not exiting when the cancel button is pressed. Link to comment Share on other sites More sharing options...
Moderators Melba23 Posted May 4, 2009 Moderators Share Posted May 4, 2009 Ryuji5864, Perhaps something like this:While 1 $newpw = InputBox("Change Student's Password", "Please type in a seven digit password for the student's account:", "", "¤") $slen = StringLen($newpw) If $slen = 0 Then MsgBox(4096, "Error", "Please enter something - try again!") ElseIf $slen < 7 Then MsgBox(4096, "Error", "Password is too short - try again!") ElseIf $slen > 7 Then MsgBox(4096, "Error", "Password is too long - try again!") Else ConsoleWrite("Do It!" & @CRLF) #cs Send($newpw) Send("{Tab}") Send($newpw) Send("{TAB}{TAB}{SPACE}") Sleep(550) Send("{ENTER}") Sleep(550) Send("{ALTDOWN}c{ALTUP}") Sleep(550) Send("{ENTER}") Send("{ALTDOWN}{F4}{F4}{ALTUP}") #ce ExitLoop EndIf WEnd ConsoleWrite("Here" & @CRLF) M23 Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind Open spoiler to see my UDFs: Spoiler ArrayMultiColSort ---- Sort arrays on multiple columnsChooseFileFolder ---- Single and multiple selections from specified path treeview listingDate_Time_Convert -- Easily convert date/time formats, including the language usedExtMsgBox --------- A highly customisable replacement for MsgBoxGUIExtender -------- Extend and retract multiple sections within a GUIGUIFrame ---------- Subdivide GUIs into many adjustable framesGUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView itemsGUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeViewMarquee ----------- Scrolling tickertape GUIsNoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxesNotify ------------- Small notifications on the edge of the displayScrollbars ----------Automatically sized scrollbars with a single commandStringSize ---------- Automatically size controls to fit textToast -------------- Small GUIs which pop out of the notification area Link to comment Share on other sites More sharing options...
Ryuji5864 Posted May 4, 2009 Author Share Posted May 4, 2009 You were checking the error for the inputbox after stringlen(), this is a fix $error = @errorThanks a ton... I cannot believe it was that simple. Link to comment Share on other sites More sharing options...
Ryuji5864 Posted May 4, 2009 Author Share Posted May 4, 2009 Ryuji5864, Perhaps something like this:While 1 $newpw = InputBox("Change Student's Password", "Please type in a seven digit password for the student's account:", "", "¤") $slen = StringLen($newpw) If $slen = 0 Then MsgBox(4096, "Error", "Please enter something - try again!") ElseIf $slen < 7 Then MsgBox(4096, "Error", "Password is too short - try again!") ElseIf $slen > 7 Then MsgBox(4096, "Error", "Password is too long - try again!") Else ConsoleWrite("Do It!" & @CRLF) #cs Send($newpw) Send("{Tab}") Send($newpw) Send("{TAB}{TAB}{SPACE}") Sleep(550) Send("{ENTER}") Sleep(550) Send("{ALTDOWN}c{ALTUP}") Sleep(550) Send("{ENTER}") Send("{ALTDOWN}{F4}{F4}{ALTUP}") #ce ExitLoop EndIf WEnd ConsoleWrite("Here" & @CRLF) M23 I like the way you think ^.^ 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