cowboy713 Posted June 8, 2012 Share Posted June 8, 2012 Hello everyone. I just started working with Autoit about a week ago and I only have a a minor amount of coding experience but so far I think it's coming along pretty well. Anyway I'm trying to write a loop and within it there will be an if statement called but I can't seem to figure out what I'm doing wrong. Currently whenever I run it it doesn't seem to ever get past the first If condition. Local $i = 0 While $i<20 If $i == 2 or 5 or 11 or 16 Then _Func1() Else _Func2() $i= $i + 1 EndIf WEnd I had also tried using a do until and just setting it to Until $i==20 but that was unsuccessful as well. Any idea where I'm messing this up? Link to comment Share on other sites More sharing options...
JohnOne Posted June 8, 2012 Share Posted June 8, 2012 If $i = 2 or $i = 5 or $i = 11 or $i = 16 Then AutoIt Absolute Beginners Require a serial Pause Script Video Tutorials by Morthawt ipify Monkey's are, like, natures humans. Link to comment Share on other sites More sharing options...
water Posted June 8, 2012 Share Posted June 8, 2012 Your code shouldn't ever pass the syntax check because your if statement is wrong.You need to dig into the AutoIt language before writing scripts. Check the Wiki for some very good tutorials. I think what you need is something liek this: Local $i = 0 While $i < 20 If $i = 2 Or $i = 5 Or $i = 11 Or $i = 16 Then _Func1() Else _Func2() EndIf $i = $i + 1 WEnd 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...
Kidney Posted June 8, 2012 Share Posted June 8, 2012 If $i = 2 or $i = 5 or $i = 11 or $i = 16 ThenThis. Also, a short hand to adding an integer to a variable and setting it equal to itself looks like this:$i += 1 Link to comment Share on other sites More sharing options...
JohnOne Posted June 8, 2012 Share Posted June 8, 2012 (edited) I'd probably do it something like this... Local $i = 0 While $i < 20 Switch $i Case 2, 5, 11, 16 _Func1() Case Else _Func2() EndSwitch $i = $i + 1 WEnd Edited June 8, 2012 by JohnOne AutoIt Absolute Beginners Require a serial Pause Script Video Tutorials by Morthawt ipify Monkey's are, like, natures humans. Link to comment Share on other sites More sharing options...
cowboy713 Posted June 8, 2012 Author Share Posted June 8, 2012 (edited) Figured it would be a simple mistake I was making >.< Since every seems to be quite active hopefully you could answer one other quite question. I was reading through the different Autoit language references for example of what I was trying to do. With something like Local $i = 0 While $i <= 10 MsgBox(0, "Value of $i is:", $i) $i = $i + 1 WEnd for example, what else would I need to put into SciTE to be able to run and test that? Originally I was trying to test my previous code using just MsgBoxes instead of calling the functions to make everything simpler. But the code I just posted I can't seem to run a quick test. Would I need to add in an active function window or a function for the MsgBoxes ? Thanks for the quite replies, you guys are on the ball considering how early it still is lol. Edit: Had been trying F5, turned out the reason it wasn't working was since I hadn't bothered to save it since it was just a quick test... Oh man. Thanks for the help again though guys. Edited June 8, 2012 by cowboy713 Link to comment Share on other sites More sharing options...
water Posted June 8, 2012 Share Posted June 8, 2012 ... what else would I need to put into SciTE to be able to run and test that? ...Press F5 in SciTE? 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...
JohnOne Posted June 8, 2012 Share Posted June 8, 2012 ConsoleWrite("Value of $i is:" & $i & @LF) AutoIt Absolute Beginners Require a serial Pause Script Video Tutorials by Morthawt ipify Monkey's are, like, natures humans. 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