Announcement

Collapse
No announcement yet.

DIMming arrays

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

  • DIMming arrays

    Can I set the length of each segment of a double dimensioned string array?

    For example, I can use DIM a(500,12) AS SHARED STRING.

    But how do I set the length of each segment, such as
    a(x,1) = 5 bytes
    a(x,2) = 2 bytes
    and so on.

    Can anyone give me some advice.

    Regards,
    Brian Reynolds.
    Brian.

  • #2
    You should not need to set the length, as you can always interrogate it with LEN:

    PRINT LEN(a(x,1))



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

    Comment


    • #3
      Have you thought about using a UDT (user defined type)? You could then set the maximum length for each string: EG:

      TYPE StringType
      A AS STRING * 10
      B AS STRING * 20
      C AS STRING * 5
      END TYPE

      DIM MyType(500) AS StringType
      Walt Decker

      Comment


      • #4
        If you want to have a fixed format; rather than dimensioning a dual array, why not use a single array of a UDT:

        TYPE myUDT
        first AS STRING * 5
        second AS STRING * 2
        END TYPE

        Then DIM myArray(1 TO 100) AS myUDT.

        Now a(x,1) would be equivalent to myArray(x).first
        and a(x,2) would be equivalent to myArray(x).second

        Regards, Ian Cairns
        [email protected]
        :) IRC :)

        Comment

        Working...
        X