BBC BASIC for Windows
Programming >> Database and Files >> Lists in BB4W
http://bb4w.conforums.com/index.cgi?board=database&action=display&num=1386770394

Lists in BB4W
Post by dje4816 on Nov 15th, 2013, 3:49pm

Several languages offer a List function. This is essentially an array which can be grown or shrunk on the fly without destroying its contents. Typically a structure would be used, one field holding data with a couple of other fields employed as pointers to the preceding and succeeding element in the list. A new element (structure) can be added anytime, and an existing structure can be deleted anytime without affecting the rest of the List.

I can't find a way to make BB4W structures generate new structures without providing a structure name on the fly, so I'm stuck. I want the List feature in a program I'm working on.

I'm sure someone has already solved this problem, so please give me some pointers (no pun intended!)

Dave.
undecided
Re: Lists in BB4W
Post by admin on Nov 15th, 2013, 5:34pm

on Nov 15th, 2013, 3:49pm, dje4816 wrote:
Typically a structure would be used, one field holding data with a couple of other fields employed as pointers to the preceding and succeeding element in the list.

What you seem to be describing there is a doubly-linked list. If so, these Rosetta Code pages contain BBC BASIC solutions for Element Definition, Element Insertion and Traversal:

http://rosettacode.org/wiki/Doubly-linked_list/Element_definition#BBC_BASIC
http://rosettacode.org/wiki/Doubly-linked_list/Element_insertion#BBC_BASIC
http://rosettacode.org/wiki/Doubly-linked_list/Traversal#BBC_BASIC

Does that help?

Richard.

Re: Lists in BB4W
Post by dje4816 on Nov 16th, 2013, 08:36am

Thanks, Richard, I knew you'd come up with something!

Dave.
laugh
Re: Lists in BB4W
Post by dje4816 on Nov 16th, 2013, 09:45am

I tried to use the code linked at http://rosettacode.org/wiki/Doubly-linked_list/Traversal#BBC_BASIC.

In the code in the link the following lines appear:

a.pNext% = b{}
a.iData% = 123
b.pPrev% = a{}
b.iData% = 789
c.iData% = 456

When I copy and paste them in to BB4W, they appear like this:
andpNext% = b{}
andiData% = 123
bgetpPrev% = a{}
bgetiData% = 789
colouriData% = 456

As you can see, BB4W changes the code after copying it in. So I tried typing it in directly into BB4W, with exactly the same effect.

What's going on here? Do those changes mean anything? Either way, the code doesn't run.

Any help and an explanation appreciated!

Dave.





huh huh undecided sad huh smiley
Re: Lists in BB4W
Post by Malvern on Nov 16th, 2013, 12:32pm

Go to the IDE Options menu, select Customize and then uncheck the Accept Keyword Abbreviations option.

The effect you are getting is because you have lower case keywords selected and the IDE thinks you are trying to use abbreviated keywords.
Re: Lists in BB4W
Post by dje4816 on Nov 16th, 2013, 12:40pm

Thanks, Malvern, it's working fine now.

Dave.
laugh