SubStrReplace doesn't work if start+length>=len(string)

Made a small change or new addition to the POL Core that makes a difference? You can post the changes here in .patch or .diff file format, for our Dev team to screen and apply to the SVN!

Moderator: POL Developer

Locked
User avatar
andenixa
Grandmaster Poster
Posts: 105
Joined: Tue Nov 09, 2010 1:33 am

SubStrReplace doesn't work if start+length>=len(string)

Post by andenixa »

SubStrReplace(str, replace_with, start, length:=0);

doesn't work if start + length >= the length of the string
which should be perfectly legal for POL since its indexations are 1-based

such that:

var myString := "Hello, World!";
SubStrReplace(myString , "Hell!", 7, length:=6);

>> Would cause an error: "Length out of range"

This patch fixes that issue.
Attachments
mf_SubStrReplace.patch
(764 Bytes) Downloaded 359 times
Locked