Announcement

Collapse
No announcement yet.

Help: Passing array member of UDT

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

  • Help: Passing array member of UDT

    Hi folks,
    Hopefully someone can provide me with a quick answer to this one
    because its been stumping me for the last 10 minutes.

    Why cant I pass the byte array element of my udt, the same
    way that I can pass a regular byte array that is not a member
    of a udt? How would I correctly pass that udt member?

    Thanks in advance!
    -Mike

    Code:
    #COMPILE EXE
    #DIM ALL
    
    TYPE UDT
        B(0 TO 5) AS BYTE   
    END TYPE
    
    FUNCTION PassByteArray( B1() AS BYTE) AS LONG
        MSGBOX "Success"
    END FUNCTION
    
    FUNCTION PBMAIN()
        DIM b() AS BYTE
        DIM lRet AS LONG
        DIM u AS UDT
        
        Redim b(0 to 5)
        
        'lRet = PassByteArray( u.b())   <-- This fails
        lRet = PassByteArray(b())       <-- This works
        
    END FUNCTION
    ------------------

  • #2
    Mike --
    array in UDT is not an array at all.
    Compiler simply calculates offsets and doesn't create a descripter.
    That's why pass address of first element + no. of elements.

    ------------------
    E-MAIL: [email protected]

    Comment


    • #3
      Thanks for the fast response. Gonna have to re-think my
      design here... i dont really want to have to pass two
      parameters for this if i can avoid it. Maybe instead of
      bytes i'll just use asciiz.
      -Mike


      ------------------

      Comment

      Working...
      X