Qbasicnews.com

Full Version: Nedd some help with arrays and types..
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Okey, I'll try to explain this en english Smile

Here's an example:

TYPE Values
X AS SINGLE
END TYPE

DIM SHARED Player(2) AS Values

As it looks now i got Player(1).X, Player(2).X and so on..

But if i want something like this:

Player(1).Col(1), Player(2).Col(1)
Player(1).Col(2), Player(2).Col(2)

I want the variable col not to hold one value, but i want it ti be a array that can hold two values..
So not just Player(1).Col and Player(2).Col, i want Col to hold two values..

How do i declare something like that?

Thx alot!
I'm not sure , but try this :

TYPE Values
col(2) as single
END TYPE


But I repeat that I'm not sure ...
arg

Sorry ... i'm wrong
Sorry, it's not possible to take a type element and use it as an array in QB... it would be nice though.
It is possible in PDS (QB 7.1) and VBDOS, but not in QB4.5 and below.
you can still do it in qb. this is what you do:

1) make a type
2) make a large array of that type
3) make two more integer arrays of the same size for each unique object that you want to have that type for (item, object, unit..).

Ok, now each itme, object, unit, etc... is in an array, and has an index. You use that index to look up the number in the first array and the number in the second array.
The first number would give you the start position of the array in (2), and the second would give either the amount of things in (2) that tie up to your first object, or the end position.
So, you go from the start to end position, and that gives you a type array for any object. Easy, eh? :lol: