Windows Vista Forums
Vista Forums Home Join Vista Forums Windows 7 Forum Vista Tutorials Tags
Welcome to Windows Vista Forums. Our forum is dedicated to helping you find solutions with any problems, errors or issues you are experiencing with Windows Vista. The Vista forum also covers news and updates and has an extensive Windows Vista tutorial section that covers a wide range of tips and tricks.


Go Back   Vista Forums > Misc Newsgroups > PowerShell

RB

Vista - line continuation char

Reply
 
03-09-2009   #1
Dan Holmes


 

line continuation char

My script has lines that are very long. In C# ";" acts as a statement terminator so statements can span lines. It
seems in PowerShell that the ";" is optional. how do i break a line so that it is still legal syntax?

$msg += Get-RM_DbsLastUse $server | Select dbName, LastTripDate | sort LastTripDate | Format-Table -AutoSize -Wrap |
Out-String -Width 120;

I want to add a "Where" to that as well.

dan

My System SpecsSystem Spec
03-09-2009   #2
Josh Einstein


 

Re: line continuation char

PowerShell will allow the statement to span lines if it detects an
incomplete statement (for example, an unclosed set of parenthases, a
trailing operator, etc.) or you can force it with a backtick at the end of
the line.

If you're building a big pipeline you can do:

Command1 |
Command2 |
Command3 `
| Command4

etc...

Josh

"Dan Holmes" <dan.holmes@xxxxxx> wrote in message
news:uSnx4ZNoJHA.1184@xxxxxx
Quote:

> My script has lines that are very long. In C# ";" acts as a statement
> terminator so statements can span lines. It seems in PowerShell that the
> ";" is optional. how do i break a line so that it is still legal syntax?
>
> $msg += Get-RM_DbsLastUse $server | Select dbName, LastTripDate | sort
> LastTripDate | Format-Table -AutoSize -Wrap | Out-String -Width 120;
>
> I want to add a "Where" to that as well.
>
> dan
My System SpecsSystem Spec
03-09-2009   #3
Charlie Russel - MVP


 

Re: line continuation char

The escape character is the backquote (sometimes called back tick). It is
used for all escape sequences, including the end of the line.

--
Charlie.
http://msmvps.com/blogs/xperts64
http://mvp.support.microsoft.com/profile/charlie.russel


"Dan Holmes" <dan.holmes@xxxxxx> wrote in message
news:uSnx4ZNoJHA.1184@xxxxxx
Quote:

> My script has lines that are very long. In C# ";" acts as a statement
> terminator so statements can span lines. It seems in PowerShell that the
> ";" is optional. how do i break a line so that it is still legal syntax?
>
> $msg += Get-RM_DbsLastUse $server | Select dbName, LastTripDate | sort
> LastTripDate | Format-Table -AutoSize -Wrap | Out-String -Width 120;
>
> I want to add a "Where" to that as well.
>
> dan

My System SpecsSystem Spec
Reply

RB


Thread Tools


Similar Threads for: line continuation char
Thread Forum
double char? General Discussion
Re: Extracting the last char from the string VB Script
continuing the continuation Vista mail
Message - Too many continuation lines .NET General
Continuation of video Vista music pictures video


Vista Forums 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 Ltd