>>>DIM imageRow as long >>>imageRow = gRect.right-gRect.left (say this equals 1200 this time) >>> >>>DIM tmpListH as Handle >>>XREF@ myList(imageRow) as CList >>> >>>Sorry, I just got lost... Argh. >>> >>>Now it is a two tier mess... >>> >>>Robert >>> >> >>I cant see how this would work - at some point you need to calculate the >>size of the memory block - XREF takes care ofthe offsets for each element >>in the array. I'm not sure that the offsets can be calculated dynamically, >>and keeping track of the memory blocks size could also be fun. >> >>What do the experts think? >> >>cheers >> >>David > >I thunk there was a memory block somewhere. > >Why does making use of dynamic memory allocation in FB have to be so hard? > It's so hard because you think it's so hard. To me, it's easy because I think it's easy. Okay, maybe there are some experiential factors, but mind-set has something to do with it. :) Try this on for size: You allocate one handle for each array. You have one XREF@ statement for each TYPE of array you are going to use. When you want to use a particular array, just put its handle into the appropariate XREF@ var. Array handles may be stored in other arrays, each of which will have its own handle. I suspect the conceptual difficulty is that you are thinking in 2-dimensional (x,y) terms, and therefore wanting to create 2-dimensional arrays for your data. That's fine unless you need dynamic allocation. Try thinking of each row of data existing in a single array. Then you can have a single array of handles to these rows, so you can easily pick out the one you want. This is obviously what you are proposing, but the fog hasn't settled yet. Work with it a little, then sleep--it should be clear in the morning. BEGIN RECORD Contrib DIM pixel as Int DIM weight as Double END RECORD BEGIN RECORD CList DIM n as int DIM pHndl(_maxInt) as handle END RECORD XREF@ theCLists(_maxLong) as CList'Array of Clists XREF@ theRow(_maxLong) as Contrib'Array of data for 1 row DIM as long rowCount,c DIM as long imageRow,rowSize,r n = gRect.bottom-gRect.top'Is this what goes in CList.n? theCLists = fn newhandle((n+1) * sizeof(Clist))'Allocate dynamic memory imageRow = gRect.right-gRect.left'Get # of pixels for array rowSize = (imageRow+1) * sizeof(Contrib)'Calc size of row array for c = 1 to rowCount theClists.n(c) = whateverDataGoesHere'Set n val for row c of CList array theRow = fn newhandle(rowSize)'Allocate dynamic memory for XREF@ array theClists.pHndl(c) = theRow'Save handle in CList array for r = 1 to theClists.n(c)'Set data for each pixel in this row theRow.pixel(r) = myPixelData theRow.weight(r) = myWeightData next next'On to next row This may not work verbatim, but should be very close to what you're looking for. I look at XREF arrays as identical to DIM arrays, except that I am responsible for providing the memory. That's thw way I want it, so I can decide dynamically how much memory to provide. The other difference is that I can replace the data in the array by simply pointing it to a different block of memory. COOL! 0"0 =J= a y "