ArrayDeleteValue( – Is this supposed to delete multiple elements?

‘OriginalArray’ = ‘1.2.3.4.5.6’

‘LValue’ = '2.3.5’

Is this code supposed to delete 2, 3, & 5 such that my resulting array would be ‘1.4.6’

ArrayDeleteValue(‘OriginalArray’,LValue,”.”)

The way I am reading the documentation, this is not supposed to happen but in some old code, it is working that way. I like that it is but just wondering where I got the idea that it might happen as the docs don’t seem to say that it should work.

No that’s not what it does. It’s looking for the exact string “.2.3.5.” and it will replace it with “.”. Your example doesn’t contain that string so nothing gets replaced at all.

Robert, you will have to process the first array OriginalArray with the second array LValue. You can do that with a looparray statement:

let OriginalArray = "1.2.3.4.5.6"
let LValue = "2.3.5"
let n = 1

looparray LValue,".",i,n
    OriginalArray = arraydeletevalue(OriginalArray,array(LValue,n,"."),".")
    n = n + 1 
endloop

message OriginalArray

Not exactly, because that doesn’t take account of ‘2.3.5’ coming at the beginning or end of OriginalArray, only it occurring somewhere in the middle.

I hear you and Dave. I am just a bit bewildered at the moment because it is working for me as is. Something is odd and I’ve yet to figure out why it is working for me. In a bit of time, I’ll look further into what or why it is working as I need it to. Old code. Something is amiss. I appreciate the time you took on this. I was just first trying to figure out if the docs were less than complete.

Is this code supposed to delete 2, 3, & 5 such that my resulting array would be ‘1.4.6’

Nope. The arraydeletevalue( function can only delete one value at a time.

You can do that with a looparray statement:

Yep, that is the straightforward way to do it.

But … there is another way to do it, the arraydifference( function.

1 Like

Luv that.

I am getting the results I want, just not clear as to how yet.

My description was incomplete. Before it looks for that string, it places separator characters before and after. It removes those extra characters at the end.