Home
JAQForum Ver 20.06
Log In or Join  
Active Topics
Local Time 18:55 16 May 2024 Privacy Policy
Jump to

Notice. New forum software under development. It's going to miss a few functions and look a bit ugly for a while, but I'm working on it full time now as the old forum was too unstable. Couple days, all good. If you notice any issues, please contact me.

Forum Index : Microcontroller and PC projects : error with "on error skip"

Author Message
robert.rozee
Guru

Joined: 31/12/2012
Location: New Zealand
Posts: 2294
Posted: 04:05am 29 Jan 2017
Copy link to clipboard 
Print this post

i believe the following two pieces of code should work - they don't:

On error skip
For I = 1 To 28
SetPin I, DOUT
Print "pin " I " configured"
Next I

> run
[3] SetPin I, DOUT
Error: Pin 1 is invalid
>

and

On error ignore
For I = 1 To 28
SetPin I, DOUT
Print "pin " I " configured"
Next I

> run
pin 0 configured
>


cheers,
rob :-)
 
robert.rozee
Guru

Joined: 31/12/2012
Location: New Zealand
Posts: 2294
Posted: 04:24am 29 Jan 2017
Copy link to clipboard 
Print this post

looks like part of the problem is that RAM is being cleared after the error occurs:

On error ignore

A$="some text"
Memory
SetPin 1, DOUT
Print"----------------"
Memory

> run
Flash:
1K ( 1%) Program (7 lines)
59K (99%) Free

RAM:
1K ( 1%) 1 Variable
0K ( 0%) General
49K (99%) Free
----------------
Flash:
1K ( 1%) Program (7 lines)
59K (99%) Free

RAM:
0K ( 0%) 0 Variables
0K ( 0%) General
50K (100%) Free
>


cheers,
rob :-)
 
robert.rozee
Guru

Joined: 31/12/2012
Location: New Zealand
Posts: 2294
Posted: 04:29am 29 Jan 2017
Copy link to clipboard 
Print this post

looks like my use of ON ERROR SKIP was incorrect. correcting the use (placing it just before the SETPIN line) reveals the same problem as with IGNORE, in that RAM is cleared.

rob :-)
 
Grogster

Admin Group

Joined: 31/12/2012
Location: New Zealand
Posts: 9078
Posted: 11:08pm 29 Jan 2017
Copy link to clipboard 
Print this post

I am seeing this error too, whenever I try to use ON ERROR SKIP. Following the initial error, I also am not getting any response from mm.errmsg$:





MM.ERRMSG$ is suddenly "Invalid syntax", when it was perfectly valid BEFORE the on error skip error comes up. The MM.ERRNO value is also wrong, but Geoff knows about that one.

I'm using 5.03B10.
Smoke makes things work. When the smoke gets out, it stops!
 
JohnS
Guru

Joined: 18/11/2011
Location: United Kingdom
Posts: 3677
Posted: 12:14am 30 Jan 2017
Copy link to clipboard 
Print this post

Maybe the syntax changed to ON ERROR IGNORE

John
 
Grogster

Admin Group

Joined: 31/12/2012
Location: New Zealand
Posts: 9078
Posted: 01:21pm 30 Jan 2017
Copy link to clipboard 
Print this post

I need to correct the above - it was actually correct in terms of my asking MMBASIC in immediate mode(command prompt) what mm.errmsg$ was - it was indeed "Invalid syntax" - that was the error message last reported, so my asking for ? mm.errmsg$ and it reporting back "Invalid syntax." was actually correct in terms of the error message itself.

The message is wrong for the On Error Skip command, but the actual message text as held by mm.errmsg$ is correct, and asking to print that at the command prompt is actually the correct result for that command, if you see what I mean.....
Smoke makes things work. When the smoke gets out, it stops!
 
Grogster

Admin Group

Joined: 31/12/2012
Location: New Zealand
Posts: 9078
Posted: 01:52pm 30 Jan 2017
Copy link to clipboard 
Print this post

UPDATE:

On Error Skip MUST specify the number of lines to ignore errors in - see B10 manual, page 63. Although the manual says that if you DON'T specify a number, it will default to one, this causes the error.

If I use On Error Skip 1 for ignore any errors in the next line where I try to open the file, it works perfectly, and even the mm.errno number is also then correct - 6 - which is file not found, which is exactly right.

The bug would seem to be connected to On Error Skip if you DON'T specify a number to skip, and MMBASIC is supposed to ASSUME one, but does not, and this is upsetting it.

Rob - I would be extremely interested to hear from you if this also fixes your issue with the same command.
Smoke makes things work. When the smoke gets out, it stops!
 
robert.rozee
Guru

Joined: 31/12/2012
Location: New Zealand
Posts: 2294
Posted: 02:10pm 30 Jan 2017
Copy link to clipboard 
Print this post

nope, still fails:

For I = 1 To 28
On error skip 1
SetPin I, DOUT
Print "pin " I " configured"
Next I

> run
pin 0 configured
[5] Next I
Error: Cannot find a matching FOR
>


the problem is that when the error occurs, all variables, etc are lost. in the above example I reverts to zero and the for loop stack is cleared.


cheers,
rob :-)
 
Grogster

Admin Group

Joined: 31/12/2012
Location: New Zealand
Posts: 9078
Posted: 02:19pm 30 Jan 2017
Copy link to clipboard 
Print this post

What version of MMBASIC are you using, Rob? B10 I guess?
Smoke makes things work. When the smoke gets out, it stops!
 
Geoffg

Guru

Joined: 06/06/2011
Location: Australia
Posts: 3167
Posted: 02:55pm 30 Jan 2017
Copy link to clipboard 
Print this post

I think that we have two bugs here and hopefully I have hunted both of them down.

The first - clearing all variables. When the error occurs in a subroutine the ERROR SKIP or IGNORE works OK but if it happens in the main program the variable table will be cleared (thanks Rob for finding that one).

The second - working with files. If the error occurs when accessing the SD card on the MM+ the MM.ERRNO and MM.ERRMSG$ variables got confused (thanks Grogster for finding that one).

I have fixed both of these in the final version of 5.3 (due out in a day or two).

Geoff
Geoff Graham - http://geoffg.net
 
robert.rozee
Guru

Joined: 31/12/2012
Location: New Zealand
Posts: 2294
Posted: 10:19pm 30 Jan 2017
Copy link to clipboard 
Print this post

excellent news, although there are (currently) even problems if used in a subroutine:

foobar
End

Sub foobar
On error ignore
For I = 1 To 28
SetPin I, DOUT
Print "pin " I " configured"
Next I
End Sub

> run
pin 1 configured
>


also, if I is declared with LOCAL it is cleared.


cheers,
rob :-)
 
Print this page


To reply to this topic, you need to log in.

© JAQ Software 2024