Given an array of records, how can I get an array representing a field from each one?

Viewed 2171

I have to translate some Fortran 90 code and found an interesting language feature.

As an example, they define the following type and dynamic-array variable:

TYPE WallInfo
  CHARACTER(len=40) :: Name
  REAL              :: Azimuth
  REAL              :: Tilt
  REAL              :: Area
  REAL              :: Height
END TYPE WallInfo

TYPE(WallInfo), ALLOCATABLE, DIMENSION(:) :: Wall

Later in the code, they call a function:

CALL HeatFlow(Wall%Area, Wall%Azimuth)

As a Delphi programmer, this threw me a bit because Wall is an array of records!

From the usage in the routine, it is clear that Fortran can project fields from the record array as an array of their own.

SUBROUTINE HeatFlow( Area, Azimuth )
  REAL, INTENT(IN), DIMENSION(:) :: Area
  REAL, INTENT(IN), DIMENSION(:) :: Azimuth

Does anyone know if there is a way to do this with Delphi (I'm using version 2010)?

I could write a function to extract a record value as an array but this is a bit tedious because I will have to write a dedicated routine for every field (and there are a quite a few).

I'm hoping that there is some language feature in Delphi 2010 that I have missed.

3 Answers
Related