If...Then Mehrere Statements per Zeile

  • Hi,
    ist es möglich mehrere Then Statements in einer Zeile zu definieren:

    geht nicht, aber so in der Art

    [autoit]

    If $curElement = "" Then $e += 1 Then ContinueLoop

    [/autoit]

    sieht halt besser aus!

    Einmal editiert, zuletzt von Trolleule1337 (16. Februar 2013 um 00:54)

  • Einzige Möglichkeit wäre wohl:

    [autoit]

    If $curElement = "" Then
    $e +=1
    ContinueLoop
    EndIf

    [/autoit]

    Anders ist es nicht möglich, soweit ich weiß ;)

    Mfg
    (War das überhaupt eine Frage?)

    There's a joke that C has the speed and efficieny of assembly language combined with readability of....assembly language. In other words, it's just a glorified assembly language. - Teh Interwebz

    C makes it easy to shoot yourself in the foot; C++ makes it harder, but when you do, you blow off your whole leg. - Bjarne Stroustrup
    Genie zu sein, bedeutet für mich, alles zu tun, was ich will. - Klaus Kinski

  • so wie du es beschrieben hast, ist es ja Standard. Interessant wäre es in einer Zeile unterzubringen.

    Wieso funktioniert denn:

    [autoit]

    If $curElement = "" Then BitOr(MsgBox(0, "bla", "hier"), MsgBox(0, "bla", "hier"))

    [/autoit]

    Danke!

  • Weil Autoit eben so funktioniert... :D

    [autoit]

    If 1=1 Then $a = MsgBox(0,"","1") & MsgBox(0,"","2") & MsgBox(0,"","3") & Beep(500,1000) & GUICreate("loool",500,350) & GUISetState() & Sleep(5000)

    [/autoit]

    LG
    Christoph :)

    • Offizieller Beitrag

    Du kannst außer Schleifen und erzwungenermaßen mehrzeiligen Statements alles in AutoIt in einer Zeile ausführen. Z.B. indem du eine fortlaufende Variablendeklaration durchführst mit den Funktionen, die du aufrufst:

    [autoit]


    Global $a = InputBox(...Eingabe Zahl...), $b = InputBox(...Eingabe Zahl...), $c = $a + $b, $d = $a * $b, $gui = GuiCreate(..), $button = GuiCtrlCreateButton(..), ;....... usw. usf.

    [/autoit]
  • Okay anderer Versuch:

    [autoit]

    If StringInStr($aStDataTypes[$e], "PTR") <> 0 Then
    $curElement = DllStructGetData(DllStructCreate("WCHAR [260]", DllStructGetData($getPackageInfo, $e)), 1)
    If $curElement = "" Then $e += 1 & ContinueLoop ; ?????????????

    [/autoit][autoit][/autoit][autoit]

    EndIf

    Switch $index
    ...
    ...
    ...
    $e += 1

    [/autoit]

    Wenn $curElement = "" muss ich $index so setzen, dass er die Switch Schleife überspringt. Ich brauche entweder ein $e +=1 und ein ContinueLoop in einer Zeile oder $index so setzen, dass er nicht ins Switch reingeht. Hat jemand ne Idee?

    Einmal editiert, zuletzt von Trolleule1337 (15. Februar 2013 um 23:24)

  • Habt ihr überhaupt keine Fantasie ?
    Das ist total einfach, aber unschön. (bei Assign, Variante 2 ist besser)

    [autoit]

    Global $iDummy
    Global $a, $b, $c

    [/autoit][autoit][/autoit][autoit]

    If 6 > 5 Then $iDummy = Assign('a', 12345) + Assign('b', 'Penner') + Assign('c', 0xFF00FF)

    [/autoit][autoit][/autoit][autoit]

    ConsoleWrite($iDummy & @CRLF)
    ConsoleWrite($a & @CRLF)
    ConsoleWrite($b & @CRLF)
    ConsoleWrite($c & @CRLF & @CRLF)

    [/autoit][autoit][/autoit][autoit]

    ; Edit nach 1 Min
    If Not ('Tobi' == 'tobi') Then Zuweisen3x($a, 'Ich bin Variable 1', $b, 'Team Rocket so schnell wie das Licht', $c, 'Gib lieber auf und bekämpft uns nicht !')

    [/autoit][autoit][/autoit][autoit]

    ConsoleWrite($a & @CRLF)
    ConsoleWrite($b & @CRLF)
    ConsoleWrite($c & @CRLF)

    [/autoit][autoit][/autoit][autoit]

    Func Zuweisen3x(ByRef $a, $a_, ByRef $b, $b_, ByRef $c, $c_)
    $a = $a_
    $b = $b_
    $c = $c_
    EndFunc

    [/autoit]

    Man kann so viel man will zuweisen.
    Weils so schön ist, ist mir in 1 Min noch eine leichte Methode eingefallen.
    Bisschen überlegen vorher bitte :(

    Edit 2:
    Und wenns um Continueloop geht gibts natürlich auch eine Möglichkeit.
    ContinueLoop hat einen Level. also Continueloop 5 z.B.
    Als Statement für diesen Level kann ich 1 + 0 * Was auch immer, da es eh zu 0 wird benutzen.
    .
    .
    Lg

  • [autoit]

    For $i = 1 To 6
    If $i == 3 Then Execute("ConsoleWrite('+') Assign('lol', 3) ContinueLoop")
    ConsoleWrite("#")
    Next

    [/autoit][autoit][/autoit][autoit]

    MsgBox(0,0,$lol)

    [/autoit]

    So lässt sich auch ContinueLoop verbraten ^^.

  • Sehr kreativ, aber wie würdest du das hier in eine Zeile zaubern?

    [autoit]

    If $curElement = "" Then $e += 1 & ContinueLoop

    [/autoit]


    Dir bleibt wohl nichts anderes als ;)

    [autoit]

    If $curElement = "" Then
    $e +=1
    ContinueLoop
    EndIf

    [/autoit]

    Mfg

    There's a joke that C has the speed and efficieny of assembly language combined with readability of....assembly language. In other words, it's just a glorified assembly language. - Teh Interwebz

    C makes it easy to shoot yourself in the foot; C++ makes it harder, but when you do, you blow off your whole leg. - Bjarne Stroustrup
    Genie zu sein, bedeutet für mich, alles zu tun, was ich will. - Klaus Kinski

  • Und hier kommt die Lösung:

    [autoit]

    $aElem = StringSplit("3|234|nwg||324|214.2","|",2); Ein paar Elemte erzeugen, eines ist leer
    $e = 0; Am Anfang leer

    [/autoit][autoit][/autoit][autoit]

    For $sEach In $aElem
    If $sEach = "" Then Execute("Assign('e', Eval('e')+1) ContinueLoop")
    Next

    [/autoit][autoit][/autoit][autoit]

    MsgBox(0,0,$e)

    [/autoit]
  • Niemals! :D

    [autoit]

    $aElem = StringSplit("3|234|nwg||324|214.2","|",2); Ein paar Elemte erzeugen, eines ist leer
    $e = 0; Am Anfang leer

    [/autoit][autoit][/autoit][autoit]

    For $sEach In $aElem
    If $sEach = "" Then ContinueLoop Execute("Assign('e', Eval('e')+1)")
    ConsoleWrite("Nicht übersprungen" & @CRLF)
    Next

    [/autoit][autoit][/autoit][autoit]

    MsgBox(0,0,$e)

    [/autoit]

    Einmal editiert, zuletzt von minx (16. Februar 2013 um 00:32)

  • Bei mir macht er das Execute aber nicht das ContinueLoop. Ich bekomme trotzdem noch die Message vob "draußen":

    [autoit]

    If $curElement = "" Then
    MsgBox(0, "drinne", $e)
    ContinueLoop Execute("Assign('e', Eval('e')+1) ConsoleWrite('col: ' & $col & @crlf)")

    [/autoit][autoit][/autoit][autoit]

    EndIf
    MsgBox(0, "draußen", $e)

    [/autoit]

    Ne Idee?

  • Hier nochmal ein noch ausführlicheres Beispiel, dass dir selbst zeigt, dass es funktioniert :D:

    [autoit]

    $aElem = StringSplit("3|234|nwg||324|214.2","|",2); Ein paar Elemte erzeugen, eines ist leer
    $e = 0; Am Anfang leer

    [/autoit][autoit][/autoit][autoit]

    For $sEach In $aElem
    If $sEach = "" Then ContinueLoop Mod(Execute("Assign('e', Eval('e')+1)"),ConsoleWrite("-> [" & $sEach & @tab & @tab & "=> IST LEER]" & @crlf))
    ConsoleWrite($sEach & @TAB & @TAB & "=> ist nicht leer" & @CRLF)
    Next

    [/autoit][autoit][/autoit][autoit]

    MsgBox(0,0,$e)

    [/autoit]
  • An Alle:

    minx hat das Spiel gewonnen!

    Hatte eine Klammer im Assign vergessen. Ergo: Das nach dem ContinueLoop ausgeführte Statement muss richtig sein, sonst funktioniert weder das eine noch das andere!

    PainTain:

    Danke, aber leider verloren. :D