Showing results for 
Search instead for 
Did you mean: 

[Bug][PS] assiging string[] to any[] method parameter



i made a generic method which should be able to contain integers or strings, however i don't no the type until runtime therefore i declared the method param as any[] and now it does not accept my string[]


Expected Result

string[]  is assigned to any[]


Actual Result

error: incompatible types of argument expected any[], passes string[]


Steps to reproduce error

  1. create methods in image below
  2. run exc and see error





Re: [Bug][PS] assiging string[] to any[] method parameter


Hello Frank,
your method does not work, because when you create an array, you did not say that it must have any-format. For example, with func (makeArray (1)) you get an error: "... pass integer [1]".

If you create an array without declaring the format, Plant Simulation self selects a format that uses the minimum resource. For "A" it is a string []. For 1 it is integer. For 1.1 it is real. and so on ...

For example makeArray(1,"A") create a any-format.

that helps:

var a : any[] := makeArray("A")
print func(a)
a:= makeArray(1)
print func(a)

Picture shows another solution



Regards Nadin

Re: [Bug][PS] assiging string[] to any[] method parameter

Siemens Phenom Siemens Phenom
Siemens Phenom

This behavior is actually not intended. If assigning an array to a local variable works, then passing that array to a parameter should also work.  We will change that in version 14.2.


Thank you nadin1223 for providing a workaround.

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