syntax53
(Fresh Scripter)
2017-02-28 03:48 PM
New Replace Function in 4.67

Why was this not plastered all over the release notes? After updating to 4.67 I was getting a fatal "ERROR : expected FUNCTION name!" in my UDF library. With no line number I had to go through deleting a few functions at a time to finally find the one that was causing the problem. Low and behold it was...

 Code:
FUNCTION Replace($String,$SS,$RS)
    $Replace=Join(Split($String,$SS),$RS)
ENDFUNCTION


After triple checking the code and seeing no issues, I looked all over at the release notes (website, forum, .txt file in the zip) for some hint at what changed. I saw no mention of a new replace function or anything like that. Finally I found it in the "kix2010.doc" in the "What's New" section, "New function to replace characters/strings in strings"


AllenAdministrator
(KiX Supporter)
2017-02-28 04:12 PM
Re: New Replace Function in 4.67

Replace is not new. Not sure when it was added, but it's been in there for quite a while. I'm thinking since at least 4.60.

Mart
(KiX Supporter)
2017-02-28 04:25 PM
Re: New Replace Function in 4.67

Always a PITA to find something like that especially if it turns out to be something like a "simple" function name. It are always the simple things that are overlooked.

4.61 is the first version with the build-in replace function. New functions with any kind of name can possibly be added in the future. There is no real way to predict what will happen because nobody knows in advance all function names people use in UDFs.

http://www.kixtart.org/forums/ubbthreads...true#Post191701


syntax53
(Fresh Scripter)
2017-02-28 05:40 PM
Re: New Replace Function in 4.67

Weird that it wasn't until 4.67 that it started throwing the error. I was on v4.66 prior.

Mart
(KiX Supporter)
2017-03-01 03:39 PM
Re: New Replace Function in 4.67

Hmmmm.....strange.
Just did a small test and the code below works fine in 4.66 but throws and error in 4.67. Changing the function name slightly works just fine. Something must have changed compared to 4.66. I'll post something in the BETA section and link here.

 Code:
Break on

$string = "12324252627282920"
$ss = "2"
$rs = "#"

Replace($String, $SS, $RS)

Sleep 10

Function Replace($String, $SS, $RS)
	$Replace = Join(Split($String, $SS), $RS)
EndFunction


Ruud van Velsen
(Hey THIS is FUN)
2017-07-27 01:36 PM
Re: New Replace Function in 4.67

Ah... this is a name conflict (UDF with the same name as a built-in function).
And this was slightly tweaked in 4.67.

I'll see if I can enhance it to throw a more helpful error.

Ruud