![]() |
![]() | ![]() | ![]() | ![]() | ![]() | ![]() | ![]() |
| 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) |
| | Re: passing variable by reference [something] is just text when you're using it as an argument. So you get the following: PS>function foo($bar) { $bar } PS>$x = 34 PS>foo [ref]$x [ref]34 There's a bit about this in the help for about_parsing. Its the stuff about expression mode vs argument mode. It *would* be nice if we got better help for stuff like this though. I've been thinking of writing a script to run in the prompt function that would check if you just had an error in the previous line, do some regex mathing and suggest stuff. I was mainly thinking of doing it because I keep trying to use the old cmdlet names. ![]() The script could detect stuff like this as well. Anyway, its just an idea, I thought I'd put out there. - Marcel "/\/\o\/\/" <no@spam.mow> wrote in message news:OLB03DOhGHA.3924@TK2MSFTNGP03.phx.gbl... > while answering a powershell question in m.p.w.s.s, > > I stubled to this : > > MowPS>$foo > bar > MowPS>function barFoo ([ref]$foo){$foo.value = 'foo'} > > I need to use parentheses to pass a ref variable to get it parsed, > and this is not really clear from the error : > > MowPS>barfoo [ref]$foo > barFoo : Reference type is expected in argument. > At line:1 char:7 > + barfoo <<<< [ref]$foo > > MowPS>barfoo ([ref]$foo) > MowPS>$foo > foo > > gr /\/\o\/\/ |
My System Specs![]() |
| | #2 (permalink) |
| | passing variable by reference while answering a powershell question in m.p.w.s.s, I stubled to this : MowPS>$foo bar MowPS>function barFoo ([ref]$foo){$foo.value = 'foo'} I need to use parentheses to pass a ref variable to get it parsed, and this is not really clear from the error : MowPS>barfoo [ref]$foo barFoo : Reference type is expected in argument. At line:1 char:7 + barfoo <<<< [ref]$foo MowPS>barfoo ([ref]$foo) MowPS>$foo foo gr /\/\o\/\/ |
My System Specs![]() |
![]() |
| Thread Tools | |
| |
Similar Threads | ||||
| Thread | Forum | |||
| Variable within Object Reference Line | VB Script | |||
| Passing dataset by reference between forms, what is the best approach? | .NET General | |||
| Passing parameters to a cmdlet in a variable | PowerShell | |||
| Passing ArrayList as reference to function | PowerShell | |||
| Passing hash table by reference | PowerShell | |||