Schleifen Problem

  • Hi leute ich habe folgene schleifen

    Spoiler anzeigen
    [autoit]

    $a = 5
    $location = 10
    For $i = 1 To 2 ; Um alle Links zu bekommen

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

    For $i = 0 To $a
    msgbox(0,"",$i)
    $location = $location -1
    if $location = 0 Then
    Exitloop 2
    Endif

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

    Next
    Next

    [/autoit]


    die 2 schleife soll so lange laufen bis Location= 0 ist
    und Möchte erreichen das folgene msgboxen rauskommen
    0
    1
    2
    3
    4
    5
    0
    1
    2
    3
    4
    5
    allerdings kommt nur die hälfte wiso ?
    hoffe ihr könnt mir helfen danke im vorraus JMR

    Einmal editiert, zuletzt von JMR (13. April 2011 um 21:34)

  • Richtig müsste es folgendermasen sein:

    [autoit]

    $location = 10

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

    For $i = 1 To 2 ; Um alle Links zu bekommen
    For $i2 = 0 To 5
    MsgBox(0, "", $i2)
    Next
    Next

    [/autoit]


    Das Problem bei dir ist, das du die Variable zum Überprüfen/Anzeige des Durchlaufst überschreibst und wenn er das erste for überprüft ist es schon über 2.

  • okay das stimmt aber ich hab mein problem nicht richtige beschrieben

    ich möchte 2 Schleifen habe
    die
    erste ist
    For $i = 1 To 2 ; Um alle Links zu bekommen
    Next
    und dadrin soll eine zweite schleife sein mit
    For $ii = 0 To 5
    die solange läuft bis $location="0"
    ist

  • Wofür brauchst du $location?

    Das Script wäre so:

    [autoit]

    $location = 10

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

    While 1
    For $i2 = 0 To 5
    MsgBox(0, "", $i2)
    $location -= 1
    If $location = 0 Then ExitLoop
    Next
    If $location = 0 Then ExitLoop
    WEnd

    [/autoit]
  • Spoiler anzeigen
    [autoit][/autoit] [autoit][/autoit] [autoit]

    $location = 10
    For $i = 1 To 2
    While 1
    For $i2 = 1 To 5
    MsgBox(0, "", $i2)
    $location -= 1
    If $location = 0 Then ExitLoop
    Next
    msgbox(0,"","wend ende")
    WEnd
    msgbox(0,"","$location")
    NExt

    [/autoit]


    nur nach dem 2 durchlauf der beiden mittleren schleifen müsste doch
    msgbox(0,"","$location") kommen aber wiso kommt es nicht ?

    p.s. ein anderes programm läd in einen bestimmten zeitabschnitt text dokumente runter und ich möchte diese nach einen End befehl absuchen

  • nein denn dann kommt msgbox(0,"","$location") nach jeden umlauf es soll aber erst kommen wenn $location = "0" ist nicht vohher

  • ich habs gefunden danke für eure hilfe

    Spoiler anzeigen
    [autoit]


    $location = 10
    For $i = 1 To 2
    Do
    For $i2 = 1 To 5
    MsgBox(0, "", $i2)
    $location -= 1
    Next

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

    Until $location= "0"

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

    msgbox(0,"","$location")
    $location = 10
    NExt

    [/autoit]
  • Wenn du deinen ursprünglichen Script her nimmst, liegt es daran das du in beiden Schleifen den Zähler $i verwendest.
    Nimm einfach einen Anderen her, dann kommt die Ausgabe der MessageBox 2 mal bis 5 und der Wert $location wird auf 0 reduziert.

    [autoit]

    $a = 5
    $location = 10
    For $z = 1 To 2
    For $i = 1 To $a
    MsgBox(0,"",$i)
    $location -= 1
    If $location = 0 Then ExitLoop 2
    Next
    Next

    [/autoit]


    Ich weis es sind vor mir schon viele Lösungen geschrieben worden, aber ich wollte dir nur zeigen das dein Gedanke ja komplett richtig war. :thumbup:

    aber ein Zeichen kann oft viel ausmachen. ^^