![]() |
![]() | ![]() | ![]() | ![]() | ![]() | ![]() | ![]() |
| 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) |
| | function to delete a function How would a function be written that given a name of a function, would delete that function? I tried with no success function rif { ri function:$Args[0] } - Larry |
My System Specs![]() |
| | #2 (permalink) |
| | RE: function to delete a function This seems to work: function rif { param($f) ri function:$f } "Larry__Weiss" wrote: Quote: > How would a function be written that given a name of a function, would > delete that function? > > I tried with no success > > function rif { ri function:$Args[0] } > > - Larry > |
My System Specs![]() |
| | #3 (permalink) |
| | args[0] within a doublequoted string Consider these two versions of function testArgs0_1 function testArgs0_1 { '$Args[0]' + ' ' + $Args[0] + ' ' + '$Args[1]' + ' ' + $Args[1]} testArgs0_1 xxx yyy produces $Args[0] xxx $Args[1] yyy function testArgs0_1 { '$Args[0]' + ' ' + "$Args[0]" + ' ' + '$Args[1]' + ' ' + "$Args[1]"} testArgs0_1 xxx yyy produces $Args[0] xxx yyy[0] $Args[1] xxx yyy[1] Why does putting double quotes around $Args[0] and $Args[1] make that difference? - Larry |
My System Specs![]() |
| | #4 (permalink) |
| | Re: args[0] within a doublequoted string function testArgs0_1 { $Args0 = $Args[0]; $Args1 = $Args[1]; '$Args[0]' + ' ' + "$Args0" + ' ' + '$Args[1]' + ' ' + "$Args1"} testArgs0_1 xxx yyy produces $Args[0] xxx $Args[1] yyy and works as I expected it to as it avoids a dynamic string expansion involving $Args[0] The dynamic string expander seems to stop at the [ character instead of parsing the entire $Args[0] token for replacement. - Larry Larry__Weiss wrote: Quote: > Consider these two versions of function testArgs0_1 > > function testArgs0_1 { '$Args[0]' + ' ' + $Args[0] + ' ' + '$Args[1]' Quote: > testArgs0_1 xxx yyy > produces > $Args[0] xxx $Args[1] yyy > > function testArgs0_1 { '$Args[0]' + ' ' + "$Args[0]" + ' ' + Quote: > testArgs0_1 xxx yyy > produces > $Args[0] xxx yyy[0] $Args[1] xxx yyy[1] > > Why does putting double quotes around $Args[0] and $Args[1] make that Quote: > |
My System Specs![]() |
| | #5 (permalink) |
| | Re: args[0] within a doublequoted string (I'm so sorry about the HTML versions of my postings...here is a version of my last post now in plaintext) function testArgs0_1 { $Args0 = $Args[0]; $Args1 = $Args[1]; '$Args[0]' + ' ' + "$Args0" + ' ' + '$Args[1]' + ' ' + "$Args1"} testArgs0_1 xxx yyy produces $Args[0] xxx $Args[1] yyy and works as I expected it to as it avoids a dynamic string expansion involving $Args[0] The dynamic string expander seems to stop at the [ character instead of parsing the entire $Args[0] token for replacement. Consider these two versions of function testArgs0_1 function testArgs0_1 { '$Args[0]' + ' ' + $Args[0] + ' ' + '$Args[1]' + ' ' + $Args[1]} testArgs0_1 xxx yyy produces $Args[0] xxx $Args[1] yyy function testArgs0_1 { '$Args[0]' + ' ' + "$Args[0]" + ' ' + '$Args[1]' + ' ' + "$Args[1]"} testArgs0_1 xxx yyy produces $Args[0] xxx yyy[0] $Args[1] xxx yyy[1] Why does putting double quotes around $Args[0] and $Args[1] make that difference? - Larry |
My System Specs![]() |
| | #6 (permalink) |
| | Re: args[0] within a doublequoted string I figured it out. You have to wrap it with a $() block as in function testArgs0_1 { '$Args[0]' + ' ' + "$($Args[0])" + ' ' + '$Args[1]' + ' ' + "$($Args[1])"} testArgs0_1 xxx yyy produces $Args[0] xxx $Args[1] yyy - Larry Larry__Weiss wrote: Quote: > function testArgs0_1 { $Args0 = $Args[0]; $Args1 = $Args[1]; '$Args[0]' > + ' ' + "$Args0" + ' ' + '$Args[1]' + ' ' + "$Args1"} > testArgs0_1 xxx yyy > produces > $Args[0] xxx $Args[1] yyy > > and works as I expected it to as it avoids a dynamic string expansion > involving $Args[0] > > The dynamic string expander seems to stop at the [ character instead of > parsing > the entire $Args[0] token for replacement. > > - Larry > > > > Larry__Weiss wrote: Quote: > > Consider these two versions of function testArgs0_1 > > > > function testArgs0_1 { '$Args[0]' + ' ' + $Args[0] + ' ' + '$Args[1]' Quote: > > testArgs0_1 xxx yyy > > produces > > $Args[0] xxx $Args[1] yyy > > > > function testArgs0_1 { '$Args[0]' + ' ' + "$Args[0]" + ' ' + Quote: > > testArgs0_1 xxx yyy > > produces > > $Args[0] xxx yyy[0] $Args[1] xxx yyy[1] > > > > Why does putting double quotes around $Args[0] and $Args[1] make that Quote: > > |
My System Specs![]() |
![]() |
| Thread Tools | |
| |
Similar Threads | ||||
| Thread | Forum | |||
| About the function. | PowerShell | |||
| function not working dispite working outside the function block | PowerShell | |||
| Every left click or highlight prompts delete function in Vista | Vista General | |||
| Windows Vista Email IMAP Message Delete Function | Vista mail | |||
| BUG: Redirecting function contents to a file truncates function lines at the width of the console | PowerShell | |||