Announcement

Collapse
No announcement yet.

Cannot Property Get Structures to Structures?

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • Cannot Property Get Structures to Structures?

    I tried this: (Simple demo)
    Code:
    #COMPILE EXE
    #DIM ALL
    
    #INCLUDE "WIN32API.INC"
    
    TYPE myStructure
        isValid AS LONG
        value1  AS LONG
        value2  AS LONG
    END TYPE
    
    CLASS InnerClass
        INSTANCE myElement AS myStructure
        INTERFACE InnerInterface
            INHERIT IUNKNOWN
            PROPERTY SET StoreValue (BYVAL myDataIn AS myStructure)
                myElement = myDataIn
                myElement.isValid = %TRUE
            END PROPERTY
            PROPERTY GET RetrieveValue () AS myStructure
                PROPERTY = myElement
            END PROPERTY
        END INTERFACE
    END CLASS
    
    CLASS OutterClass
        INSTANCE Inner() AS InnerInterface
        INSTANCE dCount AS LONG
        INTERFACE OutterInterface
            INHERIT IUNKNOWN
            PROPERTY SET StoreValue (BYVAL myDataIn AS myStructure, BYVAL myIndex AS LONG)
                IF myIndex < dCount THEN
                    REDIM PRESERVE Inner(myIndex)
                    LET Inner(myIndex) = CLASS "InnerClass"
                END IF
                Inner(myIndex).StoreValue = myDataIn
            END PROPERTY
            PROPERTY GET RetrieveValue (BYVAL myIndex AS LONG) AS myStructure
                LOCAL tValue AS myStructure
                tValue.isValid = %FALSE
                IF myIndex <= dCount THEN _
                    IF ISTRUE ISOBJECT(Inner(myIndex)) THEN _
                        tValue = Inner(myIndex).RetrieveValue
                PROPERTY = tValue
            END PROPERTY
        END INTERFACE
    END CLASS
    
    FUNCTION PBMAIN () AS LONG
    
    END FUNCTION
    And it fails to compile at Line 43:
    Code:
    ...
                IF myIndex <= dCount THEN _
                    IF ISTRUE ISOBJECT(Inner(myIndex)) THEN _
                        tValue = Inner(myIndex).RetrieveValue
    ...
    Error 482 in (PATH)\classtest.bas(43:030):  Data type mismatch
    Line 43:                     tValue = Inner(myIndex).RetrieveValue
    Am I going to have to retrieve each element of the structure one at a time?

    P.S. If I use the form:
    Code:
                IF myIndex <= dCount THEN _
                    IF ISTRUE ISOBJECT(Inner(myIndex)) THEN _
                        PROPERTY = Inner(myIndex).RetrieveValue
    Then yes, it will compile, however, then it would probably be the main code which will eventually fail because it needs the structure.
    Furcadia, an interesting online MMORPG in which you can create and program your own content.

  • #2
    Use TYPE SET tValue = Inner(myIndex).RetrieveValue
    Forum: http://www.jose.it-berater.org/smfforum/index.php

    Comment


    • #3
      Oh yea, learned another keyword. :shake:
      Furcadia, an interesting online MMORPG in which you can create and program your own content.

      Comment

      Working...
      X