I'm trying to count the number of replacements made by a simple script like so:
$count = 0
Function findAndReplace($objFind, $FindText, $ReplaceWith) {
$count += $objFind.Execute($FindText, $matchCase, $matchWholeWord, \`
$matchWildCards, $matchSoundsLike, $matchAllWordForms, \`
$forward, $findWrap, $format, $ReplaceWith, $replace)
}
The replacements are done alright, but $count remains at 0...
This is a scoping issue. AFAIK
$countdoes not have to be initialized first.The increment logic looks find. However, you will need to return it from the function after the increments. Otherwise it will still be
0as defined within the scope outside of the function.