Qbasicnews.com

QBasic => QB Discussion & Programming Help => Topic started by: Agamemnus on March 15, 2003, 03:38:06 PM



Title: dynamic integers?
Post by: Agamemnus on March 15, 2003, 03:38:06 PM
is there any way to redim part of an integer array in qb or vbdos?

If I had array1(100,10), for instance, and I wanted to have different sizes for each of the 100 parts of the first dimension, could I do that?

I'll probably have to figure out a way to do it without dynamic array like that, though. :|


Title: dynamic integers?
Post by: toonski84 on March 15, 2003, 03:55:37 PM
well, if you're using qb 7.1, you can put arrays in type structures, like so:

type bob
 joe(10) as integer
 bill(5) as integer
end type

dim bob(100) as bob

but this wont work in qb4.5


Title: dynamic integers?
Post by: Agamemnus on March 15, 2003, 04:52:00 PM
yes but... how does that make 'em dynamic?

Well anyways I made a max of 8 so problem solved.


Title: dynamic integers?
Post by: toonski84 on March 15, 2003, 08:23:17 PM
i dont know, but you said you wanted them to have different lengths...

i think the only way to do this is string arrays, but if this is files, windows does have a 255 character cap, so you could always stop there.


Title: dynamic integers?
Post by: Agamemnus on March 15, 2003, 09:14:15 PM
but strings are slow. =|


Title: dynamic integers?
Post by: toonski84 on March 16, 2003, 01:24:05 AM
yeah, but how fast must you retrieve and handle 100 strings?  that oughta fly on a 486 unless you're doing some sort of crazy string manipulation or something, which i'm willing to bet you arent by the filename references.


Title: as fast as possible...
Post by: Agamemnus on March 16, 2003, 11:41:46 AM
for the pathfinding of the RTS me and pr0gger are making.

The max would be (x.max^2+y.max^2)^.5 which comes out with a lot of empties.

3 ideas I came up with:

1) use a limited amount of integers for each tank and keep remaking the path (up to a certain point) when the tank goes through those integers. (slow)
2) use path strings for each tank. (slow)
3) put all the movement into a large integer queue with a reference to both the unit and where it should go. (fast but... hmm...)

EDIT:
4) then again, 200k memory for a 160x120 map, 1000 units doesn't seem so bad... but the array size is too big. :|