Qbasicnews.com

Full Version: plz help, 2 questions on array
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
1.how to ReDIM an array without setting all numbers to 0? To enlarge currently, thus new array elements are set to 0.

2.how to decalre an array-type array? I want to save pictures in an array
Code:
get (0,0)-(64,64),pix(1)
get (64,0)-(2*64,64),pix(2)
then I can
Code:
put (100,100),pix(1)
put (100,100+64),pix(2)

thanx.
1.- Like in PDS 7.1 or VBDOS, use REDIM PRESERVE.

2.- I didn't quite understand your question.
Im just gonna do this if you had 10*10 sprites to make it easy.

#1> DIM The array(X * Y * 2 - 1) That just makes space for booth arrays.
OR> DIM The array(X1 * Y1 + X2 * Y2 - 1) If you have different sized sprites.
#2> GET (0, 0)-(10, 10), Array(0)
#3> GET (11, 11)-(21, 21), Array(X * Y -1)

TO PUT:
#1> PUT (0, 0), Array(0) For the fist image
#2> PUT (0, 0), Array(X * Y - 1) For the second

NOTES:
In the fist dim, to make it hold more images do *3 for 3.... ect
THIS MIGHT NOT WORK! If it dosn't (I don't think it does) you can tell me.... but you need to have basic peek/poke knowledge.