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: AustraliaPosts: 6100 |
' 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 MMBasic Help |
||||
CaptainBoing Guru Joined: 07/09/2016 Location: United KingdomPosts: 2076 |
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 KingdomPosts: 6798 |
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: AustraliaPosts: 6100 |
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 MMBasic Help |
||||
Print this page |