Mot-cl�s AutoIt


For...In...Next

R�p�te un bloc d'instructions en �num�rant les �l�ments d'une collection d'objets ou d'un tableau.

For <$Variable> In <expression>
    Instructions
    ...
Next

Param�tres

Variable Une variable � laquelle un �l�ment de l'�num�ration est assign�
expression Doit �tre une expression aboutissant � un objet, ou un tableau avec au moins un �l�ment

Remarques

La Variable sera cr��e automatiquement avec une port�e Local, m�me lorsque MustDeclareVars est utilis�.
Si l'expression est une collection d'Objet sans �l�ments, ou un tableau multidimensionnel, la boucle sera saut�e et la Variable contiendra une cha�ne vide.
Si l'expression n'est pas un Objet ou un Tableau, le script s'arr�tera avec une erreur, � moins qu'un Syst�me de gestion d'exceptions COM n'ait �t� configur�.
Les tableaux AutoIt sont en lecture seule lors de l'utilisation de For...In. Tandis que vous pouvez assigner une valeur � la variable dans la boucle For...In, ce changement n'est pas refl�t� dans le tableau lui-m�me. Pour modifier le contenu d'un tableau pendant l'�num�ration, utilisez une boucle For...To.

Les instructions For...In...Next peuvent �tre imbriqu�es.

En relation

With...EndWith

Exemple

#include <MsgBoxConstants.au3>

Example()

Func Example()
    ; Utilisation d'un tableau
    Local $aArray[4]

    $aArray[0] = "a"
    $aArray[1] = 0
    $aArray[2] = 1.3434
    $aArray[3] = "test"

    Local $sString = ""
    For $vElement In $aArray
        $sString = $sString & $vElement & @CRLF
    Next

    MsgBox($MB_SYSTEMMODAL, "", "For..IN Arraytest:" & @CRLF & "Result is: " & @CRLF & $sString)

    ; Utilisation d'une collection d'objets

    Local $oShell = ObjCreate("shell.application")
    Local $oShellWindows = $oShell.windows

    If IsObj($oShellWindows) Then
        $sString = ""

        For $Window In $oShellWindows
            $sString = $sString & $Window.LocationName & @CRLF
        Next

        MsgBox($MB_SYSTEMMODAL, "", "You have the following windows open:" & @CRLF & $sString)
    Else

        MsgBox($MB_SYSTEMMODAL, "", "You have no open shell windows.")
    EndIf
EndFunc   ;==>Example