Mini-Bug (Error 5) on script error

Things you’d like to miss in the future...
Forum rules
:warnred20: :warnred20: :warnred20: :warnred20: :warnred20: READ THIS AND DO IT!!! :warnred20: :warnred20: :warnred20: :warnred20: :warnred20:

:info: Please include the following information:
1) Your XYplorer Version (e.g., v28.00.0801)
2) Your Windows Version (e.g., Win 11)
3) Your Screen Scaling Percentage (e.g., 125%).

:info: We strongly recommend adding your Windows Version and Screen Scaling Percentage to the Location field in your Profile or to your Signature. That way, you only have to type them once, and we won't have to search for that vital information.

:info: When attaching an Image, please use the Attachment tab at the bottom of your post and click "Add files".

:warnred20: :warnred20: :warnred20: :warnred20: :warnred20: READ THIS AND DO IT!!! :warnred20: :warnred20: :warnred20: :warnred20: :warnred20:
Post Reply
PeterH
Posts: 2830
Joined: 21 Nov 2005 20:39
Location: DE W11Pro 24H2, 1920*1200*100% 3840*2160*150%

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.)

admin
Site Admin
Posts: 66582
Joined: 22 May 2004 16:48
Location: Win8.1, Win10, Win11, all @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: 2830
Joined: 21 Nov 2005 20:39
Location: DE W11Pro 24H2, 1920*1200*100% 3840*2160*150%

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:

Post Reply