wisem2540 Posted March 22, 2013 Share Posted March 22, 2013 I have an app that can point to 1 of 4 servers. In an effort to pseudo load balance, everytime I launch the app, I would like a different server to appear in the server box. I assume I could control this by doing a regwrite. I could put the 4 server names into an array I suppose, or read them from a text file. but how can I get autoit to choose one of them at random and store it to a variable? Link to comment Share on other sites More sharing options...
water Posted March 22, 2013 Share Posted March 22, 2013 Check function Random.$iNumber = Random(1, 4, 1)willl give you an interger between 1 an 4. 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...
wisem2540 Posted March 22, 2013 Author Share Posted March 22, 2013 Just so im clear, would I then use this integer to reference a line in a theoretical array? Link to comment Share on other sites More sharing options...
water Posted March 22, 2013 Share Posted March 22, 2013 (edited) Correct. Example:Global $aServer[4] = ["Server1", "Server2", "Server3", "Server4"] $sServerToUse = $aServer[Random(0, 3, 1)] ; 0 - 3 because the index of an array starts with 0 Edited March 22, 2013 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...
wisem2540 Posted March 22, 2013 Author Share Posted March 22, 2013 Water, thanks. I added a regread to get the current value. Then a Do-Until $Currentvalue <> $sServerToUse, to prevent it from returning the same value consecutively. - then obviously a regwrite on $sServertoUse. It works well. Thanks again. Link to comment Share on other sites More sharing options...
water Posted March 22, 2013 Share Posted March 22, 2013 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...
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