Silverfrost Forums

Welcome to our forums

Silverfrost .NET abstract/interface typed arguments?

4 Aug 2013 10:39 #12749

Hello,

I am trying to write a function a bit like the one below.

FUNCTION GetPropertyUnitGroupName(model, property)
        OBJECT('Domain.UnitBaseModel'), INTENT(IN) :: model
        CHARACTER(LEN=*), INTENT(IN) :: property
        CHARACTER :: GetPropertyUnitGroupName
        OBJECT('Domain.Units.UnitGroup') :: unitGroup
        unitGroup = GetPropertyUnitGroup(CAST@(model, 'Domain.UnitBaseModel'), STRING@(property))
        GetPropertyUnitGroupName = CHAR(unitGroup%Name)
END FUNCTION GetPropertyUnitGroupName

However when trying to use it as such.

GetPropertyUnitGroupName(Input%IrrigationData, 'PumpMinimum')

I get error messages like this.

'[color=red:9fe9960f29]In the INTERFACE to GETPROPERTYUNITGROUPNAME (from MODULE MODDOMAIN), the first dummy argument (MODEL) was of type OBJECT('Domain.UnitBaseModel'), whereas the actual argument is of type OBJECT('Domain.Input.IrrigationInfrastructure')[/color:9fe9960f29]'

So I was wondering if there is anyway I can fix my function to be able to take a more generic first parameter without having to call CAST@() every time I call it?

Also what is the easiest way to get around not being able to pass .NET arrays as arguments to functions?

Thanks, Alex.

Please login to reply.