BBC BASIC for Windows
Programming >> BBC BASIC language >> Tutorial for BBC BASIC http://bb4w.conforums.com/index.cgi?board=language&action=display&num=1395348925 Tutorial for BBC BASIC
Post by Wendell on Mar 20th, 2014, 8:55pm
I am using tutorial for help ..great help sometime. i am confuse when it come to the IF ,THEN, GOTO,GOSUB how to use labels. Has al of the above been put on PROCs Also FN. IS THERE a specifiv place to look in tutorial for this I CANNOT GET THE "IF THEN STATeMENT TO WORK ALL THE TIME.
Re: Tutorial for BBC BASIC
Post by rtr on Mar 20th, 2014, 10:34pm
I am confuse when it come to the IF ,THEN, GOTO,GOSUB how to use labels.
You will find very little information on the use of labels, because they were added to BBC BASIC for Windows only to support QB2BBC (the QBASIC to BBC BASIC translator) and LB Booster (my Liberty BASIC clone). Programs written in both of those languages commonly use labels, so it was necessary for BB4W to accept them in order to make the automatic translation into BBC BASIC practical.
BBC BASIC itself traditionally doesn't support labels at all; none of the other implementations of the language - e.g. the original BBC Micro 6502 version, BBC BASIC (Z80), ARM BBC BASIC, BBC BASIC (x86) or Brandy - do so. Also, even in BB4W, labels do not work in INSTALLed or CALLed modules, which rules out their use in libraries or subprograms.
The bottom line is: you are not expected to use labels in new programs and therefore they are substantially undocumented! Check out the Tutorial chapters on Conditional Execution, Selection using CASE and Other loops: REPEAT and WHILE for how to avoid the use of GOTOs:
The bottom line is: you are not expected to use labels in new programs and therefore they are substantially undocumented!
One of the undocumented features, and something which is arguably an anomaly, is that whilst this is allowed:
Code:
IF condition% THEN 1000
this isn't:
Code:
IF condition% THEN (label)
and you have to use this instead:
Code:
IF condition% THEN GOTO (label)
It would theoretically be possible for me to change BB4W v6 so that the second example does work. Like all such modifications it would inevitably slow down execution slightly. Is it something you think I should consider?
Richard.
Re: Tutorial for BBC BASIC
Post by DDRM on Mar 21st, 2014, 4:05pm
It would theoretically be possible for me to change BB4W v6 so that the second example does work. Like all such modifications it would inevitably slow down execution slightly. Is it something you think I should consider?
Hi Richard,
My tuppence:
If it would slow down *all* IF..THEN statements (or those calling a procedure/function), then I would say definitely not: an additional note in the manual that GOTO is required with a label would be adequate.
If it would only slow down explicit or implicit GOTOs, then I don't greatly care. However, it seems to me (but what do I know) a lot of effort to have to parse the bit after THEN to see if it's a label when it almost never will be - or is there no other situation in which it could start with a bracket?
Best wishes,
D
Re: Tutorial for BBC BASIC
Post by Edja on Mar 21st, 2014, 7:12pm
It would theoretically be possible for me to change BB4W v6 so that the second example does work. Like all such modifications it would inevitably slow down execution slightly. Is it something you think I should consider?
The statement IF ... THEN GOTO (label) doesn't add anymore to the value of BB4W and only encourages bad programming habits.
IF... THEN... ELSE + the different loops : REPËAT ... UNTIL, FOR ... NEXT, WHILE... ENDWHILE + the CASE statement provide us with ample and better alternatives for well structured programming. The concepts of PROC's and FN's are absolutely within the reach of even the beginning programmer if willing to look at a tutorial.
If you want to incorporate this in V6 you may spread yourself to thin to implement a feature that virtually no-one will use at the cost of speed of execution and your personal available time that could otherwise be spent on more "worthy causes"
Please don't consider it. Eddy Re: Tutorial for BBC BASIC
Post by rtr on Mar 21st, 2014, 10:35pm
or is there no other situation in which it could start with a bracket?
My assumption is that there isn't - unless you know different! Because of the way labels were shoehorned in you get inconsistencies like this:
Code:
PRINT "Hello "; : (ignored) PRINT "world!"
The 'label' is completely ignored (apart from a slight execution-time penalty); it can't be used as the destination of a GOTO because it's not at the start of a line. Effectively it's like a mid-line comment!
Richard.
Re: Tutorial for BBC BASIC
Post by Wendell on Mar 21st, 2014, 11:01pm
That information was so valuable to me. My grandkids and i finish the project "Tenmads Math Quiz" Thanks to you and the others Wendell