[Info-vax] DEC Basic and dynamic memory ?

Dave Froble davef at tsoft-inc.com
Sat Jan 29 00:30:49 EST 2022


On 1/28/2022 2:57 PM, Simon Clubley wrote:
> On 2022-01-28, Dave Froble <davef at tsoft-inc.com> wrote:
>> On 1/28/2022 12:31 PM, John Reagan wrote:
>>> 4) As we've discussed the BASIC cross-compiler is still not available due to G2L not being
>>> able to totally handle how the BASIC MAP statement is described to GEM.  The GEM to
>>> LLVM module for common blocks is radically different.  Could you write a DIRECTORY
>>> replacement in BASIC without using MAP?
>>
>> Why, yes, I'm rather sure I could.  For example, from one of my routines:
>>
>>          RECORD FABBLK                                   !
>>          RECORD NAMBLK                                   !
>>          RECORD FIBBLK                                   !  FIB structure
>>
>> And now I'm waiting for you to say that the Basic RECORD statement has the same
>> problems as MAP.
>>
>
> 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 ?

Linked lists are rather basic (sic) ..

> I've had a quick look at the dynamic storage section of the DEC Basic user
> manual, but I don't see how you link a set of nodes together into a tree.
> However, as mentioned previously, I don't know DEC Basic and searching
> for the word pointer didn't reveal anything appropriate, so I assume
> it's another keyword I am not aware of.

No, it is because you're attempting to use methods you'd use in C.  Different 
methods in Basic.

> In addition, how easy is this to do if the nodes are not all of the
> same record type, but have a common tag at the start of each record
> to say what kind of record it actually is ? I see you have variant
> records in DEC Basic. Do they also work in a dynamic memory based
> tree structure ?

Unless you're going to do your own LIB$Get_VM Basic doesn't do dynamic memory in 
that manner.  You can, but probably should not.  I tend to assign adequate 
storage for the task at hand.

An example of how I'd approach any such need:

Record NODES
	Long	ForwardLink
	Long	BackLink
	Word	InUse
	String	N$=64
End Record

DIM NODES List(999)

Might also:

DIM NODES List2(999)
DIM NODES List3(9999)

I'd probably have an integer variable pointing to the start of the list.  Would 
not have to be consecutive if nodes were being added and deleted.  Could have an 
integer pointing to beginning of unused nodes.  (I avoid using the word POINTER, 
though that's what they would be.)

Not going to go much further, other than to say that I've used linked lists, 
tree structures, and such many times.

If you really want to get into such, take a look at my RMS_LOCKS.BAS on the VMS 
freeware.

-- 
David Froble                       Tel: 724-529-0450
Dave Froble Enterprises, Inc.      E-Mail: davef at tsoft-inc.com
DFE Ultralights, Inc.
170 Grimplin Road
Vanderbilt, PA  15486


More information about the Info-vax mailing list