Announcement

Collapse
No announcement yet.

Where to dim UDT?

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

  • Where to dim UDT?

    Hi Folks,

    My application is going to use an UDT. What is the location within the code to DIM it as an array?
    It's not allowed outside a procedure or function.
    I tried the following:
    within the procedure that uses it for the first time
    within the main module (actually as the first line),
    but in both cases the compiler does not recognize it.




    ------------------
    mailto:[email protected][email protected]</A>
    www.basicguru.com/zijlema/

    Egbert Zijlema, journalist and programmer (zijlema at basicguru dot eu)
    http://zijlema.basicguru.eu
    *** Opinions expressed here are not necessarily untrue ***

  • #2
    Here's an example for ya

    Code:
    #COMPILE EXE
    
    TYPE ExampleStruct
         Yoga AS STRING * 25
         Smitty AS LONG
         Hello AS DWORD
    END TYPE
    
    FUNCTION PBMAIN() AS LONG
        DIM Example(0 TO 3000) AS LOCAL ExampleStruct
        Example(0).Yoga = "HELLO!"
        Example(0).Smitty = 1
        Example(0).Hello = 123456789
        MSGBOX Example(0).Yoga
        MSGBOX STR$(Example(0).Smitty)
        msgbox str$(Example(0).Hello)
    END FUNCTION
    Here's another example using Pointers

    Code:
    #COMPILE EXE
    
    TYPE ExampleStruct
         Yoga AS STRING * 25
         Smitty AS LONG
         Hello AS DWORD
    END TYPE
    
    FUNCTION PBMAIN() AS LONG
        DIM Example(0 TO 3000) AS LOCAL ExampleStruct
        DIM ExamplePTR AS ExampleStruct PTR
        ExamplePTR = VARPTR(Example(0))
        @ExamplePTR[0].Yoga = "HELLO!"
        @ExamplePTR[0].Smitty = 1
        @ExamplePTR[0].Hello = 123456789
        MSGBOX @ExamplePTR[0].Yoga
        MSGBOX STR$(@ExamplePTR[0].Smitty)
        MSGBOX STR$(@ExamplePTR[0].Hello)
    END FUNCTION
    ------------------
    -Greg

    [This message has been edited by Gregery D Engle (edited July 20, 2001).]
    -Greg
    [email protected]
    MCP,MCSA,MCSE,MCSD

    Comment


    • #3
      Thanks Gregery,
      Problem solved.
      Regards,

      ------------------
      mailto:[email protected][email protected]asicguru.com</A>
      www.basicguru.com/zijlema/

      Egbert Zijlema, journalist and programmer (zijlema at basicguru dot eu)
      http://zijlema.basicguru.eu
      *** Opinions expressed here are not necessarily untrue ***

      Comment

      Working...
      X