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
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 |
#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