Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8264767
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 8, 20262026-06-08T04:34:22+00:00 2026-06-08T04:34:22+00:00

Hello I am fairly new to Powershell and are trying to construct a series

  • 0

Hello I am fairly new to Powershell and are trying to construct a series of functions that are governed by a parent function at the top level.
This is the function that I am creating:

Function TraceIntegrityCheck{
    param($MasterTracefile, $FolderWhereATFare)

The $MasterTraceFile and $FolderWhereATFare will be file paths. I will pass these in. Below is my script for all of the inner functions that will use the $MasterTraceFile and $FolderWhereATFare paths.

#-------------------------------MasterTraceConfiguration--------------------------
#*********************************************************************************
Function TraceIntegrityCheck{
param($MasterTracefile, $FolderWhereATFare)
[string](cat $MasterTracefile) | Foreach-Object {$_ -replace "\(in\)", ""} | Set-      Content 'C:\tempFile.txt'
$src = [IO.File]::ReadAllText('C:\tempFile.txt')
$pattern ='(?<Key>(APDU\s*:\s*80\s*E[68]))\s*(?<Num>(\b[0-9A-F]{2}\s+)+)'
[Regex]::Matches($src, $pattern) | % { [Regex]::Replace($_.Groups     ['Key'].Value, 'APDU\s:\s*', '') + ' ' + [Regex]::Replace($_.Groups ['Num'].Value, '\s+', ' ') }|set-content 'C:\tempFile.txt' 
$file1 = 'C:\tempFile.txt'
$file2 = 'C:\tempFileMod.txt'
$startValue = '^80 E6'
$innerValue = '^80 E8'
$regex4 = "(?m)\A(?=$startValue)|\r\n(?=$startValue)"
$regex5 = "(?m)$innerValue"
$content = [IO.File]::ReadAllText($file1).TrimEnd()
$content -split $regex4 | Select-Object -Skip 1 |
  ForEach-Object -Begin {$i = 1} -Process {
    if ($_ -match $regex5) {
      $replacement = '{0:00}' -f $i++
      $file2 = $file2 -replace '\b(?=\.\w+$)', $replacement
      Set-Content -Path $file2 -Value $_ #-Verbose
    }
  }

#-------------------------------ATF Configuration---------------------------------
#*********************************************************************************

Function allOnOneLine{  
(([regex]::replace((get-content $FolderWhereATFare),"\s+"," "))).replace    ("9000","`r`n9000`r`n") > $FolderWhereATFare
}
#Call the Function
allOnOneLine

Function StripATF{
$original_file = '$FolderWhereATFare'
$destination_file =  'C:\modatfLinedup.txt'
(Get-Content $original_file) | Foreach-Object {
    $_ -replace '9000', '' 

    } | Set-Content $destination_file
}
#Call the StripATF
StripATF
#And the white space stripper
Function Wspace{
$file1 = 'C:\modatfLinedup.txt'
(gc $file1) | ? {$_.trim() -ne "" } | set-content $file1
}
#Call the Wspace
Wspace
Function spaceStrip{
$r=[regex]' ';
$original_file2 = 'C:\modatfLinedup.txt'
$destination_file2 ='C:\modatfLinedup.txt'
(Get-Content $original_file2) | Foreach-Object {
    $_ -replace '^ ', ''

     }| Set-Content $destination_file2
}
 #Call the Function
spaceStrip
Function folderDistribute{
  $file3 = 'C:\modatfLinedup.txt'
$file4 = 'C:\modATFLinedup.txt'
$startValue = '^80 E6'
$innerValue = '^80 E8'
$regex4 = "(?m)\A(?=$startValue)|\r\n(?=$startValue)"
$regex5 = "(?m)$innerValue"
$content = [IO.File]::ReadAllText($file3).TrimEnd()
$content -split $regex4 | Select-Object -Skip 1 |
  ForEach-Object -Begin {$i = 1} -Process {
    if ($_ -match $regex5) {
      $replacement = '{0:00}' -f $i++
  $file4 = $file4 -replace '\b(?=\.\w+$)', $replacement
  Set-Content -Path $file4 -Value $_ #-Verbose
    }
   }
#Call the Function
folderDistribute
}
}
C:\Users\nicalder\Desktop\Project1\atf\atf\modatfs\modatf.txt
TraceIntegrityCheck -file1 'C:\Users\user\Desktop\Project1\Master_Trace.txt' -    file2 'C:\Users\user\Desktop\Project1\modatf.txt'

My problem lies in trying to string along the original $MasterTraceFile and $FolderWhereATFare files so that I can pass them into the function and have the child functions all use them.

So what I really want to do is just be able to pass in these two parameter file paths so that the child functions can use them. I guess essentially create a constructor that will allow me to use the passing in parameters.

I know this may appear as confusing so please let me know what you think. I am just trying to connect the files through the children functions.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-08T04:34:24+00:00Added an answer on June 8, 2026 at 4:34 am

    It seems like you want to do something like:

    function outer($a) {
        function inner($b){
            write-host -fore red $a
            write-host -fore red $b
        }
    
        inner 2
    
    }
    
    outer 1
    

    The above does print:

    1
    2
    

    That is, the $a from outer function is available in inner function

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Hello I am fairly new to Scala. I want to learn Scala because: To
I'm fairly new to Ruby but I came across this weird gist where a
I'm still fairly new to Clojure so I apologize if this is a completely
I'm a fairly experienced programmer, but new to GUI programming. I'm trying to port
Hello I am fairly new to java and programming. I was wondering how to
Hello stackoverflow community! I am new to these forums and also fairly new to
I am fairly new to the PHP world and facebook integration. I am trying
I'm fairly new to using JQuery and was just playing around. I'm trying to
Hello I have like this 2 tables class User public int UserId{get;set;} { ....
Hello I've got this query to get users by email, which is an unique

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.