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