jercfd Posted November 16, 2008 Share Posted November 16, 2008 How come the if statement can't do two commands on one line? Example: If $i = 1 Then $ElementLeft = 599 And $ElementTop = 30 #include <GUIConstantsEx.au3> #include <StaticConstants.au3> #include <WindowsConstants.au3> $Form1 = GUICreate("Form1", 633, 447, 275, 231) Global $ElementLeft, $ElementTop For $i = 0 To 1 If $i = 0 Then $ElementLeft = 55 And $ElementTop = 30 If $i = 1 Then $ElementLeft = 599 And $ElementTop = 30 GUICtrlCreateLabel("", $ElementLeft, $ElementTop, 30, 30, $SS_BLACKFRAME) GUICtrlCreateLabel($i + 1, $ElementLeft + 2, $ElementTop + 1, 20, 10) GUICtrlSetFont(-1, 7.5, 400, 0, "Arial") GUICtrlCreateLabel("Text", $ElementLeft + 1, $ElementTop + 14, 28, 15, $SS_CENTER) GUICtrlSetFont(-1, 8, 800, 0, "MS Sans Serif") Next GUISetState(@SW_SHOW) While 1 $nMsg = GUIGetMsg() Switch $nMsg Case $GUI_EVENT_CLOSE Exit EndSwitch WEnd Link to comment Share on other sites More sharing options...
Dinosaurr Posted November 16, 2008 Share Posted November 16, 2008 If $i = 0 Then $ElementLeft = 55 $ElementTop = 30 EndIf Just an example of an if statement doing 2 things. /: Link to comment Share on other sites More sharing options...
herewasplato Posted November 16, 2008 Share Posted November 16, 2008 How come the if statement can't do two commands on one line? ...probably for the same reason that You cannot do this :-)MsgBox(0, "", "") And MsgBox(0, "", "")Is an EndIf gonna kill ya? Or do you just like the way the code looks without it? :-) [size="1"][font="Arial"].[u].[/u][/font][/size] Link to comment Share on other sites More sharing options...
herewasplato Posted November 16, 2008 Share Posted November 16, 2008 If $i = 0 Then $ElementLeft = 55 $ElementTop = 30 EndIf Just an example of an if statement doing 2 things. /:or this since $ElementTop = 30 is the sameFor $i = 0 To 1 $ElementTop = 30 If $i = 0 Then $ElementLeft = 55 If $i = 1 Then $ElementLeft = 599 ;;;; ;;;; ;;;; Next [size="1"][font="Arial"].[u].[/u][/font][/size] Link to comment Share on other sites More sharing options...
jercfd Posted November 16, 2008 Author Share Posted November 16, 2008 I was just asking why. I'm just trying to optimize my code to have as little lines as possible. Link to comment Share on other sites More sharing options...
herewasplato Posted November 16, 2008 Share Posted November 16, 2008 I was just asking why. I'm just trying to optimize my code to have as little lines as possible.Yep - I understand that :-)I don't know the technical reason.Having fewer characters is a goal too:$ElementTop = 30If $i = 0 Then $ElementLeft = 55If $i = 1 Then $ElementLeft = 599orIf $i = 0 Then $ElementLeft = 55 And $ElementTop = 30If $i = 1 Then $ElementLeft = 599 And $ElementTop = 30Maybe a dev will drop by and enlighten us - in the meantime, enjoy AutoIt :-) [size="1"][font="Arial"].[u].[/u][/font][/size] Link to comment Share on other sites More sharing options...
trancexx Posted November 16, 2008 Share Posted November 16, 2008 (edited) probably for the same reason that You cannot do this :-)MsgBox(0, "", "") And MsgBox(0, "", "")oÝ÷ ØIÝ!ø(v¤YrhêÝ£*.ë-)¶°k+ayÊzZ(Ì"¶.¶+ªê-xÊjwh¶¬jëh×6$e = MsgBox(0, "", "") And MsgBox(0, "", "") edit: I recon you owe me a drink for that. Edited November 16, 2008 by trancexx ♡♡♡ . eMyvnE Link to comment Share on other sites More sharing options...
monoceres Posted November 16, 2008 Share Posted November 16, 2008 (edited) Since AutoIt uses Lazy Evaluation you can actually do custom ifs inside the regular if. So: If $i = 0 Then $ElementLeft = 55 $ElementTop = 30 EndIf Can be expressed as: If $i=0 And (Assign("ElementLeft",55) And Assign("ElementTop",30)) And 0 Then Exit I once did a whole GUI with this method, it's in my sig. Edited November 16, 2008 by monoceres Broken link? PM me and I'll send you the file! Link to comment Share on other sites More sharing options...
jercfd Posted November 16, 2008 Author Share Posted November 16, 2008 Thanks for all the replies. I kind of prefer monoceres way of assigning variable values Link to comment Share on other sites More sharing options...
monoceres Posted November 16, 2008 Share Posted November 16, 2008 Thanks for all the replies. I kind of prefer monoceres way of assigning variable valuesSeriously? My way is clearly dumbest and is really only for showing off. Broken link? PM me and I'll send you the file! Link to comment Share on other sites More sharing options...
trancexx Posted November 16, 2008 Share Posted November 16, 2008 It's for mowing chicks. Like... Hi baby! Take look at this. Ha? What do you think? ... you like it? Damn, you look good. What's your name? anyways... sorry ♡♡♡ . eMyvnE Link to comment Share on other sites More sharing options...
monoceres Posted November 16, 2008 Share Posted November 16, 2008 It's for mowing chicks.Like... Hi baby! Take look at this. Ha? What do you think? ... you like it? Damn, you look good. What's your name?anyways... sorry Who doesn't use their AutoIt skillz when hunting Broken link? PM me and I'll send you the file! 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