Skip to content

Commit

Permalink
Define and use $total variable
Browse files Browse the repository at this point in the history
  • Loading branch information
Cydroz authored and andyleejordan committed Jan 10, 2025
1 parent d75312a commit 2e8fdc9
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions snippets/PowerShell.json
Original file line number Diff line number Diff line change
Expand Up @@ -165,8 +165,9 @@
"prefix": "foreach-progress",
"description": "Insert a foreach loop with Write-Progress initialized",
"body": [
"\\$progPercent = \"{0:n2}\" -f ([math]::round(\\$i/\\$array.count,4) * 100)",
"Write-Progress -Activity \"${3:activityName}\" -Status \"\\$i of \\$array.count - \\$progPercent% Complete:\" -PercentComplete \\$progPercent",
"\\$total = \\$${1:array}.count",
"\\$progPercent = \"{0:n2}\" -f ([math]::round(\\$i/\\$total,4) * 100)",
"Write-Progress -Activity \"${3:activityName}\" -Status \"\\$i of \\$total - \\$progPercent% Complete:\" -PercentComplete \\$progPercent",
"\\$i = 1",
"foreach ($${2:item} in $${1:array}) {",
" \\$progPercent = \"{0:n2}\" -f ([math]::round(\\$i/\\$total,4) * 100)",
Expand Down Expand Up @@ -670,4 +671,4 @@
"}"
]
}
}
}

0 comments on commit 2e8fdc9

Please sign in to comment.