On Feb 24, 2006, at 10:39 PM, maxclass@... wrote: > > On Feb 24, 2006, at 11:51 AM, Bernie wrote: > >> >> def fn UBound( @p as pointer ) = [p + _AutoXREFCurr] - 1 >> > > First, I could not find a reference to _AutoXREFCurr whatever it > is. Maybe it's not important. Just curious as to where you found > the constant and what it means. It is mentioned in the reference manual under the DYNAMIC keyword. The actual definition is currently in Subs Dynamic.incl and is defined to the value 4. This offset (4) is used to store the next available slot in the dynamic array. There have been changes to the Dynamic code that are not reflected in the FB4 rel 2 version. > > Next. A trick I have always used is to never use element zero as > the first element. That way every item is exactly in its place > without having to add or subtract anything from it to get the > actual true location of the 'item' in the array. Yes, ignoring index zero is actually sometimes required when using, for example, databrowsers and can have value. The code submitted for this thread (i.e. removing an element from a dynamic array) by the listers was focused on the goal. Using index zero or not tends to be a personal preference. > > I have also sometimes used element zero to hold the actual number > of items in the array but I have found that the best solution for > that is to have some instance variable connected to the array to > hold the actual count for you. Then increment or decrement it as > the need arises. Hey, some good thoughts! Bring on the code! BTW: Some of these are already built into dynamic arrays. For example, clearing an array: Kill Dynamic arrayname.