Newb Posted May 25, 2012 Share Posted May 25, 2012 (edited) Which is the shorthand for an If expression in autoit?On a help file i found thisIf true = 1 then MsgBox(1,"Is it true?","Yarp!")but I would like to see something for an expression likeIf 5+5=10 Then ConsoleWrite("Jjj") Else ConsoleWrite("nnn") EndIfWhat about it?If 5+5=10 Then ConsoleWrite("Jjj")But what about else? Edited May 25, 2012 by Newb I'm a compulsive poster. When I post something, come to read it at least 5 minutes later after the posting, because I will edit it. I edited even this signature a few minutes later after I wrote it. Link to comment Share on other sites More sharing options...
BrewManNH Posted May 25, 2012 Share Posted May 25, 2012 Not sure what your question is. The second If statement should work, but will always show the Jjj in the console because 5 + 5 will always equal 10, change the 10 to 11 to see the else condition. 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...
Newb Posted May 25, 2012 Author Share Posted May 25, 2012 (edited) The question is, how do i set the else condition in that shortand if statement?In some languages there is a one line if statement like thisBooleanVariable=(condition=true)?"ok":"not true"or something like that. How do I replicate it in autoit? Edited May 25, 2012 by Newb I'm a compulsive poster. When I post something, come to read it at least 5 minutes later after the posting, because I will edit it. I edited even this signature a few minutes later after I wrote it. Link to comment Share on other sites More sharing options...
MvGulik Posted May 25, 2012 Share Posted May 25, 2012 Answer: You can't, as there is no Else in the short version.http://www.autoitscript.com/autoit3/docs/keywords/If.htm"Conditionally run a single statement." "Straight_and_Crooked_Thinking" : A "classic guide to ferreting out untruths, half-truths, and other distortions of facts in political and social discussions.""The Secrets of Quantum Physics" : New and excellent 2 part documentary on Quantum Physics by Jim Al-Khalili. (Dec 2014) "Believing what you know ain't so" ... Knock Knock ... Link to comment Share on other sites More sharing options...
Newb Posted May 25, 2012 Author Share Posted May 25, 2012 Good to know. A pity, as most languages implement such thing, but whatever. Thanks to all. I'm a compulsive poster. When I post something, come to read it at least 5 minutes later after the posting, because I will edit it. I edited even this signature a few minutes later after I wrote it. Link to comment Share on other sites More sharing options...
kaotkbliss Posted May 25, 2012 Share Posted May 25, 2012 (edited) you could do If 5+5=10 Then ConsoleWrite("Jjj") If 5+5<>10 Then ConsoleWrite("nnn") I think that's about as close as you will get Edited May 25, 2012 by kaotkbliss 010101000110100001101001011100110010000001101001011100110010000 001101101011110010010000001110011011010010110011100100001 My Android cat and mouse gamehttps://play.google.com/store/apps/details?id=com.KaosVisions.WhiskersNSqueek We're gonna need another Timmy! Link to comment Share on other sites More sharing options...
Newb Posted May 25, 2012 Author Share Posted May 25, 2012 At that point an else would be a better solution. Thanks anyway. I'm a compulsive poster. When I post something, come to read it at least 5 minutes later after the posting, because I will edit it. I edited even this signature a few minutes later after I wrote it. Link to comment Share on other sites More sharing options...
lowray1975 Posted May 25, 2012 Share Posted May 25, 2012 The question is, how do i set the else condition in that shortand if statement?In some languages there is a one line if statement like thisBooleanVariable=(condition=true)?"ok":"not true"or something like that. How do I replicate it in autoit?I believe this will be supported in the next release (it's in beta now). Link to comment Share on other sites More sharing options...
Malkey Posted May 25, 2012 Share Posted May 25, 2012 The question is, how do i set the else condition in that shortand if statement?In some languages there is a one line if statement like thisBooleanVariable=(condition=true)?"ok":"not true"or something like that. How do I replicate it in autoit?Look up the _Iif() function in AutoIt help file. Link to comment Share on other sites More sharing options...
Newb Posted May 25, 2012 Author Share Posted May 25, 2012 Look up the _Iif() function in AutoIt help file. That's exactly what I meant! Nice to know, thanks Malkley. By the way I think I will stay on If... Then.... Else since my aim was to make the shortest code possible without implementing external libraries/UDF files. I was doing a decimal to binary converting function (I don't know if there is one in Autoit, couldn't find anything but Binary into Help file, and by the way I wanted to write one on my own) and I was trying to do it as short as possible with basic instructions. This is the shortest I achieved so far Func DecToBin($decim) Local $temp While $decim>=1 If Floor(Mod($decim,2))>0 Then $temp="1"&$temp Else $temp="0"&$temp EndIf $decim/=2 WEnd Return $temp EndFunc And I asked about the shorter If to cut that if in the while loop (I don't want to use _Iif, or external functions, but thanks for letting me know about it Malkey!) Any way to do my function shorter which is not a predefined autoit converting function? (Like Int, String etc etc) I'm a compulsive poster. When I post something, come to read it at least 5 minutes later after the posting, because I will edit it. I edited even this signature a few minutes later after I wrote it. 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