1. w32replaceItem misbehaving

Hi,

The documentation for w32replaceItem says

  • w32replaceItem (sequence pList, object pOld, object pNew)
  • Replaces all occurances of pOld with pNew
  • Note this routine will not do recursive replacements. That is, if pNew contains pOld, it doesn't go into a never-ending loop.

Whilst it's true that it doesn't go into a never-ending loop, it does do additional text replacements if pNew contains pOld. Which I believe it shouldn't do.

Here's an example

include win32lib.ew 
sequence email 
email = "mark_young@mydomain.com" 
email = w32replaceItem(email, "@", "@@") 
puts(1, email)) 

This produces the result

mark_young@@@@@@@@@@@@mydomain.com 

Am I correct that this is wrong? Am I missing a simple way to turn a single @ into two?

Cheers,
Mark

new topic     » topic index » view message » categorize

2. Re: w32replaceItem misbehaving

I should just add that I wrote a replacement w32replaceItem for myself...

function my_w32replaceItem(sequence pText, sequence pOLD, sequence pNEW) 
	sequence lParts, lText 
	 
	lParts = w32split(pText, pOLD) 
	lText  = "" 
	for x = 1 to length(lParts)-1 do 
		lText &= lParts[x] & pNEW 
	end for 
	lText &= lParts[length(lParts)] 
	 
	return lText 
end function 

Cheers
Mark

new topic     » goto parent     » topic index » view message » categorize

3. Re: w32replaceItem misbehaving

It is wrong, and the docs are right.

In the w32replaceItem() code, change the line

        lFrom += lLenNew 

by

        lFrom = lPos + lLenNew 

This has been there for a while. I'll update on SF, and perhaps make a corrective release before going to vacations.

hris

new topic     » goto parent     » topic index » view message » categorize

4. Re: w32replaceItem misbehaving

Thanks very much CChris

new topic     » goto parent     » topic index » view message » categorize

5. Re: w32replaceItem misbehaving

CChris said...

hris

BTW - Was this a subtle w32replaceItems related joke blink

new topic     » goto parent     » topic index » view message » categorize

Search



Quick Links

User menu

Not signed in.

Misc Menu