[futurebasic] Re: Array specification

Message: < previous - next > : Reply : Subscribe : Cleanse
Home   : April 1998 : Group Archive : Group : All Groups

From: Jay Reeve <jktr@...>
Date: Wed, 8 Apr 98 01:11:37 +0100
Dale,

Alessandro wrote:
>DIM Gird(10,10,10,8);0
>DIM 9 Gird$(10,10,10)
>
>'two dim is in same phisical ram space.

Maybe I'm missing something, but I don't believe this can work. It's true 
you have two arrays sharing (approximately) the same memory, but in the 
first case there are 1,331 (11x11x11) 18-byte arrays, for a total array 
size of 21,296 bytes. The string array has 1,331 10-byte strings (9 + 
length byte) for a total array size of 13,310.

Let me offer one more potential solution that may come closer to your 
original request.
'----------
LOCAL FN getBlock(@arrayBlock&,@vars&)
  BLOCKMOVE arrayBlock&, vars&, 16   'Copy coords into vars
END FN

LOCAL FN putBlock(@arrayBlock&, @vars&)
  BLOCKMOVE vars&, arrayBlock&, 16   'Copy coords back into block
END FN
'----------
  DIM Gird.16(10,10,10)        'Make array of 1,331 16-byte blocks
  'Assign names to 8 contiguous integers (16 bytes):
  DIM X1,Y1,X2,Y2,X3,Y3,X4,Y4

'When you're ready to work with a particular block,

  FN getBlock(Gird(a,b,c),X1)  'Note: ALWAYS use X1 for 2nd param!

'Read, calculate and change the coordinates X1, Y1, etc. all you like. 

  X1 = 0 : Y1 = 0               '(Nonsense examples)
  X2 = 50 : Y2 = 50
  X3 = X2 * 2 : Y3 = Y2 / 2
  X4 = X4 + 23 : Y4 = Y4 + 32

'When you are finished with that block, just reverse the process:

  FN putBlock(Gird(a,b,c),X1)  'Note: ALWAYS use X1 for 2nd param!

'To copy entire blocks:

  BLOCKMOVE @Gird(a,b,c), @Gird(x,y,z), 16

'----------

I'm fascinated by all the different approaches available for this 
question. I have another using XREF that I won't go into unless 
requested. (I prefer this one.) Please do let us know what you choose.

 @^@
 =J= a  y