No announcement yet.

Limitation with UDTs

  • Filter
  • Time
  • Show
Clear All
new posts

  • Limitation with UDTs

    PB has a known limitation with UDTs:

    Type TQuadix3D
    dp(0 To 3) As POINT3D
    End Type

    Type TQuadix3DArray
    Arr() As TQuadix3D 'needs here an integer dimensioning I try to avoid.
    End Type
    'Inside a function:
    Dim TQ3D(1 To 999) As TQuadix3DArray 'As an example for the wanted usage.

    In my current code I'm planning hundreds of similiar UDT definitions.
    How could I avoid dimensioning them like Arr(0) As TQuadix3D?
    Norbert Doerre

  • #2
    Dynamic portions of a UDT not possible, from the help file:

    subscripts The dimensions of a member array. Arrays of one and two dimensions are supported, but must be defined with constant or numeric literal values. That is, the total size of a UDT must be known at compile-time, so items like dynamic strings, which vary in size, cannot be part of a TYPE structure.
    Adam Drake


    • #3
      I believe you are going to need to allocate your own memory with the Api allocation functions, and access the records with pointers.

      Added Later...

      If at all possible, I'd try to declare UDT variables of a fixed size, then dimension as many of these fixed size UDTs as you need.
      Last edited by Fred Harris; 13 Feb 2008, 01:37 PM.


      • #4
        Weak syntax choice by the compiler publisher:

        "Arrays" within UDTs are not PowerBASIC "Arrays" in that none of the ARRAY functions (UBOUND, LBOUND, DIM/REDIM or ARRAY xxxxxx) work with them.

        I would have (and do) call "multiple indexed or subscripted occurrences of a UDT member variable" Tables.

        Michael Mattias
        Tal Systems (retired)
        Port Washington WI USA
        [email protected]