[Info-vax] DEC Basic and dynamic memory ?

seasoned_geek roland at logikalsolutions.com
Fri Jan 28 17:09:06 EST 2022


On Friday, January 28, 2022 at 1:57:28 PM UTC-6, Simon Clubley wrote:
> 
> How easy is it in DEC Basic to build a tree of (say) 1000 nodes of 
> a custom data structure in dynamic memory and then walk the tree 
> either depth-first or breadth-first ? 
> 

The statement that you want is

DIM

create a (I haven't hacked BASIC for a while and didn't log into Eisner to test this so take the concept, not the syntax, as being pure)

RECORD SOME_RECORD
STRING IN_USE=1%
STRING SOME_KEY_VALUE=15%
INTEGER  PREV_REC
INTEGER  NEXT_REC
STRING    WHOLE_LOT_OF_STUFF=255%
! other fields
END RECORD

As you learned in data structures class, you put the subscripts in as you add records.
You have to keep the doubly linked list in order yourself, but if you set IN_USE to CVT%$(255%) or even just "Z" for every empty record you can even sort well.

Oh, you don't like it as a doubly linked list?

RECORD SOME_RECORD
STRING IN_USE=1%
STRING SOME_KEY_VALUE=15%
INTEGER  LEFT_NODE
INTEGER  RIGHT_NODE
INTEGER  PARENT_NODE
STRING    WHOLE_LOT_OF_STUFF=255%
! other fields
END RECORD

You can even redimension if need be.



More information about the Info-vax mailing list