BBC BASIC for Windows
Programming >> User Interface >> Easily add stuff
http://bb4w.conforums.com/index.cgi?board=ui&action=display&num=1381101776

Easily add stuff
Post by JB91 on Jul 10th, 2010, 12:41pm

In the example program "DLGEDIT", you add stuff and resize it, and thats what I think should go into BBC BASIC. Instead of writing all the code, you can insert something, resize it and do lots and lots of other stuff. smiley
Re: Easily add stuff
Post by admin on Jul 10th, 2010, 9:22pm

on Jul 10th, 2010, 12:41pm, JB91 wrote:
In the example program "DLGEDIT", you add stuff and resize it, and thats what I think should go into BBC BASIC. Instead of writing all the code, you can insert something, resize it and do lots and lots of other stuff. smiley

Sounds like a library is required. I suggest you write a specification of just what you'd like to see in such a library and maybe somebody will take up the challenge!

The beauty of BBC BASIC is that it doesn't have the baggage that causes some other languages to be so bloated. Rather than building in more and more features, BBC BASIC is 'lean and mean', keeping only the most fundamental building blocks in the 'core' language. Everything else is done using add-ons like libraries.

Richard.
Re: Easily add stuff
Post by JB91 on Jul 13th, 2010, 6:01pm

Maybe someone could create a library where you have the following PROCs:

PROC_initlib - to instalize the library
All PROCs to do with dialog boxes
PROC_set - to set all objects

When you type in PROC_initlib and dialog box stuff, you run your program and the objects are resizable and movable. When you are happy with it, you close it and use PROCset to keep everything in place.

Can someone do it?
smiley
Re: Easily add stuff
Post by Matt on Oct 7th, 2013, 06:08am

I have been creating a DLGLIB for myself, which is constantly growing everytime I require another command. However, the constant adaptation and total number of commands that could potentially be included makes the library I'm doing inappropriate for the public domain - IMHO. I could list it here, but I'm sure those with a much higher and more logical programming skill would tear it to shreds.

Matt
Re: Easily add stuff
Post by admin on Oct 7th, 2013, 11:14am

on Oct 7th, 2013, 06:08am, Matt wrote:
I could list it here, but I'm sure those with a much higher and more logical programming skill would tear it to shreds.

Perhaps you could find one or more other BB4W users with whom you could collaborate to develop this further, rather as the 'community edition' of the Dialogue Editor was developed (although that rather seemed to fizzle out at the end).

I would be interested to learn to what extent the GUILIB that I proposed a while ago (and a tentative specification of which was published) would have met your needs. Again that's something that - try as I might - I couldn't drum up enough enthusiasm for to get moving.

If there is one thing that highlights the difference between the BBC BASIC community and the Liberty BASIC community it is the degree to which LB is 'user supported' (look at FreeForm and Liberty BASIC Workshop as examples of tools that have been written by users). With a couple of notable exceptions I have had to write most of the BBC BASIC tools myself.

Richard.

Re: Easily add stuff
Post by Edja on Oct 7th, 2013, 1:27pm

On this forum I've never seen anyone "tearing to shreds" someone else's contribution.

In my experience you'll get constructive and usefull tips and suggestions to improve your code and ideas to expand its functionality.

The worst that could happen is that you'll get no response by lack of intrest. But I suppose you'll survive that.

Just list it.
Eddy
Re: Easily add stuff
Post by Matt on Oct 10th, 2013, 05:26am

on Oct 7th, 2013, 1:27pm, Edja wrote:
On this forum I've never seen anyone "tearing to shreds" someone else's contribution.
My appologies, Edja. My intension was to imply that others with far more experience and expertise might find the coding primative and crude, thinking to themselves, "why this way, that's just daft". Not that they would write damning reports about it on here.

If others are willing to help produce a community edition, I'm more than happy to list it here. Although, it is long (142 lines) and would be better suited to being place on somewhere like the Wiggio site.

Anyone interested? And where shall I put it?

Matt
Re: Easily add stuff
Post by admin on Oct 10th, 2013, 09:12am

on Oct 10th, 2013, 05:26am, Matt wrote:
And where shall I put it?

That's a good question! With Yahoo having broken the Files List functionality (you can no longer link to an individual file, AIUI) that is no longer suitable. Options you could consider are:

  1. The files folder of the Wiggio group. Although it seems the group is unsuitable as a replacement for Yahoo, its files repository appears to work OK and I believe it can be accessed by non-members.
  2. Personal web space, if you have any (e.g. provided by your ISP as part of your broadband package).
  3. The Public folder in a free Dropbox account

Richard.
Re: Easily add stuff
Post by Matt on Oct 10th, 2013, 8:46pm

OK.

It's in the Wiggion Temp folder: DLGLIB.bbc

http://wiggio.com/#tpl=folderlist_1911366

Please feel free to make any constructive comments. The file is uploaded purely as is. I have made no adjustments.

Matt
Re: Easily add stuff
Post by admin on Oct 10th, 2013, 9:10pm

