It is currently Tue May 30, 2017 3:57 am



Welcome
Welcome to rfobasic

You are currently viewing our boards as a guest, which gives you limited access to view most discussions and access our other features. By joining our free community, you will have access to post topics, communicate privately with other members (PM), respond to polls, upload content, and access many other special features. In addition, registered members also see less advertisements. Registration is fast, simple, and absolutely free, so please, join our community today. **You are not required to provide truthful information to any registration questions. Be whomever you wish to be.!


Post new topic Reply to topic  [ 18 posts ]  Go to page 1, 2  Next
Author Message
 Post subject: Line numbers in error messages
Unread postPosted: Mon Nov 28, 2016 12:47 am 
Offline

Joined: Wed Feb 20, 2013 3:25 pm
Posts: 423
Location: Italy
Hi,

Given that BASIC! is now used more and more with external editors (both on Android and PCs), it would be very useful if BASIC! error messages came with an indication of the source line number where the error occurred, in addition to a print of the code line itself (which is already given).

This would make it easier to navigate to the incriminated line on an external editor.

/ Luca

Example:

Syntax error
inputa$ [at line 13]


Last edited by luca_italy on Mon Nov 28, 2016 5:10 am, edited 1 time in total.

Report this post
Top
 Profile  
 
 Post subject: Re: Line numbers in error messages
Unread postPosted: Mon Nov 28, 2016 2:21 am 
Offline
User avatar

Joined: Mon Aug 18, 2014 1:16 pm
Posts: 1336
Nice idea Luca


Report this post
Top
 Profile  
 
 Post subject: Re: Line numbers in error messages
Unread postPosted: Mon Nov 28, 2016 4:13 am 
Offline

Joined: Tue Dec 04, 2012 10:50 am
Posts: 656
Location: UK
luca_italy wrote:
Hi,

Given that BASIC! is now used more and more with external editors (both on Android and PCs), it would be very useful if BASIC! error messages came with an indication of the source line number where the error occurred, in addition to a print of the code line itself (which is already given).

This would make it esaier to navigate to the incriminated line on an external editor.

/ Luca

Example:

Syntax error
inputa$ [at line 13]

Maybe it would be tricky if more than one source file involved (per library etc)...

To do it properly would need a stack of embedded source files and including the file name with the line number.

Mike.


Report this post
Top
 Profile  
 
 Post subject: Re: Line numbers in error messages
Unread postPosted: Mon Nov 28, 2016 5:12 am 
Offline

Joined: Wed Feb 20, 2013 3:25 pm
Posts: 423
Location: Italy
Yes true.

Then a more complete proposal could be this:

Syntax error
inputa$ [at line 13 of "test.bas"]

/ Luca


Report this post
Top
 Profile  
 
 Post subject: Re: Line numbers in error messages
Unread postPosted: Mon Nov 28, 2016 9:55 am 
Offline
User avatar

Joined: Thu Nov 24, 2016 8:26 pm
Posts: 49
Location: GA, USA
luca_italy wrote:
Yes true.

Then a more complete proposal could be this:

Syntax error
inputa$ [at line 13 of "test.bas"]

/ Luca

+1

I agree! Although new to RFO Basic, I already have several 'include' files and your proposal will make debugging a lot easier.

_________________
A good programmer is someone who always looks both ways before crossing a one-way street.


Report this post
Top
 Profile  
 
 Post subject: Re: Line numbers in error messages
Unread postPosted: Mon Nov 28, 2016 12:38 pm 
Offline
User avatar

Joined: Sun Nov 23, 2014 8:15 am
Posts: 2185
Location: romania
i think the interpreter does not know if a line comes from an 'include', because after the preprocessing all files are merged in a single list of instructions.


Report this post
Top
 Profile  
 
 Post subject: Re: Line numbers in error messages
Unread postPosted: Mon Nov 28, 2016 1:35 pm 
Offline
User avatar

Joined: Thu Nov 24, 2016 8:26 pm
Posts: 49
Location: GA, USA
That's too bad. If that is indeed the case, we'll have to live with it then, don't we? :lol:

_________________
A good programmer is someone who always looks both ways before crossing a one-way street.


Report this post
Top
 Profile  
 
 Post subject: Re: Line numbers in error messages
Unread postPosted: Mon Nov 28, 2016 3:04 pm 
Offline

Joined: Tue Dec 04, 2012 10:50 am
Posts: 656
Location: UK
gikam wrote:
i think the interpreter does not know if a line comes from an 'include', because after the preprocessing all files are merged in a single list of instructions.

But I think that the intermediate merged file is "private" and not seen by any user. So comments could be embedded to drive the stack mechanism I suggested. In effect preserving the "include" and adding matching end-markers. Not simple, though, is it!

Mike.


Report this post
Top
 Profile  
 
 Post subject: Re: Line numbers in error messages
Unread postPosted: Tue Nov 29, 2016 5:08 am 
Offline

Joined: Tue Dec 04, 2012 10:50 am
Posts: 656
Location: UK
mjcoon wrote:
gikam wrote:
i think the interpreter does not know if a line comes from an 'include', because after the preprocessing all files are merged in a single list of instructions.

But I think that the intermediate merged file is "private" and not seen by any user. So comments could be embedded to drive the stack mechanism I suggested. In effect preserving the "include" and adding matching end-markers. Not simple, though, is it!

Mike.

As soon as I had gone to bed I realised that since the interpreter is reading the intermediate file randomly (by following the program logic; so not serially, I mean!) every line in the file would have to be tagged with its file name and line number, just in case a fault report was needed. (Although some post-fault scanning could reconstruct the same information instead.) A bit of an overhead in the pre-processor and the file would be a bit bigger. Could still be worth it, though, perhaps as a debugging option...

Mike.


Report this post
Top
 Profile  
 
 Post subject: Re: Line numbers in error messages
Unread postPosted: Tue Nov 29, 2016 5:49 am 
Offline

Joined: Wed Feb 20, 2013 3:25 pm
Posts: 423
Location: Italy
Hi,

It would be very easy to create a small BASIC! script which takes a .bas as input and creates a debug version for it:

test.bas -> test_debug.bas

Comments cannot be used because they are removed.
The best way maybe would be this:

Code:
FOR a=1 to 10
  PRINT a
NEXT

becomes:
Code:
test001::FOR a=1 to 10
test002::  PRINT a
test003::NEXT


But I'm not 100% sure if all those labels in front can cause malfunctions in some control structures.
We should test.

The script should scan test.bas twice, 1st time to count the total number of lines (and so understand how many leading zeros to put in front -- they are needed to keep the code formatting), and a second time to actually produce the output file line by line.
The script should ask for two user inputs: program file to be scanned and label to be put in front of line numbers.

/ Luca


Report this post
Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 18 posts ]  Go to page 1, 2  Next


Who is online

Users browsing this forum: No registered users and 2 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
suspicion-preferred