unexpected return values using StrReplace as a BoundFunc object
Posted: 06 Feb 2018, 20:52
I fail to understand why all these MsgBoxes don't show the same value respectively. Can someone shed a light on this? It seems to occur only if Needle does not appear in Haystack.
Thank you.
Code: Select all
#NoEnv
#Warn
#SingleInstance force
; Windows 8.1 64 bit
; Autohotkey v1.1.27.04/v1.1.27.07 32-bit Unicode
; encodage: utf-8 (with BOM)
MsgBox % RegExReplace("Haystack", "z", "ReplaceText") ; Haystack
MsgBox % Func("RegExReplace").bind("Haystack", "z", "ReplaceText").call() ; sometimes 斘/᷸/tack, sometimes 斘5᷸5tack etc.
MsgBox % (Func("RegExReplace").bind("Haystack", "z", "ReplaceText")).call() ; sometimes 斘/᷸/tack, sometimes 斘5᷸5tack etc.
MsgBox % (f:=Func("RegExReplace").bind("Haystack", "z", "ReplaceText")).call() ; Haystack
MsgBox % StrReplace("Haystack", "z", "ReplaceText") ; Haystack
MsgBox % Func("StrReplace").bind("Haystack", "z", "ReplaceText").call() ; sometimes 醘ȨÀȦtack, sometimes 醘ȣÀtack etc.
MsgBox % (Func("StrReplace").bind("Haystack", "z", "ReplaceText")).call() ; sometimes 醘ȨÀȦtack, sometimes 醘ȣÀtack etc.
MsgBox % (f:=Func("StrReplace").bind("Haystack", "z", "ReplaceText")).call() ; Haystack