Skip to content

Commit 2e8fdc9

Browse files
Cydrozandyleejordan
authored andcommitted
Define and use $total variable
1 parent d75312a commit 2e8fdc9

File tree

1 file changed

+4
-3
lines changed

1 file changed

+4
-3
lines changed

snippets/PowerShell.json

+4-3
Original file line numberDiff line numberDiff line change
@@ -165,8 +165,9 @@
165165
"prefix": "foreach-progress",
166166
"description": "Insert a foreach loop with Write-Progress initialized",
167167
"body": [
168-
"\\$progPercent = \"{0:n2}\" -f ([math]::round(\\$i/\\$array.count,4) * 100)",
169-
"Write-Progress -Activity \"${3:activityName}\" -Status \"\\$i of \\$array.count - \\$progPercent% Complete:\" -PercentComplete \\$progPercent",
168+
"\\$total = \\$${1:array}.count",
169+
"\\$progPercent = \"{0:n2}\" -f ([math]::round(\\$i/\\$total,4) * 100)",
170+
"Write-Progress -Activity \"${3:activityName}\" -Status \"\\$i of \\$total - \\$progPercent% Complete:\" -PercentComplete \\$progPercent",
170171
"\\$i = 1",
171172
"foreach ($${2:item} in $${1:array}) {",
172173
" \\$progPercent = \"{0:n2}\" -f ([math]::round(\\$i/\\$total,4) * 100)",
@@ -670,4 +671,4 @@
670671
"}"
671672
]
672673
}
673-
}
674+
}

0 commit comments

Comments
 (0)