Home
JAQForum Ver 24.01
Log In or Join  
Active Topics
Local Time 11:15 01 Aug 2025 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 : ON ERROR SKIP examples

Author Message
TassyJim

Guru

Joined: 07/08/2011
Location: Australia
Posts: 6283
Posted: 07:21am 19 Aug 2023
Copy link to clipboard 
Print this post

 '
 ON ERROR SKIP 1
 x = k/0
 y = g/0
 z = g/0

As expected, the first divide by zero is skipped and the second line throws an error.

 '
 ON ERROR SKIP 1
 x = k/0 : y = g/0
 z = g/0

Only the first statement on the line is counted when 'skipping'
The second statement after the : will cause an error condition.

 '
 t$ = "999"
 ON ERROR SKIP 1
 x = VAL(t$)/0
 y = g/0
 z = g/0

With builtin functions, the whole statement is treated as one.
The first error trapped is on the following line
(This may not be true for all built-in functions or complex lines.)

 '
 t$ = "999"
 ON ERROR SKIP 1
 x = myval(t$)/0
 y = g/0
 z = g/0
 
FUNCTION myval(txt$)
 myval = VAL(txt$)
END FUNCTION

With user functions, the call to the function is (more than) one statement  hence the error on that line. The example uses up 3 'skip' statements on the one line.
Edited 2023-08-19 17:22 by TassyJim
VK7JH
MMedit
 
CaptainBoing

Guru

Joined: 07/09/2016
Location: United Kingdom
Posts: 2170
Posted: 08:55am 19 Aug 2023
Copy link to clipboard 
Print this post

nice concise write-up.

note also that


ON ERROR SKIP 1 ' CATCH ZERO DIVIDE
X=1/0


won't work as you might expect - I think this is probably because ' is treated as REM whic is a statement and so the only 1 command skipped
 
Mixtel90

Guru

Joined: 05/10/2019
Location: United Kingdom
Posts: 7937
Posted: 09:10am 19 Aug 2023
Copy link to clipboard 
Print this post

Also, ON ERROR SKIP is the same as ON ERROR SKIP 1 as the skip count value is optional and defaults to 1.
Mick

Zilog Inside! nascom.info for Nascom & Gemini
Preliminary MMBasic docs & my PCB designs
 
TassyJim

Guru

Joined: 07/08/2011
Location: Australia
Posts: 6283
Posted: 09:52am 19 Aug 2023
Copy link to clipboard 
Print this post

  CaptainBoing said  nice concise write-up.

note also that


ON ERROR SKIP 1 ' CATCH ZERO DIVIDE
X=1/0


won't work as you might expect - I think this is probably because ' is treated as REM whic is a statement and so the only 1 command skipped


It works as expected on the picomite (and MMB4W) - rems are ignored.

'
ON ERROR SKIP 1
' test
x = k/0
y = g/0
z = g/0


'
ON ERROR SKIP 1 ' test
x = k/0
y = g/0
z = g/0



both the above ignore the remarks

Jim
VK7JH
MMedit
 
Print this page


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

The Back Shed's forum code is written, and hosted, in Australia.
© JAQ Software 2025