adriancs35 Posted December 15, 2014 Share Posted December 15, 2014 Hello, so is there any possible way to restart a script instead of exitting when an error occurs?Yes I know the error will still happen even after 1000 restarts, but my error is about mysql, basically I want my script to do SELECT statements from a table with EzMysql but sometimes that tables is empty so an error will occur in autoit because you can't SELECT nothing...So my script breaks at the half..What I want to do is to restart the script instead of exitting so that my program will scan the sql table until i will insert a row so it will be able to execute the next steps in my script. P.S.:The scripts break around here : _EzMySql_Startup("\MYSQL") $sqlConnect = _EzMySql_Open("127.0.0.1", "root", "", "vrgaming", 3306, "", 0) _EzMySql_Query('SELECT * FROM warns WHERE pctid = '& $sFileRead &'') $myRows = _EzMySql_Rows() ;Numara rowurile rezultate in urma query-ului. _EzMySql_QueryFinalize() $i = 1 $row = _EzMySql_GetTable2d('SELECT * FROM warns WHERE pctid = '& $sFileRead &'') _EzMySql_QueryFinalize() Do MsgBox($MB_SYSTEMMODAL, "Warning!", $row[$i][1], 10) $i = $i + 1 Until $i = $myRows + 1 ==> Array variable has incorrect number of subscripts or subscript dimension range exceeded.: Link to comment Share on other sites More sharing options...
BrewManNH Posted December 15, 2014 Share Posted December 15, 2014 You should check that what's returned is an array before you do anything with it. If you put this into a loop, you can just use ContinueLoop when it gets something that's not an array, or not an array of the correct size and or dimensions. If I posted any code, assume that code was written using the latest release version unless stated otherwise. Also, if it doesn't work on XP I can't help with that because I don't have access to XP, and I'm not going to.Give a programmer the correct code and he can do his work for a day. Teach a programmer to debug and he can do his work for a lifetime - by Chirag GudeHow to ask questions the smart way! I hereby grant any person the right to use any code I post, that I am the original author of, on the autoitscript.com forums, unless I've specifically stated otherwise in the code or the thread post. If you do use my code all I ask, as a courtesy, is to make note of where you got it from. Back up and restore Windows user files _Array.au3 - Modified array functions that include support for 2D arrays. - ColorChooser - An add-on for SciTE that pops up a color dialog so you can select and paste a color code into a script. - Customizable Splashscreen GUI w/Progress Bar - Create a custom "splash screen" GUI with a progress bar and custom label. - _FileGetProperty - Retrieve the properties of a file - SciTE Toolbar - A toolbar demo for use with the SciTE editor - GUIRegisterMsg demo - Demo script to show how to use the Windows messages to interact with controls and your GUI. - Latin Square password generator Link to comment Share on other sites More sharing options...
Moderators SmOke_N Posted December 15, 2014 Moderators Share Posted December 15, 2014 Check the UBound of the array before checking the value. Really, instead of a Do/Until loop you should use a For/Next loop to manage your code: For $i = 1 To UBound($row) - 1 MsgBox($MB_SYSTEMMODAL, "Warning!", $row[$i][1], 10) Next Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer. 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