Mini-Bug (Error 5) on script error

Things you’d like to miss in the future...
Post Reply
PeterH
Posts: 2776
Joined: 21 Nov 2005 20:39
Location: Germany

Mini-Bug (Error 5) on script error

Post by PeterH »

This script:

Code: Select all

"Main : test"
   $s = "cmd(op)";
   $w = "cmd";
   $r = replace($s, $w, '', 1, 0); // $w -> '', a ^= A, start = 0
has a bug: start has to start with 1, 0 is not defined.

Result:
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
I think it should just display a scripting error, shouldn't it?

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 :titter:
Though I don't expect this to happen. :whistle: )


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.)
W7(x64) SP1 German
( +WXP SP3 )

admin
Site Admin
Posts: 60357
Joined: 22 May 2004 16:48
Location: Win8.1 @100%, Win10 @100%
Contact:

Re: Mini-Bug (Error 5) on script error

Post by admin »

Bug confirmed and fixed.

In strings the first character is at position 1. Yes, I probably inherited this from VB. Now I wish I did not, but too late. :)

PeterH
Posts: 2776
Joined: 21 Nov 2005 20:39
Location: Germany

Re: Mini-Bug (Error 5) on script error

Post by PeterH »

Maybe I should have protested louder then... :roll:

OK: I'll try to remember never to mention it again :beer:
W7(x64) SP1 German
( +WXP SP3 )

Post Reply