I'm busy looking into implementing the new Genero Methods into an application and was wondering how to return an Interface from a Function
I have two example Types set up as
TYPE TypeA RECORD
notUsed STRING
END RECORD
FUNCTION (typeA TypeA) test()
DISPLAY "Is TypeA"
END FUNCTION
And
TYPE TypeB RECORD
notUsed STRING
END RECORD
FUNCTION (typeB TypeB) test()
DISPLAY "Is TypeB"
END FUNCTION
Then an Interface to use them with as
TYPE IType INTERFACE
test()
END INTERFACE
It seems to work fine but how can they be used in a scenario like the below where I need to return an Interface depending on an argument
MAIN
DEFINE typeA TypeA
CALL typeBuilder("typeA") RETURNING typeA.*
CALL polyTest(typeA)
END MAIN
FUNCTION typeBuilder(request STRING)
DEFINE typeA TypeA, typeB TypeB
IF request = "typeA" THEN
RETURN typeA.*
ELSE
RETURN typeB.*
END IF
END FUNCTION
FUNCTION polyTest(itype IType)
CALL itype.test()
END FUNCTION
I'm trying to use in the code in MAIN as
MAIN
DEFINE itype IType
CALL typeBuilder("typeA") RETURNING itype
CALL polyTest(itype)
END MAIN