Community
cancel
Showing results for 
Search instead for 
Did you mean: 
Highlighted
Beginner
12 Views

Convert array of objects into array of properties

Jump to solution

Say I have an array of class People called Employees,

ArrayOfEmployedAtAge  = Employees(:)%BirthDate - ArrayOfEmployedDate

The result is

error #6159: A component cannot be an array if the encompassing structure is an array.


 

0 Kudos

Accepted Solutions
Highlighted
Black Belt
12 Views

Is the BirthDate component a non-allocatable, non-pointer, integer scalar?  If so... Employees%BirthDate will be an integer array (the (:) bit is frippery in this context).  If not... it will be something else, possibly an error.

As per #2... please show the declarations.

View solution in original post

0 Kudos
3 Replies
Highlighted
Valued Contributor II
12 Views

You are not clear about:

  • The question you want an answer to (I guess it is: how to solve the compile error, but then we need information on what you actually want to do)
  • The declaration of the various variables. I guess from the error message that BirthDate, the one component in this statement, is not a scalar, but given the missing declarations, it is no more than a guess

Please provide the missing information, so we can help.

0 Kudos
Highlighted
Beginner
12 Views

Arjen Markus wrote:

You are not clear about:

  • The question you want an answer to (I guess it is: how to solve the compile error, but then we need information on what you actually want to do)
  • The declaration of the various variables. I guess from the error message that BirthDate, the one component in this statement, is not a scalar, but given the missing declarations, it is no more than a guess

Please provide the missing information, so we can help.

I want to make a integer array from the birth date of employees. But Employees is an array of objects and the birth date is only a property. 

Question: Is there a syntax error in this line?

ArrayOfEmployedAtAge  = Employees(:)%BirthDate - ArrayOfEmployedDate

Will Employees(:)%BirthDate return an integer array of BirthDates?

If not what is the right way of doing that (without making a loop)?

0 Kudos
Highlighted
Black Belt
13 Views

Is the BirthDate component a non-allocatable, non-pointer, integer scalar?  If so... Employees%BirthDate will be an integer array (the (:) bit is frippery in this context).  If not... it will be something else, possibly an error.

As per #2... please show the declarations.

View solution in original post

0 Kudos