[futurebasic] Re: linked lists in FB

Message: < previous - next > : Reply : Subscribe : Cleanse
Home   : December 1997 : Group Archive : Group : All Groups

From: Rick Brown <rbrown@...>
Date: Fri, 05 Dec 1997 06:57:17 -0600
Chris wrote:
> In your example code you had a new handle created each time you wanted to
> add an element to the linked list.  if I had a dimmed variable that was
> created in the image of the data structure (ie DIM someRec.ListElement) how
> would I add that to the linked list?  Would I have to create a new handle,
> put that handle into the nextElement of the tail (or wherever I'm adding it
> to) and then move the data from the record into the handle?
> Something like this:
> DIM someRec.ListElement
> LOCAL FN addToTail (aRec)
>         newEle& = FN NEWHANDLE (_ListElement)
>         [newEle&];8 = aRec
>         'or would that be [[newEle&]];8 = aRec?
>         'code to get to the tail
>         'for arguments sake say that it is in tail&
>         tail&..nextElement& = newEle&

The "xxx;nn = yyy" syntax can't be used to move the data (the "xxx" part
has to be a "container," like a variable or an array element.  [newEle&]
does not identify a container, instead it's just an expression which
equals the address of the 8-byte data block.)  You would have to use
something like BLOCKMOVE instead.  In this _particular_ case, since
you're only moving 8 bytes, a pair of POKE LONG's might even be more
efficient than a BLOCKMOVE.

- Rick