on Oct 10th, 2013, 8:46pm, Matt wrote:
It's in the Wiggion Temp folder: DLGLIB.bbc

I think only members will be able to access it that way, and I certainly don't want more people joining just to be able to download it! Click on the button to make a link, then publish the link, that way everybody will be able to access the file.

I'll save you the trouble this time, but in future that's the best method to use (everybody take note please):

http://wiggio.com/yui/folder/stream_file.php?doc_key=o7Jktoc8GfH9zZPXoTRxC0n8y2cBIJbHocRLDacLjyo=

Richard.

Re: Easily add stuff
Post by Matt on Oct 11th, 2013, 05:36am

on Oct 10th, 2013, 9:10pm, Richard Russell wrote:
Click on the button to make a link, then publish the link, that way everybody will be able to access the file.
Hadn't noticed the 'link' link. I was trying to copy a link to the Temp folder, which I found didn't work anyway. Will do it that way in future. Thanks.
Matt
Re: Easily add stuff
Post by Edja on Oct 11th, 2013, 09:32am

Would you have a minimal program somewhere that uses this libraries' functions just to demonstrate the "mechanics" ?
Re: Easily add stuff
Post by Matt on Oct 11th, 2013, 5:25pm

on Oct 11th, 2013, 09:32am, Edja wrote:
Would you have a minimal program somewhere that uses this libraries' functions just to demonstrate the "mechanics" ?
Not really. I've just been adding to the lib whenever I've wanted to do something different. I could write something if you wanted, but it might take some time. All I would do is produce a comprehensive array of controls in a dialog box and throw a few of the library elements about. Not exactly a great demonstration, though.

Matt
Re: Easily add stuff
Post by Edja on Oct 12th, 2013, 11:49am

on Oct 11th, 2013, 5:25pm, Matt wrote:
All I would do is produce a comprehensive array of controls in a dialog box and throw a few of the library elements about. Matt

Still, this would be useful (if not too much effort !!)
Eddy
Re: Easily add stuff
Post by Matt on Oct 13th, 2013, 10:30am

OK. Slightly edited version of DLG_LIB.bbc:
http://wiggio.com/yui/folder/stream_file.php?doc_key=VlTlnRespI5YxHZ9xmvhh5/tAtfwYbimUi6e9OYTsiU=
due to a few PROCs that had little to do with a community edition.

And a rough version of a demo DLG_LIB DEMO.bbc:
http://wiggio.com/yui/folder/stream_file.php?doc_key=QOuxQRn7VPBqKg+zu1OAMtljyAZWXUF6a2reduZv5+Q=
This doesn't utilise all aspects of the LIB, but please play around with the code and see what happens.

Matt
Re: Easily add stuff
Post by admin on Oct 13th, 2013, 11:30am

on Oct 13th, 2013, 10:30am, Matt wrote:
OK. Slightly edited version of DLG_LIB.bbc

Just a quick query. There are one or two places where you have used a WHILE..ENDWHILE loop when, superficially, a REPEAT..UNTIL or FOR..NEXT loop appears to be more appropriate. WHILE loops are slower than either of the other kinds (because they involve searching through the code at run-time, which is inefficient) so they are best avoided if that is easily achieved.

It's no coincidence that the original BBC BASIC (on the BBC Micro) had FOR..NEXT and REPEAT..UNTIL but not WHILE..ENDWHILE!

Richard.
Re: Easily add stuff
Post by Matt on Oct 13th, 2013, 3:25pm

on Oct 13th, 2013, 11:30am, Richard Russell wrote:
There are one or two places where you have used a WHILE..ENDWHILE loop when, superficially, a REPEAT..UNTIL or FOR..NEXT loop appears to be more appropriate.
You're probably right. I think the reason I chose WHILE..ENDWHILE is the avoidance of a conditional line to check to see if the second value was 'less than' the first. However, in a procedure that might well require a significant number of loops to complete, a conditional line may well be advised.

Matt
Re: Easily add stuff
Post by Matt on Oct 13th, 2013, 3:52pm

on Oct 13th, 2013, 11:30am, Richard Russell wrote:
WHILE loops are slower than either of the other kinds (because they involve searching through the code at run-time, which is inefficient).
Out of pure curiosity, I tried some rudimentay experiments and seemed to find that the REPEAT..UNTIL loop had a similar (if not slightly longer) loop time to that of WHILE. Does REPEAT not have to search as well? From previous posts I'm aware that FOR does not recheck a TO <numeric> unlike UNTIL <t-cond> or WHILE <t-cond>? Am I getting somewhere, or am I off the track? huh This seems to be basic stuff that I should already know, but obviously I don't. embarassed

Matt
Re: Easily add stuff
Post by admin on Oct 13th, 2013, 4:20pm

on Oct 13th, 2013, 3:52pm, Matt wrote:
Out of pure curiosity, I tried some rudimentay experiments and seemed to find that the REPEAT..UNTIL loop had a similar (if not slightly longer) loop time to that of WHILE.

