![]() |
![]() | ![]() | ![]() | ![]() | ![]() | ![]() | ![]() |
| 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. |
| |||||||
![]() |
| |
| | #1 (permalink) |
| Guest | insert object in pipe In a filter, is is possible to insert a new object in the pipeline? filter myfilter { # On first call, insert an object in pipe here. # else, process each object normally. } -- William Stacey [C# MVP] |
My System Specs![]() |
| | #2 (permalink) |
| Guest | Re: insert object in pipe Hi William > In a filter, is is possible to insert a new object in the pipeline? Yes, that's possible. Depending of what's your goal you could place yor new object in the begin section. filter myfilter { begin { $firstcall=$true } process { if($firstcall) { $firstcall=$false # On first call, insert an object in pipe here. get-date # uncomment next line to insert the current # pipline object, too # $_ } else { # else, process each object normally. $_ } } end { # The end } } hth Max |
My System Specs![]() |
| | #3 (permalink) |
| Guest | Re: insert object in pipe o man, that is cool. Thank you. -- William Stacey [C# MVP] "Maximilian Hänel" <ngSpam@smjh.de> wrote in message news:Or5Kg71FHHA.536@TK2MSFTNGP02.phx.gbl... | Hi William | | > In a filter, is is possible to insert a new object in the pipeline? | | Yes, that's possible. Depending of what's your goal you could place yor | new object in the begin section. | | filter myfilter | { | begin | { | $firstcall=$true | } | process | { | if($firstcall) | { | $firstcall=$false | # On first call, insert an object in pipe here. | get-date | # uncomment next line to insert the current | # pipline object, too | # $_ | } | else | { | # else, process each object normally. | $_ | } | } | end | { | # The end | } | } | | hth | | Max |
My System Specs![]() |
| | #4 (permalink) |
| Guest | Re: insert object in pipe And you don't even need the flag. Just send in the begin block. I remember talking/wanting this cmdlet-like feature in scripts a year ago. They did not think it would get in v1. Glad it did along with parms. Nice. filter myfilter { begin { "Begin" # insert string. } process { $_ # pass along pipe object. } end { "End" # pass string. } } PS C:\> "a","b" | myfilter Begin a b End -- William Stacey [C# MVP] "William Stacey [C# MVP]" <william.stacey@gmail.com> wrote in message news:O$aE%23o2FHHA.320@TK2MSFTNGP06.phx.gbl... |o man, that is cool. Thank you. | | -- | William Stacey [C# MVP] | | "Maximilian Hänel" <ngSpam@smjh.de> wrote in message | news:Or5Kg71FHHA.536@TK2MSFTNGP02.phx.gbl... || Hi William || || > In a filter, is is possible to insert a new object in the pipeline? || || Yes, that's possible. Depending of what's your goal you could place yor || new object in the begin section. || || filter myfilter || { || begin || { || $firstcall=$true || } || process || { || if($firstcall) || { || $firstcall=$false || # On first call, insert an object in pipe here. || get-date || # uncomment next line to insert the current || # pipline object, too || # $_ || } || else || { || # else, process each object normally. || $_ || } || } || end || { || # The end || } || } || || hth || || Max | | |
My System Specs![]() |
![]() |
| Thread Tools | |
| |
Similar Threads | ||||
| Thread | Forum | |||
| Pipe compare-object results into something useable | PowerShell | |||
| Pipe a pipe command to a file | VB Script | |||
| CD Insert/Jewel Case Insert Maker ignored? | Vista music pictures video | |||
| Testing object arrays using Compare-Object and -contains | PowerShell | |||
| Adding canonical aliases for Compare-Object, Measure-Object, New-Object | PowerShell | |||