PoshCode Archive  Artifact [88cdbd93da]

Artifact 88cdbd93da956e8579332c7cd3d99b4697f0e0ce1ccb649357d14083f5be4a9f:

  • File Get-Scope.ps1 — part of check-in [213c07c6df] at 2018-06-10 13:13:39 on branch trunk — Get PowerShell numbered scope in anytime!!! (user: ingted size: 750)

# encoding: ascii
# api: powershell
# title: Get-Scope
# description: Get PowerShell numbered scope in anytime!!!
# version: 0.1
# type: function
# author: ingted
# license: CC0
# function: Get-Scope
# x-poshcode-id: 2642
# x-archived: 2011-05-03T14:16:45
# x-published: 2011-05-01T00:57:00
#
#
function Get-Scope{
    $rtnScope = 0
    $global:scope = $false
    $scope = $true
    while($($ErrorActionPreference = "silentlycontinue"; switch((get-Variable -Name scope -Scope $rtnScope).value){$null{$true} $true{$true} $false{$ErrorActionPreference = "continue"; return ($rtnScope - 1)}})){
        $rtnScope++
    }
}

<#Example.

function gg{
    Get-Scope
}; 

function iii{
    gg
}; 

iii    ==> result is 2#>