Code: Select all
"Main : test"
$s = "cmd(op)";
$w = "cmd";
$r = replace($s, $w, '', 1, 0); // $w -> '', a ^= A, start = 0
Result:
I think it should just display a scripting error, shouldn't it?Error: 5 (0x00000005)
Desc: Invalid procedure call or argument
Dll: 0
Proc: script_EvalFunction: replace
Source: XYplorer
XY ver: XYplorer 24.40.0005 - Lifetime License Enterprise
OS: Windows 7 Home Premium (Service Pack 1), 64-bit, Build 7601 (6.1)
Locale: 1031 (de-DE)
ANSI: 1252, ACP: 1252 (ANSI - Lateinisch I)
Font: Segoe UI 9, Segoe UI 9, DBCS: No
DPI: 96 (100%), 1680x1050
Date: 2023-05-28 11:57:42
The good thing: XY does not terminate (as I expected) - only the script does.
This way it seems like a bug in replace(), not in the script. Only found it by chance...
(Best would be Msg = Invalid argument value for 'start', I think
Though I don't expect this to happen. )
By the way: building the replace() I thought of substr() etc: the 'first' char is '0'. So I coded start=0 - and failed. Is this consistent?
(For me 20 years ago and now it's so that the first tree, as well as the first character, is 1, not 0. So replace() counts 'correct'.
I said this when substr() was created, and say this still.
And yes, I know what an offset is. But a scripter should not have to think about that.
And no - nothing can be changed about that now.)