[futurebasic] Re: [FB] Removing element from dynamic array

Message: < previous - next > : Reply : Subscribe : Cleanse
Home   : February 2006 : Group Archive : Group : All Groups

From: Brian Stevens <brilor@...>
Date: Fri, 24 Feb 2006 23:17:16 -0700
Jay, this would be the newer stuff you mention since (as you know)  
I'm running a beta. Does the demo just submitted fail for you? It is  
just a quick hack but your feedback will probably help us improve it.

Thanks.....Brian


On Feb 24, 2006, at 8:47 PM, Jay Reeve wrote:

> Brian,
>
> This would have been fairly easy with Andy's Dynamic arrays, but  
> Robert's get into realms where I can't find any way to discover the  
> size of an element, so I've been unable to make it work.
>
>   e-e
>   =J= a  y
>    "
>
>
> On Feb 24, 2006, at 6:01 PM, Brian Stevens wrote:
>
>>
>> On Feb 24, 2006, at 9:09 AM, Bernie wrote:
>> <snip>
>>
>> This is great stuff from my perspective because some of my old  
>> code manages(if you can call it that)  dynamic arrays. Some of  
>> that code really needed some work and along comes this wonderful  
>> idea. My first thought (after WOW!) was to make a generic Fn that  
>> could accept *any* dynamic array and not just the one hard-coded  
>> in it. Here is my first shot at  (combining ideas from Bernie,  
>> Alain and Jay) doing just that. It isn't pretty but seems to work.  
>> It has barely been tested, so be careful. Also, this can be  
>> cleaned up since I just wrote code to try and make it work.
>>
>> Brian
>>
>>
>>
>>
>> dynamic gArray((_maxLong) as str255
>> dim as int nextAvail, i
>> dim as long length,itemToRemove
>>
>> local fn DynamicRemoveElement( item as long, which as long, dest  
>> as ptr,start as ptr,theLen as long )
>> dim as long  count
>> '~'1
>> count = [which + _autoXREFCurr]
>> if ( item < count ) then BlockMove( start, dest, theLen )
>> & which + _AutoXREFCurr, count - 1
>> end fn
>>
>>
>> gArray(0) = "Georgia Sam"
>> gArray(1) = "Jezebel the Nun"
>> gArray(2) = "Jack the Ripper"
>> gArray(3) = "Queen Jane"
>> gArray(4) = "Tom Thumb"
>> gArray(5) = "Thin Man"
>> gArray(6) = "The Brakeman"
>> gArray(7) = "Mr. Jones"
>> gArray(8) = "One-eyed midget"
>> gArray(9) = "Gypsey Davey"
>> gArray(10) = "Ma Raney"
>> gArray(11) = "Graveyard woman"
>> gArray(12) = "Mack the Finger"
>> gArray(13) = "The Seventh Son"
>> gArray(14) = "Dr. Filth"
>> gArray(15) = "The Mighty Quinn"
>> gArray(16) = "Tiny Montgomery"
>> gArray(17) = "Jack of Hearts"
>> gArray(18) = "Brownsville Girl"
>> gArray(19) = "John Wesley Harding"
>> gArray(20) = "Murf the Surf"
>> gArray(21) = "Lily"
>> gArray(22) = "Rosemary"
>> gArray(23) = "Einstein"
>> gArray(24) = "Robin Hood"
>> gArray(25) = "Louis the King"
>>
>>
>>
>> nextAvail = [@gArray + _autoXREFCurr]
>> print "Before removal count = ";nextAvail
>> itemToRemove = 16'take out Tiny Mongomery
>> length = @gArray(nextAvail-1) - @gArray(itemToRemove)
>> fn DynamicRemoveElement( itemToRemove, @gArray,@gArray 
>> (itemToRemove),@gArray(itemToRemove + 1),length)
>> compress dynamic gArray
>> nextAvail = [@gArray + _autoXREFCurr]
>> print "After removal count = ";nextAvail
>> for i = 0 to nextAvail
>> print gArray(i)
>>
>> next
>>
>> do
>> handleevents
>> until 0
>>
>> --
>>
>
> --
>