FinalVersion Posted June 18, 2010 Share Posted June 18, 2010 Why can't you have this sort of If statement? Or am I just coding it wrong? If ($Var = Function(..., ...)) == 0 Then [center][+] Steam GUI [+][+] Clipboard Tool [+][+] System :: Uptime [+][+] StarCraft II Mouse Trap [+][/center] Link to comment Share on other sites More sharing options...
bo8ster Posted June 18, 2010 Share Posted June 18, 2010 Why can't you have this sort of If statement? Or am I just coding it wrong? If ($Var = Function(..., ...)) == 0 Then I could say not correct. If $Var == Function(..., ...) Then or If NOT $Var == Function(..., ...) Then There is no need for the additional level of comparison. I am assuming you are not doing assignment in your example, this Function returns 5 so $var = 5 then doing if 5 equals 0. I have never done this in C so I can't say if it works but would be hit over the head for trying it. Post your code because code says more then your words can. SciTe Debug mode - it's magic: #AutoIt3Wrapper_run_debug_mode=Y. Use Opt("MustDeclareVars", 1)[topic="84960"]Brett F's Learning To Script with AutoIt V3[/topic][topic="21048"]Valuater's AutoIt 1-2-3, Class... is now in Session[/topic]Contribution: [topic="87994"]Get SVN Rev Number[/topic], [topic="93527"]Control Handle under mouse[/topic], [topic="91966"]A Presentation using AutoIt[/topic], [topic="112756"]Log ConsoleWrite output in Scite[/topic] Link to comment Share on other sites More sharing options...
FinalVersion Posted June 18, 2010 Author Share Posted June 18, 2010 That's only 2 possibilities, 0 or 1. What if I wanted to check for something other then 1 or 0? [center][+] Steam GUI [+][+] Clipboard Tool [+][+] System :: Uptime [+][+] StarCraft II Mouse Trap [+][/center] Link to comment Share on other sites More sharing options...
AlmarM Posted June 18, 2010 Share Posted June 18, 2010 $var = Function(..., ...) If ($var == "something_the_function_returned") Then ; == means case-sense EndIf You mean like this? Minesweeper A minesweeper game created in autoit, source available. _Mouse_UDF An UDF for registering functions to mouse events, made in pure autoit. 2D Hitbox Editor A 2D hitbox editor for quick creation of 2D sphere and rectangle hitboxes. Link to comment Share on other sites More sharing options...
FinalVersion Posted June 18, 2010 Author Share Posted June 18, 2010 Yeah I can do it like that, but I'd like the if and declaration of $var on the same line. [center][+] Steam GUI [+][+] Clipboard Tool [+][+] System :: Uptime [+][+] StarCraft II Mouse Trap [+][/center] Link to comment Share on other sites More sharing options...
AlmarM Posted June 18, 2010 Share Posted June 18, 2010 (edited) If (Add(5, 5) = 10) Then MsgBox(0, "", "Succes!") EndIf If (Paste("Hello", "World") == "HelloWorld") Then MsgBox(0, "", "Succes!") EndIf Func Add($Param1, $Param2) Return $Param1 + $Param2 EndFunc Func Paste($Param1, $Param2) Return $Param1 & $Param2 EndFuncAs far as I know, you can't declare a variable inside an If statement. Im coding C# and know what you mean. Edited June 18, 2010 by AlmarM Minesweeper A minesweeper game created in autoit, source available. _Mouse_UDF An UDF for registering functions to mouse events, made in pure autoit. 2D Hitbox Editor A 2D hitbox editor for quick creation of 2D sphere and rectangle hitboxes. Link to comment Share on other sites More sharing options...
FinalVersion Posted June 18, 2010 Author Share Posted June 18, 2010 (edited) Didn't see your edit, well that sucks. Edited June 18, 2010 by FinalVersion [center][+] Steam GUI [+][+] Clipboard Tool [+][+] System :: Uptime [+][+] StarCraft II Mouse Trap [+][/center] Link to comment Share on other sites More sharing options...
AlmarM Posted June 18, 2010 Share Posted June 18, 2010 (edited) I know, refresh the page and read my previous post again. Edited June 18, 2010 by AlmarM Minesweeper A minesweeper game created in autoit, source available. _Mouse_UDF An UDF for registering functions to mouse events, made in pure autoit. 2D Hitbox Editor A 2D hitbox editor for quick creation of 2D sphere and rectangle hitboxes. Link to comment Share on other sites More sharing options...
AndyG Posted June 18, 2010 Share Posted June 18, 2010 regardless of the fact that '==' is a string comparison....2 cases are possible in if/then:if TRUE then if FALSE then ;or if 0 then ... everything other than 0 is TRUE so you have to distinguish if the expression (($Var = Function(..., ...)) = 0) is true or not($Var = Function(..., ...)) could be TRUE or FALSE, nothing else!so the expression TRUE=0 has the result FALSEand FALSE=0 has the result TRUEExample:For $var = 1 To 3 For $para = 1 To 2 If ($var = _Function($para)) = 0 Then ;is it true or false? MsgBox(0,"$var="&$var&" $para="&$para&" --> "& (($var = _Function($para)) = 0), "(" & $var & " = _Function(" & $para & ")) is " & ($var = _Function($para)) & @CRLF & "so " & ($var = _Function($para)) & " = 0 is " & (($var = _Function($para)) = 0)) Else MsgBox(0,"$var="&$var&" $para="&$para&" --> "& (($var = _Function($para)) = 0), "(" & $var & " = _Function(" & $para & ")) is " & ($var = _Function($para)) & @CRLF & "so " & ($var = _Function($para)) & " = 0 is " & (($var = _Function($para)) = 0)) EndIf Next Next Func _function($a) Return $a EndFunc ;==>_function 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