View Single Post
Old 01-08-2008   #2 (permalink)
Tao Ma


 
 

Re: Has anyone sucessfully read the value of the $OFS variable?

You can use Test-Path to check if the ofs exist, if so, the PowerShell use
it as delimiter to concatenate the array element.
If it doesn't exist, PowerShell use blank space instead.

You can use Remove-Item variablefs to investigate above hehavior.

Best wishes.

Tao Ma

"Bob Landau" <BobLandau@xxxxxx> дÈëÓʼþ
news:B9F9BCDC-BA13-4A67-A374-9EFBF06103B4@xxxxxx
Quote:

> All the code I search in books and online will do something like this
>
> $OFS = <some character>
>
> but none of them first save the orignal value
>
> The problem I'm having is the default OFS variable seems to be
instanciated
Quote:

> on the fly
>
> dir variable:OFS
>
> will return an error stating it doesn't exist nor does the following see
it
Quote:

>
> Get-Variable -Scope global -Name o*
>
> so if you by habit use Set-PSDebug -Strict in your scripts it will error
out.
Quote:

>
> According to About_Automatic_Variables all of these are set by Powershell
> while I can see some of the "read-only" type variables being created on
the
Quote:

> fly; I don't see why the OFS variable should be.
>
> I would like to keep the user default value for OFS if I need to override
> it. so that it can be restored i.e.
>
> $oldOFS = $OFS
> set-variable -name oldOFS -value $OFS
>
> I feel like I'm missing something here but I don't see what or how to
achive
Quote:

> this short of catching the error.
>
> thx
> bob

My System SpecsSystem Spec