MKANET Posted June 14, 2012 Share Posted June 14, 2012 I recently migrated from a batch file world.So, for an autoit code such as:If StringRegExp($read, "MultiServer = yes") Then ExitAll I would have to do is insert the word NOT to get what I want done....If NOT StringRegExp($read, "MultiServer = yes") Then ExitSo, what's the simplest possible way to say if "MultiServer = yes" was not found in the text file to exit the autoit script?I tried search for examples, but what I found looked unecessarily complex.Thanks so much in advance! Link to comment Share on other sites More sharing options...
UEZ Posted June 14, 2012 Share Posted June 14, 2012 Try If Not StringInStr($read, "MultiServer = yes") Then Exit Br, UEZ Please don't send me any personal message and ask for support! I will not reply! Selection of finest graphical examples at Codepen.io The own fart smells best! ✌Her 'sikim hıyar' diyene bir avuç tuz alıp koşma!¯\_(ツ)_/¯ ٩(●̮̮̃•̃)۶ ٩(-̮̮̃-̃)۶ૐ Link to comment Share on other sites More sharing options...
MKANET Posted June 14, 2012 Author Share Posted June 14, 2012 Thank you!! So, it is exactly like batch file logic! Cool.. trying it now. Link to comment Share on other sites More sharing options...
Moderators JLogan3o13 Posted June 14, 2012 Moderators Share Posted June 14, 2012 (edited) Hi MKANET. Did you TRY If Not StringRegExp($read, "MultiServer = yes") Then Exit??$read = "093606-CAR095193-NUR098927-ped101247-pedMultiServer = yes101713-car102902-car103244-ped103303-ped104739-car105276-car" If Not StringRegExp($read, "MultiServer = yes") Then MsgBox(0, "", "Not there") Else MsgBox(0, "", "It's there") EndIfEdit: Man I wish the page would update correctly when a new post appears Edited June 14, 2012 by JLogan3o13 "Profanity is the last vestige of the feeble mind. For the man who cannot express himself forcibly through intellect must do so through shock and awe" - Spencer W. Kimball How to get your question answered on this forum! Link to comment Share on other sites More sharing options...
Mechaflash Posted June 14, 2012 Share Posted June 14, 2012 Thank you!! So, it is exactly like batch file logic! Cool.. trying it now.So you didn't try it in the first place? Spoiler “Hello, ladies, look at your man, now back to me, now back at your man, now back to me. Sadly, he isn’t me, but if he stopped using ladies scented body wash and switched to Old Spice, he could smell like he’s me. Look down, back up, where are you? You’re on a boat with the man your man could smell like. What’s in your hand, back at me. I have it, it’s an oyster with two tickets to that thing you love. Look again, the tickets are now diamonds. Anything is possible when your man smells like Old Spice and not a lady. I’m on a horse.” Link to comment Share on other sites More sharing options...
MKANET Posted June 14, 2012 Author Share Posted June 14, 2012 I didn't presume it would just work; especially since I didn't find any examples. It turns out it works fine! I guess autoit is closer to batch files than I realized! Thanks for the tip! Link to comment Share on other sites More sharing options...
Mechaflash Posted June 14, 2012 Share Posted June 14, 2012 I didn't presume it would just work; especially since I didn't find any examples. It turns out it works fine! I guess autoit is closer to batch files than I realized! Thanks for the tip! It has to do with return values and true/false. In AutoIt, 0 or "" returns false while non-zero and non-empty string returns true. If you look at the help file notes on StringRegExp(), you'll see that by default, it returns 0 if it doesn't find it (false) or 1 if it does (true). So saying If Not Function() Then [...] also means If (function returns 0) If Function() Then [...] also means If (Function returns non-zero). So if you do If Not FileExists($file) Then msgbox(0,"","NOT HERE") If it doesn't find a file the msgbox() will appear because FileExists() returns 0 if a file isn't found. Most of the AutoIt functions work in this manner. Always check the help file however because some return 0 when it worked and -1 when it doesn't... which goes against these rules because 0 matches false and -1 matches true. =/ Spoiler “Hello, ladies, look at your man, now back to me, now back at your man, now back to me. Sadly, he isn’t me, but if he stopped using ladies scented body wash and switched to Old Spice, he could smell like he’s me. Look down, back up, where are you? You’re on a boat with the man your man could smell like. What’s in your hand, back at me. I have it, it’s an oyster with two tickets to that thing you love. Look again, the tickets are now diamonds. Anything is possible when your man smells like Old Spice and not a lady. I’m on a horse.” Link to comment Share on other sites More sharing options...
MKANET Posted June 14, 2012 Author Share Posted June 14, 2012 I did a bunch of Internet searches before posting (which usually gives me the information I need); and, even saw the return value of 0 or 1. I just didn't know what the correct way of saying "NOT". I was too focused on finding the right regex for this and thinking I might have to do a condition for the value returned. If you see in my first post. I already guessed it exactly correct; which made perfect sense to me... I just didn't think there was a chance I could actually be right But thanks very much for the examples! 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