Eekhoorn Posted March 26, 2011 Share Posted March 26, 2011 Hey, I got this script but it's not working like it should be. The sub scripts are perfect(and simple:)). Here is the code: WinWaitActive("Untitled - Notepad") #include <script1.au3> #include <script2.au3> #include <script3.au3> #include <script4.au3> dim $aRun[4] = ["script1.au3", "script2.au3", "script3.au3", "script4.au3"] $rand = random(1,4,1) dim $iCount $iCount = 0 while 1 if $iCount < 100 then run($arun[$rand]) $iCount = $iCount + 1 WEnd Really need help, thanks in advance! It works well actually, but it doesn't repeat... Link to comment Share on other sites More sharing options...
water Posted March 26, 2011 Share Posted March 26, 2011 (edited) The index of an array starts with 0. So you have to change the random statement to generate numbers between 0 and 3 for an array with 4 elements: $rand = random(0,3,1) Edited March 26, 2011 by water My UDFs and Tutorials: Spoiler UDFs:Active Directory (NEW 2022-02-19 - Version 1.6.1.0) - Download - General Help & Support - Example Scripts - WikiExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example ScriptsOutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - WikiOutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - DownloadOutlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - WikiPowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - WikiTask Scheduler (NEW 2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki Standard UDFs:Excel - Example Scripts - WikiWord - Wiki Tutorials:ADO - WikiWebDriver - Wiki Link to comment Share on other sites More sharing options...
Eekhoorn Posted March 26, 2011 Author Share Posted March 26, 2011 The index of an array starts with 0. So you have to change the random statement to generate numbers between 0 and 3 for an array with 4 elements: $rand = random(0,3,1) Changed that, but still the same problem.. It gives no error and it doesnt shut done btw Link to comment Share on other sites More sharing options...
water Posted March 26, 2011 Share Posted March 26, 2011 (edited) I've reformated your script a bit. What you need is some error checking. Run the script and post what you get in SciTe. #include <script1.au3> #include <script2.au3> #include <script3.au3> #include <script4.au3> Global $aRun[4] = ["script1.au3", "script2.au3", "script3.au3", "script4.au3"] $iRand = random(0,3,1) Global $iCount = 0 WinWaitActive("Untitled - Notepad") While 1 if $iCount < 100 then $iResult = run($aRun[$iRand]) ConsoleWrite("Script " & $aRun[$iRand] & " executed. @error = " & @error & ", @extended = " & @extended) Else Exit Endif $iCount = $iCount + 1 WEnd Edited March 26, 2011 by water My UDFs and Tutorials: Spoiler UDFs:Active Directory (NEW 2022-02-19 - Version 1.6.1.0) - Download - General Help & Support - Example Scripts - WikiExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example ScriptsOutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - WikiOutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - DownloadOutlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - WikiPowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - WikiTask Scheduler (NEW 2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki Standard UDFs:Excel - Example Scripts - WikiWord - Wiki Tutorials:ADO - WikiWebDriver - Wiki Link to comment Share on other sites More sharing options...
Eekhoorn Posted March 26, 2011 Author Share Posted March 26, 2011 (edited) I've reformated your script a bit. What you need is some error checking. Run the script and post what you get in SciTe. #include <script1.au3> #include <script2.au3> #include <script3.au3> #include <script4.au3> Global $aRun[4] = ["script1.au3", "script2.au3", "script3.au3", "script4.au3"] $iRand = random(1,4,1) Global $iCount = 0 WinWaitActive("Untitled - Notepad") While 1 if $iCount < 100 then $iResult = run($aRun[$iRand]) ConsoleWrite("Script " & $aRun[$iRand] & " executed. @error = " & @error & ", @extended = " & @extended) Else Exit Endif $iCount = $iCount + 1 WEnd Thanks! but $iResult is not declared and gives an error. dim $iResult doesnt work, neither does global $iResult. Any solutions ? edit: rand was declared, but we used iRand, changed that! no errors anymore now edit2: You know, he isn't doing the loop at all, it just runs script1, then script2 etc.. Edited March 26, 2011 by Eekhoorn Link to comment Share on other sites More sharing options...
water Posted March 26, 2011 Share Posted March 26, 2011 (edited) BTW: I didn't correct the error with the wrong index. The correct version is: #include <script1.au3> #include <script2.au3> #include <script3.au3> #include <script4.au3> Global $aRun[4] = ["script1.au3", "script2.au3", "script3.au3", "script4.au3"] Global $iResult $iRand = random(0,3,1) Global $iCount = 0 WinWaitActive("Untitled - Notepad") While 1 if $iCount < 100 then $iResult = run($aRun[$iRand]) ConsoleWrite("Script " & $aRun[$iRand] & " executed. @error = " & @error & ", @extended = " & @extended) Else Exit Endif $iCount = $iCount + 1 WEnd Edited March 26, 2011 by water My UDFs and Tutorials: Spoiler UDFs:Active Directory (NEW 2022-02-19 - Version 1.6.1.0) - Download - General Help & Support - Example Scripts - WikiExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example ScriptsOutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - WikiOutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - DownloadOutlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - WikiPowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - WikiTask Scheduler (NEW 2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki Standard UDFs:Excel - Example Scripts - WikiWord - Wiki Tutorials:ADO - WikiWebDriver - Wiki Link to comment Share on other sites More sharing options...
Eekhoorn Posted March 26, 2011 Author Share Posted March 26, 2011 BTW: I didn't correct the error with the wrong index. The correct version is: #include <script1.au3> #include <script2.au3> #include <script3.au3> #include <script4.au3> Global $aRun[4] = ["script1.au3", "script2.au3", "script3.au3", "script4.au3"] Global $iResult $iRand = random(0,3,1) Global $iCount = 0 WinWaitActive("Untitled - Notepad") While 1 if $iCount < 100 then $iResult = run($aRun[$iRand]) ConsoleWrite("Script " & $aRun[$iRand] & " executed. @error = " & @error & ", @extended = " & @extended) Else Exit Endif $iCount = $iCount + 1 WEnd same problem, read post above . Link to comment Share on other sites More sharing options...
MHz Posted March 26, 2011 Share Posted March 26, 2011 edit2: You know, he isn't doing the loop at all, it just runs script1, then script2 etc..Be aware that #including those files can execute script1, then script2 etc... as you are actually including the code from those included scripts into the main script. Also be aware that Run() executes files that are executable so au3 files may not be executable. 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