Announcement

Collapse

New Sub-Forum

In an effort to help make sure there are appropriate categories for topics of discussion that are happening, there is now a sub-forum for databases and database programming under Special Interest groups. Please direct questions, etc., about this topic to that sub-forum moving forward. Thank you.
See more
See less

Can't get TYPEs to work w/ arrays...

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

  • Can't get TYPEs to work w/ arrays...

    This is actually 2 questions..

    1) Can i DIM an array as a TYPE?
    Type MyType
    MyVar1 as integer
    MyVar2(900) as single
    End Type
    DIM MyArray(1 to 10) as MyType

    well when i do the above i get an error on a statement like this
    MyArray(3).MyVar1 = x

    2) I want to use GET & PUT for animation on a game i'm making
    But when i try using an Array w/in a type it says it's a Syntax Error

    Type MyType
    MyPic(900)
    etc...
    End Type
    DIM MyPictureType as MyType
    Get (0,0)-(30,30), MyPictureType.MyPic <-- however this works fine using a normal array (not within a Type)

    any help will be appriciated

    Kevin

  • #2
    Arrays within a UDT is only available in PB/DOS 3.5. The following code compiles and runs fine:
    Code:
    Type MyType
      MyVar1 as integer
      MyVar2(900) as single
    End Type
     
    DIM MyArray(1 to 10) as MyType
    MyArray(3).MyVar1 = x
    However, because an array inside a UDT is not exactly the same as a conventional array, you cannot use them with the graphic "get" statement, exactly as you have found. The "workaround" is to use a conventional arraym and move the data across to the array within the UDT.

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

    Comment

    Working...
    X