View Single Post
Old 01-20-2008   #4 (permalink)
Anthony Houssa


 
 

Re: BREAK out of a LOOP

In their articles to prepare the 2008 Winter Scripting Games, "The Scripting
Guys" explain how to exit a loop in PowerShell (in Perl, and vbscript too).

The link:
http://www.microsoft.com/technet/scr...p0111.mspx#ERD
As mentioned in the article, PowerShell also enables to attach a label to a
loop

:OutsideLoop for ($y = 1; $y -le 5; $y++)
{
write-host "Loop number $y"
for ($i = 1; $i -le 3 ; $i++)
{
if ($y -eq 2) {break OutsideLoop}
$i
}
}

Regards

"RichS" <RichS@xxxxxx> wrote in message
news:5DB6AD7E-6E4A-4922-A08F-0E00058A6A45@xxxxxx
Quote:

> see
>
> get-help about_break
>
> get-help about_continue
>
> for details
> --
> Richard Siddaway
> Please note that all scripts are supplied "as is" and with no warranty
> Blog: http://richardsiddaway.spaces.live.com/
> PowerShell User Group: http://www.get-psuguk.org.uk
>
>
> "IT Staff" wrote:
>
Quote:

>> yes, BREAK is the command
>>
>> "Sue & Bill" <sue.and.bill@xxxxxx> wrote in message
>> news:999087fa-536c-48a2-879c-d3edab5fe6de@xxxxxx
Quote:

>> > Is there a way to BREAK out of a LOOP? How about CONTINUE/NEXT?
>> >
>> > Thanks.
>>
>>
>>
My System SpecsSystem Spec