Nedir?
Belirlene koşula göre bir döngü içerisinde komutları çalıştırır. Condition bölümünde verilen koşul(lar)a göre Perform bölümündeki script işlemlerini çalıştırır.
Not: While döngüsünde koşulların sonsuz döngüye girmemesi için dikkat edilmelidir. Gerekirse Break komutu ile belirli bir döngü sayısında While döngüsünden çıkılabilir.
Sentaks
<While> <Condition> <Expression/> </Condition> <Perform> <Expression/> </Perform> </While>
Condition bölümünde döngü sayısı 5 ten küçük olduğu sürece while döngüsü çalışır, perform bölümünde Loopcount değişkeninin değeri 1 arttırılır.
Örnek 1
<SetVariable Name="$(LoopCount)"> <Value Target="Integer">0</Value> </SetVariable> <While> <Condition> <Less> <Value>$(LoopCount)</Value> <Value Target="Integer">5</Value> </Less> </Condition> <Perform> <SetVariable Name="$(LoopCount)"> <Math Operator="Add"> <Value>$(LoopCount)</Value> <Value Target="Integer">1</Value> </Math> </SetVariable> </Perform> </While> <Value>$(LoopCount)</Value>
Condition bölümünde döngü sayısı 10 ten küçük olduğu sürece while döngüsü çalışır, perform bölümünde Loopcount değişkeninin değeri 1 arttırılır. Ayrıca döngü sayısı 5 olduğunda While döngüsünden Break komutu ile çıkış yapılır.
Örnek 2
<SetVariable Name="$(LoopCount)"> <Value Target="Integer">0</Value> </SetVariable> <While> <Condition> <Less> <Value>$(LoopCount)</Value> <Value Target="Integer">10</Value> </Less> </Condition> <Perform> <SetVariable Name="$(LoopCount)"> <Math Operator="Add"> <Value>$(LoopCount)</Value> <Value Target="Integer">1</Value> </Math> </SetVariable> <If> <Then> <Condition> <Equals> <Value>$(LoopCount)</Value> <Value Target="Integer">5</Value> </Equals> </Condition> <Perform> <Break /> </Perform> </Then> </If> </Perform> </While> <Value>$(LoopCount)</Value>