News:

Function Finder  Find all the functions within source code files

Main Menu

Types and multi-dimensional arrays

Started by SpellSword, July 08, 2007, 02:52:08 AM

Previous topic - Next topic

SpellSword

I'm not sure what is the proper way to interact types and arrays, and I was hoping someone here could shed some light on it.

Do the arrays inside the type have to be one dimensional (1D) or is it the external Array outside the type that is being used to store the type data style? Or both?

Example (Correct):
Type MyType
     MyIntegerArray(10)
     MyFloatArray$(20)
     MyStringArray$(30)
EndType


Example (Incorrect):
Type MyType
     MyIntegerArray(10,10)
     MyFloatArray$(20,33,24,56,32)
     MyStringArray$(30,1)
EndType


Or is it that the type can only be assigned to Arrays that have a single dimension, and not multi-dimensional arrays?

Example (Correct):
TheArray(30) As MyType

Example (Incorrect):
TheArray(30,10,58,39) As MyType

I'm completely new to the use of types, but if they behave like I think they will then what a powerful tool!

For example, instead of creating four different Arrays(Or)Variables:
CarType=3
CarSpeed=2
CarColor=2
CarCost=34


A single Type can be assigned to a variable allowing it to contain all 4 sets of data!

(Ack, sorry... rambling on!)

I don't have the programming terminology down yet, so I hope I've been able to articulate what I mean.
When I dream,
I carry a sword in one hand,
a gun in the other...

kevin

QuoteDo the arrays inside the type have to be one dimensional (1D) or is it the external Array outside the type that is being used to store the type data style? Or both?

   Yes, this is a current limitation.   


QuoteOr is it that the type can only be assigned to Arrays that have a single dimension, and not multi-dimensional arrays?

    No, the containing array be have as many dimensions as you like (with max of 10),  each dimension can be as large as like.  (memory allowing)

    I'm not sure i follow your last example.   

    Anyway, here's an example using a 2D typed array to represent a checker board (of sorts) .. See Checker Board Example

   



Rembrandt Q Einstein

ugghh..  I wish I knew types could have 1d arrays.  That would have made for some cleaner code.  I'm picking up something new every day.

Honestly I don't know why I thought they couldn't.  Maybe I just assumed since when I used DB it didn't allow it.