Googler24022 Posted December 5, 2006 Share Posted December 5, 2006 (edited) Hi, I have made a program which logs you into an online game, I made a nice GUI and all works well. Now, I am coding in some error checking to keep the users updated as there not going to see the internet explorer window.Here is my current code. You can see the error checking function at the bottom there. What I have done is put the various errors into the array, then it reads the page to check for them. But, I'm not sure how to check for them.expandcollapse popup#include <IE.au3> #include <GUIConstants.au3> #Include <GuiStatusBar.au3> #include <Array.au3> $GUI = GUICreate("Kings of Chaos", 500,160) $tab=GUICtrlCreateTab (5,5, 490,135) $oIE = _IECreate ("http://www.kingsofchaos.com",0,0) $tab0=GUICtrlCreateTabitem ("Login") $username = GUICtrlCreateInput ("Username", 15, 35, 100, 20) $email = GUICtrlCreateInput ("Email", 15, 60, 100, 20) $password = GUICtrlCreateInput ("Password", 15, 85, 100, 20,$ES_PASSWORD) $login = GUICtrlCreateButton ( "Login", 15, 110, 100, 20) GUICtrlCreateLabel ("Currently Logged in As : ", 125, 38) GUICtrlCreateLabel ("Gold : ", 125, 58) GUICtrlCreateLabel ("Army Size : ", 125, 78) GUICtrlCreateLabel ("Strike Action : ", 325, 38) GUICtrlCreateLabel ("Defensive Action : ", 325, 58) GUICtrlCreateLabel ("Spy Action : ", 325, 78) GUICtrlCreateLabel ("Sentry Action : ", 325, 98) GUISetState (@SW_SHOW) While 1 $msg = GUIGetMsg() If $msg = $GUI_EVENT_CLOSE Then ExitLoop If $msg = $login then $user = GUICtrlRead($username) $emai = GUICtrlRead($email) $pswd = GUICtrlRead($password) koc_login($user, $emai, $pswd) endif Wend Func koc_login($username, $email, $password) $oForm = _IEFormGetCollection ($oIE, 0) $ousername = _IEFormElementGetObjByName ($oForm, "usrname") $oemail = _IEFormElementGetObjByName ($oForm, "uemail") $opassword = _IEFormElementGetObjByName ($oForm, "peeword") _IEFormElementSetValue ($ousername, $username) _IEFormElementSetValue ($oemail, $email) _IEFormElementSetValue ($opassword, $password) _IEFormSubmit ($oForm) Sleep(1000) ; koc_error() EndFunc Func koc_stats() EndFunc Func koc_error () Dim $avArray[2] $avArray[0] = "Invalid Username/Password/Email combination" $avArray[1] = "You have been suspended for Vacation Mode" $sHTML = _IEDocReadHTML ($oIE) $error = StringInStr($sHTML, $avArray) EndFuncAny help is appreciated, I've never handled arrays before so forgive me.Regards,-Matt Edited January 29, 2012 by Googler24022 Link to comment Share on other sites More sharing options...
JSThePatriot Posted December 5, 2006 Share Posted December 5, 2006 Func koc_error () Dim $avArray[2] $avArray[0] = "Invalid Username/Password/Email combination" $avArray[1] = "You have been suspended for Vacation Mode" $sHTML = _IEDocReadHTML ($oIE) For $i = 0 To UBound($avArray) Step 1 $error = StringInStr($sHTML, $avArray[$i]) If $error Then ;Do something about error. MsgBox(48 + 262144, "Error!", $avArray[$i]) EndIf Next EndFunc The above code should sort out your problems. I hope it also helps you learn. Thanks, JS AutoIt Links File-String Hash Plugin Updated! 04-02-2008 Plugins have been discontinued. I just found out. ComputerGetInfo UDF's Updated! 11-23-2006 External Links Vortex Revolutions Engineer / Inventor (Web, Desktop, and Mobile Applications, Hardware Gizmos, Consulting, and more) Link to comment Share on other sites More sharing options...
Googler24022 Posted December 5, 2006 Author Share Posted December 5, 2006 (edited) Thanks for the fast reply, but there was an error when pressing "Ok" on the msgbox. >"C:\Program Files\AutoIt3\SciTE\..\autoit3.exe" /ErrorStdOut "C:\Documents and Settings\Mathew\Desktop\KingsofChaos Bot\Kings of Kaos Money Bot.au3" C:\Documents and Settings\Mathew\Desktop\KingsofChaos Bot\Kings of Kaos Money Bot.au3 (70) : ==> Array variable has incorrect number of subscripts or subscript dimension range exceeded.: $error = StringInStr($sHTML, $avArray[$i]) $error = StringInStr($sHTML, ^ ERROR >Exit code: 0 Time: 5.803 Edited December 5, 2006 by Googler24022 Link to comment Share on other sites More sharing options...
Googler24022 Posted December 5, 2006 Author Share Posted December 5, 2006 Fixed it, you forgot to add the 0 dimension to the ubound part. Regards, -Matt. Link to comment Share on other sites More sharing options...
Moderators big_daddy Posted December 5, 2006 Moderators Share Posted December 5, 2006 (edited) Actually you just need to change this... For $i = 0 To UBound($avArray) Step 1oÝ÷ Ù:-+ºÚ"µÍÜ ÌÍÚHHÈPÝ[ ÌÍØ]^JHH Edited December 5, 2006 by big_daddy Link to comment Share on other sites More sharing options...
JSThePatriot Posted December 5, 2006 Share Posted December 5, 2006 Actually you just need to change this... For $i = 0 To UBound($avArray) Step 1oÝ÷ Ù:-+ºÚ"µÍÜ ÌÍÚHHÈPÝ[ ÌÍØ]^JHH Thanks big_daddy. @Googler24022 Sorry I didn't catch that the first time. AutoIt Links File-String Hash Plugin Updated! 04-02-2008 Plugins have been discontinued. I just found out. ComputerGetInfo UDF's Updated! 11-23-2006 External Links Vortex Revolutions Engineer / Inventor (Web, Desktop, and Mobile Applications, Hardware Gizmos, Consulting, and more) Link to comment Share on other sites More sharing options...
Googler24022 Posted December 5, 2006 Author Share Posted December 5, 2006 I'm not quite sure what you did there with the -1. Does this tell the loop to keep going untill there are no more array values? Link to comment Share on other sites More sharing options...
JSThePatriot Posted December 5, 2006 Share Posted December 5, 2006 I'm not quite sure what you did there with the -1. Does this tell the loop to keep going untill there are no more array values? UBound finds the Upper Bounds of the array. In your example that number is 2. Well AutoIt arrays are 0 based meaning the 1st array element is at $array[0] not $array[1]. So what adding - 1 to the For...Next loop does is makes the top of the array equal to 1. For $i = 0 to 1 Step 1 First time $i = value second time its that value + step. I hope I have explained this well. JS AutoIt Links File-String Hash Plugin Updated! 04-02-2008 Plugins have been discontinued. I just found out. ComputerGetInfo UDF's Updated! 11-23-2006 External Links Vortex Revolutions Engineer / Inventor (Web, Desktop, and Mobile Applications, Hardware Gizmos, Consulting, and more) Link to comment Share on other sites More sharing options...
Moderators big_daddy Posted December 5, 2006 Moderators Share Posted December 5, 2006 I'm not quite sure what you did there with the -1. Does this tell the loop to keep going untill there are no more array values?Well think about an array with 3 elements... $aArray[0] $aArray[1] $aArray[2]oÝ÷ Ùµ¢éÝÓ~ºÚËöðYkzÛ«|!Èb±Ê+ç-½êâ*.vayú%"¨¹éݺh¢§bëºÚ"µÍÜ ÌÍÚHHÈPÝ[ ÌÍØP^J Link to comment Share on other sites More sharing options...
JSThePatriot Posted December 5, 2006 Share Posted December 5, 2006 Well think about an array with 3 elements... $aArray[0] $aArray[1] $aArray[2]oÝ÷ Ùµ¢éÝÓ~ºÚËöðYkzÛ«|!Èb±Ê+ç-½êâ*.vayú%"¨¹éݺh¢§bëºÚ"µÍÜ ÌÍÚHHÈPÝ[ ÌÍØP^J A much simpler way to put it. JS AutoIt Links File-String Hash Plugin Updated! 04-02-2008 Plugins have been discontinued. I just found out. ComputerGetInfo UDF's Updated! 11-23-2006 External Links Vortex Revolutions Engineer / Inventor (Web, Desktop, and Mobile Applications, Hardware Gizmos, Consulting, and more) Link to comment Share on other sites More sharing options...
Googler24022 Posted December 5, 2006 Author Share Posted December 5, 2006 I learnt something today, thanks. Regards, -Matt Link to comment Share on other sites More sharing options...
JSThePatriot Posted December 5, 2006 Share Posted December 5, 2006 I learnt something today, thanks.Regards,-MattExcellent happy to hear that.JS AutoIt Links File-String Hash Plugin Updated! 04-02-2008 Plugins have been discontinued. I just found out. ComputerGetInfo UDF's Updated! 11-23-2006 External Links Vortex Revolutions Engineer / Inventor (Web, Desktop, and Mobile Applications, Hardware Gizmos, Consulting, and more) Link to comment Share on other sites More sharing options...
Moderators big_daddy Posted December 5, 2006 Moderators Share Posted December 5, 2006 @JS - I think we both hit on some good points. @Googler24022 - That's what I would consider the goal! Link to comment Share on other sites More sharing options...
herewasplato Posted December 5, 2006 Share Posted December 5, 2006 (edited) ...UBound($aArray) will return 3 which is correct, however...Well done... I was working on sample code to explain this "- 1" concept also and I noticed that UBound is going to return whatever is "Dim'd" - or am I missing something here?Dim $TestArray[7] $TestArray[0] = "test text 0" $TestArray[1] = "test text 1" $TestArray[2] = "test text 2" MsgBox(0,"UBound",UBound($TestArray)) For $i = 0 to UBound($TestArray) - 1 MsgBox(0,$i,$TestArray[$i]) Next Edit: I'm not picking at your statement - I just had not noticed that before. Most arrays that I work with are from StringSplit, so I just use the zero element in loops. Edited December 5, 2006 by herewasplato [size="1"][font="Arial"].[u].[/u][/font][/size] Link to comment Share on other sites More sharing options...
Moderators big_daddy Posted December 5, 2006 Moderators Share Posted December 5, 2006 Well done... I was working on sample code to explain this "- 1" concept also and I noticed that UBound is going to return whatever is "Dim'd" - or am I missing something here?You are correct, the only exception to this is if the array has been ReDim'd. Link to comment Share on other sites More sharing options...
JSThePatriot Posted December 5, 2006 Share Posted December 5, 2006 Well done... I was working on sample code to explain this "- 1" concept also and I noticed that UBound is going to return whatever is "Dim'd" - or am I missing something here?Dim $TestArray[7] $TestArray[0] = "test text 0" $TestArray[1] = "test text 1" $TestArray[2] = "test text 2" MsgBox(0,"UBound",UBound($TestArray)) For $i = 0 to UBound($TestArray) - 1 MsgBox(0,$i,$TestArray[$i]) Next Edit: I'm not picking at your statement - I just had not noticed that before. Most arrays that I work with are from StringSplit, so I just use the zero element in loops. UBound returns what is Dim'd that is true. The place where UBound really becomes useful is when you ReDim to a new unknown level. JS AutoIt Links File-String Hash Plugin Updated! 04-02-2008 Plugins have been discontinued. I just found out. ComputerGetInfo UDF's Updated! 11-23-2006 External Links Vortex Revolutions Engineer / Inventor (Web, Desktop, and Mobile Applications, Hardware Gizmos, Consulting, and more) 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