Announcement

Collapse
No announcement yet.

Only 2 dimensions max for arrays in UDT's?

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

  • Only 2 dimensions max for arrays in UDT's?

    Hi,
    Am i doing something wrong or are UDT's limited to containing
    arrays wich only have 2 dimensions maximum?

    Type Test
    a(0 to 1) as long
    b(0 to 2, 0 to 2) as long
    c(0 to 3, 0 to 3, 0 to 3) as long
    End Type

    As far as I can tell, a and b are allowed, but c isnt. Is this
    a limitation... Will more dimensions be allowed in future versions?

    -Mike

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

  • #2
    Yes, the limit is two dimensions for arrays within types, and this is mentioned in the documentation.

    I'll pass your request for more dimensions along to R&D.

    Thanks!



    ------------------
    Lance
    PowerBASIC Support
    mailto:[email protected][email protected]</A>
    Lance
    mailto:[email protected]

    Comment


    • #3
      Originally posted by Lance Edmonds:
      Yes, the limit is two dimensions for arrays within types, and this is mentioned in the documentation.

      I'll pass your request for more dimensions along to R&D.
      If you update the documentation, please also consider:

      A. Renaming "arrays" to "tables" or something else
      and/or
      B. Making it *very* explicit in the documentation that UDT "arrays" are not really "arrays" and none of the "ARRAY xxxxx" operate on them.
      and/or
      C. Changing the compiler to flag attempts to use "ARRAY xxx" on a UDT table as a compile-time error.

      MCM


      Michael Mattias
      Tal Systems (retired)
      Port Washington WI USA
      [email protected]
      http://www.talsystems.com

      Comment


      • #4
        Thanks for the head-up Michael... I'll pass those suggestions along.

        One note though on point C: The compiler does flag use of an inappropriate array with an error 423 "Array Variable Expected". Try it for yourself:
        Code:
        #COMPILE EXE
         
        TYPE a
            b AS LONG
            c(1 TO 1000) AS LONG
            d AS LONG
        END TYPE
         
        FUNCTION PBMAIN
            DIM x AS a
            ARRAY SORT x.c() ' Error 423 as expected!
        END FUNCTION
        ------------------
        Lance
        PowerBASIC Support
        mailto:[email protected][email protected]</A>
        Lance
        mailto:[email protected]

        Comment


        • #5
          Ofcourse you can always DIM AT to get around that one...

          Peter.


          ------------------
          [email protected]

          Comment


          • #6
            Actually if you need a work around for the 2 element limit for UDT variables,
            you can do the following:

            Type DIndex
            TE(100,100) as Integer
            End Type

            Type MyType
            MyVariable(100) as DIndex
            End Type

            You now have three elements at your disposal, albeit you must access
            them as:

            Dim MyRec as MyType

            MyRec.MyVariable(a).te(b,c) = x


            Its not pretty, but it does work. I had to revert to using the same type
            of coding in several of my programs.

            Ray


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

            Comment

            Working...
            X