![]() |
![]() | ![]() | ![]() | ![]() | ![]() | ![]() | ![]() |
|
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.
br> br> |
| |||||||
![]() |
| | Thread Tools | Display Modes |
| | #1 (permalink) |
| Guest | Named parameters with Scope Heya, I love named parameters (I even used them in batches), so I really want all my scripts to support them. However I run into problem when I try to define also scope: Param ( [string]$Global:JobStorage = $(throw "You must specify folder where you jobs are stored as parameter."), #Get folder where jobs are stored [string]$Global ebugLog = $("$pwd\S4M_EngineDebug.log") #Location of debuglog (log file from current session. Optional parameter ) If scope ($Global is specified, -JobStorage "C:\Temp" won't work...Not sure whether it is bug or feature - I can imagine it was implemented to prevent situation like Param ( [string]$Global:JobStorage = $(throw "You must specify folder where you jobs are stored as parameter."), #Get folder where jobs are stored [string]$Private:JobStorage = $(throw "You must specify folder where you jobs are stored as parameter."), #Get folder where jobs are stored ) Martin |
My System Specs![]() |
| | #2 (permalink) |
| Scripting Guru ![]() Rep Power: 8 ![]() ![]() ![]() | Re: Named parameters with Scope Why are you scoping your variables? This is a dangerous practice unless you know exactly what you are changing and why. The best practice is that functions should never modify the global scope. |
My System Specs![]() |
![]() |
| Thread Tools | |
| Display Modes | |
| |
Similar Threads | ||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Is this a bug in the scope? | Joel (Jaykul) Bennett | PowerShell | 1 | 08-18-2008 11:33 AM |
| Variable scope | Altraf | PowerShell | 6 | 12-13-2007 10:41 AM |
| trap scope | Bob Butler | PowerShell | 9 | 10-27-2007 08:41 PM |
| Powershell and scope | wkempf | PowerShell | 12 | 04-02-2007 04:13 PM |
| using named parameters in a SetScriptBlock (typedata) | /\\/\\o\\/\\/ | PowerShell | 1 | 07-17-2006 08:14 PM |