Windows Vista Forums
Vista Forums Home Join Vista Forums Donate Vista Tutorials Tags

Welcome to Vista Forums we are your forum to discuss Windows Vista x64 and x86 systems. Whether you need help or just want to post an idea you have on Vista, this is the forum for you.
Register at Vista forums...the world biggest Windows Vista resource Join Vista Forums Now

Go Back   Vista Forums > Microsoft Technical Newsgroups > PowerShell

Using labels in Powershell

Closed Thread
 
Thread Tools Display Modes
Old 02-06-2007   #1 (permalink)
Bruno Guerpillon
Guest


 

Using labels in Powershell

Hi

Didnt find this anywhere.
What's the equivalent to :

goto :labelx
command
command

:labelx


Regards


Old 02-06-2007   #2 (permalink)
Keith Hill
Guest


 

Re: Using labels in Powershell

"Bruno Guerpillon" <toto@toto.fr> wrote in message news:45c8b8c2$0$16176$426a74cc@news.free.fr...
> Hi
>
> Didnt find this anywhere.
> What's the equivalent to :
>
> goto :labelx
> command
> command
>
> :labelx


I believe labels are only used in conjunction with the loop terminators: break and continue. For example:

uter while (1) {
while (1) {
break outer
}
# break without label would break to this line
}

Note that the label in "break <label>" doesn't have to be a literal/constant string. It can be an expression (found this little tidbit in Bruce Payette's book Windows PowerShell in Action) e.g.

$target = "outer"
uter while (1) {
while (1) {
break $target
}
}

Your code above looks kind of like batch script. I would probably modify it to use some form of control flow e.g.:

if (<some expression>) {
# skips this block of commands if <some expression> doesn't evaluate to $true
command
command
}

--
Keith
Old 02-06-2007   #3 (permalink)
Brandon Shell
Guest


 

Re: Using labels in Powershell

Along with what Keith Said... before Powershell I wrote a good bit of Batch
scripts... in Powershell I have yet to find any reason for the Label.
Controlling script execution in Powershell is WAY easier than batch (once
you get use it to it.) I would recommend biting the bullet and forcing your
self to rethink script design.

--
Brandon Shell
---------------
Stop by my blog some time
http://www.bsonposh.com/
Try the "Search of Powershell Blogs"
--------------------------------------

"Bruno Guerpillon" <toto@toto.fr> wrote in message
news:45c8b8c2$0$16176$426a74cc@news.free.fr...
> Hi
>
> Didnt find this anywhere.
> What's the equivalent to :
>
> goto :labelx
> command
> command
>
> :labelx
>
>
> Regards
>
>


Old 02-06-2007   #4 (permalink)
/\\/\\o\\/\\/ [MVP]
Guest


 

Re: Using labels in Powershell

for exeption handling the labels are handy (and breaking nested loops )


Greetings /\/\o\/\/

"Brandon Shell" <tshell.mask@gmail.com> wrote in message
news:ugSIlqhSHHA.5060@TK2MSFTNGP06.phx.gbl...
> Along with what Keith Said... before Powershell I wrote a good bit of
> Batch scripts... in Powershell I have yet to find any reason for the
> Label. Controlling script execution in Powershell is WAY easier than batch
> (once you get use it to it.) I would recommend biting the bullet and
> forcing your self to rethink script design.
>
> --
> Brandon Shell
> ---------------
> Stop by my blog some time
> http://www.bsonposh.com/
> Try the "Search of Powershell Blogs"
> --------------------------------------
>
> "Bruno Guerpillon" <toto@toto.fr> wrote in message
> news:45c8b8c2$0$16176$426a74cc@news.free.fr...
>> Hi
>>
>> Didnt find this anywhere.
>> What's the equivalent to :
>>
>> goto :labelx
>> command
>> command
>>
>> :labelx
>>
>>
>> Regards
>>
>>

>


Old 02-06-2007   #5 (permalink)
Brandon Shell
Guest


 

Re: Using labels in Powershell

as apposed to try?

btw... where is that /\/\o\/\/ guide

--
Brandon Shell
---------------
Stop by my blog some time
http://www.bsonposh.com/
Try the "Search of Powershell Blogs"
--------------------------------------

"/\/\o\/\/ [MVP]" <mow001@hotmail.NoSpam> wrote in message
news:B48812D8-F3E2-44A4-BA4C-69BCD691C3C7@microsoft.com...
> for exeption handling the labels are handy (and breaking nested loops )
>
>
> Greetings /\/\o\/\/
>
> "Brandon Shell" <tshell.mask@gmail.com> wrote in message
> news:ugSIlqhSHHA.5060@TK2MSFTNGP06.phx.gbl...
>> Along with what Keith Said... before Powershell I wrote a good bit of
>> Batch scripts... in Powershell I have yet to find any reason for the
>> Label. Controlling script execution in Powershell is WAY easier than
>> batch (once you get use it to it.) I would recommend biting the bullet
>> and forcing your self to rethink script design.
>>
>> --
>> Brandon Shell
>> ---------------
>> Stop by my blog some time
>> http://www.bsonposh.com/
>> Try the "Search of Powershell Blogs"
>> --------------------------------------
>>
>> "Bruno Guerpillon" <toto@toto.fr> wrote in message
>> news:45c8b8c2$0$16176$426a74cc@news.free.fr...
>>> Hi
>>>
>>> Didnt find this anywhere.
>>> What's the equivalent to :
>>>
>>> goto :labelx
>>> command
>>> command
>>>
>>> :labelx
>>>
>>>
>>> Regards
>>>
>>>

>>

>


Closed Thread

Thread Tools
Display Modes


Similar Threads
Thread Thread Starter Forum Replies Last Post
printing labels Lane Vista print fax & scan 6 05-13-2008 08:40 AM
Labels, Classification José Vista General 0 02-05-2008 12:22 PM
Labels, classificatie José Vista General 0 02-05-2008 09:18 AM
printing labels amanda Vista print fax & scan 1 01-09-2008 10:10 PM
Address Labels Stuart Brown Vista mail 0 11-01-2007 05:21 AM








Vistax64.com is an independent web site and has not been authorized,
sponsored, or otherwise approved by Microsoft Corporation.
"Windows Vista", the Start Orb, and related materials are trademarks of Microsoft Corp.
© Designer Media 2005-2008

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50