Cancel
Showing results for 
Search instead for 
Did you mean: 
Highlighted

Delete value in an array defined as any[]

Pioneer
Pioneer

 

Hi,

 

This simple code doesn't seem to print what it should be printing:

 

var arr : any[]
arr.append("a")
arr.append("b")
arr.deleteValue("b")
print arr

 

 

I'm using Plant Simulation 14.0.1.

 

The problem also concerns the find method. The find method always returns the first value of the array when the array is an any[].

 

Have a good day.

5 REPLIES 5

Re: Delete value in an array defined as any[]

Genius
Genius

Hello,bpinarci

 

As for the code you posted,in my opinion the atrributes and methods "append" ,"deletevalue" is not suitable for all type of data "any". I look up its usage, and post it with marks in the following picture:

it can be used for type of data "CardFile" ,maybe others but not all.

捕获.JPG

 

What's more, I make a small model to show how to use it,you can refer .Hope it helps you!

if it does ,please give me a kudos!

 

Re: Delete value in an array defined as any[]

Pioneer
Pioneer

Thanks for the model and your time.

Actually I don't want to use a any but a any[] which is an array containing values of any type.

The methods find and deleteValue are usable with arrays and an any[] is an array, so I don't get why they act wrong in this case...

 

Hava a good day!

Re: Delete value in an array defined as any[]

Genius
Genius

Hi,bpinarci

 

If you set the "arr: any[]",there is no relationship with the content "d" of arr.deletevalue("d"),the result is that the first character will be delelted.It seems that the the default content of arr.deletevalue() is "1",what matter you enter.


If you change the "arr:any[]" to "arr:string[]", the result is ok. I'm sorry I have no idea about the real cause.

Re: Delete value in an array defined as any[]

Siemens Phenom Siemens Phenom
Siemens Phenom

This is definitely a bug. We will fix it in the next maintenance pack. Please note that we recently released maintenance packs, so this could take a while. If you have a maintenance contract and you need a hotfix soon, please contact your local support.

_________________________________________________________________
Did you like the answer? Then click the Thumbs Up button.
Did the answer solve your problem? Then accept the answer as solution.

Re: Delete value in an array defined as any[]

Pioneer
Pioneer

For me, it looks like the developers took a shortcut for these functions or didn't take into account the case where the array is a any[]

Let's see what they think about it Smiley Very Happy

 

EDIT : Didn't see Michael's answer. I mark this as solved since it's taken into account for the next maintenance pack. For the moment, i'll just use a workaround and wait for the next release (I just loop in the array and find my value and delete it).

 

Thanks Michael.