BBC BASIC for Windows
« missing until or endif not noiced by BASIC. »

Welcome Guest. Please Login or Register.
Apr 5th, 2018, 9:52pm



ATTENTION MEMBERS: Conforums will be closing it doors and discontinuing its service on April 15, 2018.
Ad-Free has been deactivated. Outstanding Ad-Free credits will be reimbursed to respective payment methods.

If you require a dump of the post on your message board, please come to the support board and request it.


Thank you Conforums members.

BBC BASIC for Windows Resources
Online BBC BASIC for Windows documentation
BBC BASIC for Windows Beginners' Tutorial
BBC BASIC Home Page
BBC BASIC on Rosetta Code
BBC BASIC discussion group
BBC BASIC for Windows Programmers' Reference

« Previous Topic | Next Topic »
Pages: 1  Notify Send Topic Print
 thread  Author  Topic: missing until or endif not noiced by BASIC.  (Read 1028 times)
chrispc
New Member
Image


member is offline

Avatar




PM


Posts: 19
xx missing until or endif not noiced by BASIC.
« Thread started on: Feb 17th, 2015, 07:20am »

It has just dawned on me that if I forget to put in an UNTIL or an ENDIF at the end of section starting with REPEAT or IF, then the program does not give an error message. It would be one more little help for idiots like me if it did. I have just spent a long time looking for an error which turned out to be that I put REM in front of an UNTIL, so disabling it.
Any chance of that error message being added?
chrispc
User IP Logged

rtr2
Guest
xx Re: missing until or endif not noiced by BASIC.
« Reply #1 on: Feb 17th, 2015, 08:53am »

on Feb 17th, 2015, 07:20am, chrispc wrote:
Any chance of that error message being added?

Sorry, no. The reason no message is generated is that, as far as the interpreter is concerned, there was no error!

The basic issue here, as I expect you are aware, is that BBC BASIC is a traditional interpreter. The only error checking that it performs is at run time, so it will only report an error if something 'goes wrong' when the program is running.

Take the REPEAT..UNTIL loop. How is the interpreter supposed to 'know' that the UNTIL is missing? It doesn't 'look for' the UNTIL, it simply executes it when it finds it. So the absence of an UNTIL isn't a condition the interpreter is aware of!

The missing ENDIF is a slightly different case. There is a situation in which the interpreter 'looks for' the ENDIF, and that is if the condition is false. In that case it will indeed report a 'Missing ENDIF'. Try running this single-line program:

Code:
      IF FALSE THEN 

But if the condition is true the interpreter has no need to 'look for' the ENDIF (unless an ELSE clause is present) so this program does not report an error, because nothing 'goes wrong':

Code:
      IF TRUE THEN 

The trouble is, of course, that an error like a missing UNTIL or a missing ENDIF may be obvious to you, the programmer, so you think it ought to be obvious to the language too. In the case of a compiled language, or an interpreter that does 'off line' syntax checking, it might be. But to an interpreter that only checks things at run-time it isn't.

The practical solution is to keep an eye on the indentation of your program. If there is a missing ENDIF or a missing UNTIL the indentation at the end of your program will be greater than it was at the beginning! By scanning down the code to see where the indentation goes wrong you should be able to identify the region of the program with the problem.

Richard.
« Last Edit: Feb 17th, 2015, 1:28pm by rtr2 » User IP Logged

KenDown
Full Member
ImageImageImage


member is offline

Avatar




PM


Posts: 181
xx Re: missing until or endif not noiced by BASIC.
« Reply #2 on: Nov 15th, 2016, 5:59pm »

Coming in late on this topic: there are two situations with indents. One is as Richard indicates if there is a missing ENDIF or UNTIL, but the other is if there is a superfluous ENDIF, UNTIL, NEXT, ENDWHILE etc.

You discover the problem when you notice - if you notice! - that loops etc after the unwanted end statement are no longer indented, or only indented with nested statements.

The only thing to do is start at the beginning of your program and work down until you spot a loop that isn't indented and then look before it for the problem.
User IP Logged

Pages: 1  Notify Send Topic Print
« Previous Topic | Next Topic »

| |

This forum powered for FREE by Conforums ©
Terms of Service | Privacy Policy | Conforums Support | Parental Controls