What was the initial condition? The case when a WHILE loop is slow is, of course, when the initial condition is FALSE because it's then that the search to find the ENDWHILE has to take place (and because it must allow for things like nested WHILE loops this is quite complex).

Here is a test of the relative slowness of WHILE:

Code:
      S% = TIME
      FOR I% = 1 TO 10000000
        WHILE FALSE
          A = PI+PI+PI+PI+PI+PI+PI+PI+PI+PI+PI+PI+PI+PI+PI+PI+PI+PI
          A += PI+PI+PI+PI+PI+PI+PI+PI+PI+PI+PI+PI+PI+PI+PI+PI+PI+PI
          A += PI+PI+PI+PI+PI+PI+PI+PI+PI+PI+PI+PI+PI+PI+PI+PI+PI+PI
        ENDWHILE
      NEXT
      F% = TIME
      PRINT "Time for WHILE was "; F%-S% " centiseconds"
      
      S% = TIME
      FOR I% = 1 TO 10000000
        IF FALSE THEN
          REPEAT
            A = PI+PI+PI+PI+PI+PI+PI+PI+PI+PI+PI+PI+PI+PI+PI+PI+PI+PI
            A += PI+PI+PI+PI+PI+PI+PI+PI+PI+PI+PI+PI+PI+PI+PI+PI+PI+PI
            A += PI+PI+PI+PI+PI+PI+PI+PI+PI+PI+PI+PI+PI+PI+PI+PI+PI+PI
          UNTIL TRUE
        ENDIF
      NEXT
      F% = TIME
      PRINT "Time for IF/THEN plus REPEAT was "; F%-S% " centiseconds" 

On my PC the WHILE version took more than four times as long as the IF/THEN/REPEAT version.

Quote:
Does REPEAT not have to search as well?

No. A REPEAT loop is always executed at least once. Neither of the loop types supported in the original 6502 versions of BBC BASIC involves any kind of searching.

WHILE is unique in BBC BASIC in having to do a 'linear' search through what could be a considerable amount of code. No other statements ever need to search through more than one line of code. Of course if you know for sure that the initial condition will always be true then the search doesn't need to take place and WHILE isn't slow, but in that case a REPEAT loop is likely to be more appropriate anyway!

Richard.
Re: Easily add stuff
Post by Matt on Oct 14th, 2013, 04:53am

on Oct 13th, 2013, 4:20pm, Richard Russell wrote:
What was the initial condition? The case when a WHILE loop is slow is, of course, when the initial condition is FALSE because it's then that the search to find the ENDWHILE has to take place (and because it must allow for things like nested WHILE loops this is quite complex).

Yes. The only condition that was FALSE was the last one, so any time lag would be on that final one. Overall a realatively small drop.

Quote:
WHILE is unique in BBC BASIC in having to do a 'linear' search through what could be a considerable amount of code. No other statements ever need to search through more than one line of code.

I understand the need for the WHILE to search through the code until it finds the matching ENDWHILE, but doesn't the IF have to search through until it finds the matching ENDIF? Or is there something different about the way it searches?

Matt
Re: Easily add stuff
Post by admin on Oct 14th, 2013, 08:43am

on Oct 14th, 2013, 04:53am, Matt wrote:
Yes. The only condition that was FALSE was the last one, so any time lag would be on that final one.

"The only condition that was FALSE was the last one". That's stating the obvious - it's inherent in how WHILE..ENDWHILE loops work (they loop while the condition is true and terminate as soon as the condition is FALSE)!

And anyway even on that final FALSE condition no searching is required. If the initial condition is true, WHILE..ENDWHILE basically runs at the same speed as REPEAT..UNTIL.

Quote:
doesn't the IF have to search through until it finds the matching ENDIF? Or is there something different about the way it searches?

A single-line IF does have to search through code, and some of the same issues apply as for WHILE (although not nesting), but the important factor is that the maximum amount of code it has to search through is one line (i.e. about 250 bytes).

A multi-line IF..ENDIF doesn't have to search through any code as such, so it's much faster than WHILE..ENDWHILE. WHILE has to cope with the possibility that the token for ENDWHILE might be found within a text string, or a REMark, or a DATA statement, or after a line-continuation character. And a line-continuation character itself can be found in an encoded line number! So (in addition to needing to deal with nested WHILE loops) the search is complicated and messy.

It's in the knowledge of how horrible the code is that I like to avoid WHILE whenever I can (plus of course having spent 20-odd years programming in versions of BBC BASIC which didn't have WHILE at all)! I can understand why Acorn added WHILE, because it's a standard feature of other languages, but as I said it's uniquely messy in an interpreted language.

One reason why Brandy is so much faster than any other version of BBC BASIC is that it doesn't do any of this crazy stuff. It determines the position of the terminating ENDWHILE 'in advance' so no searching at run-time is required at all! You might argue that this is a vastly superior method to what Acorn's and my versions of BBC BASIC do, but I wouldn't care to comment. wink

Richard.