Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. The Lounge
  3. ON ERROR RESUME NEXT

ON ERROR RESUME NEXT

Scheduled Pinned Locked Moved The Lounge
45 Posts 27 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • R Richard Deeming

    Not quite - the modern version would require wrapping every single statement in its own "Pokémon exception-handling" block. Which would mean splitting all variable declarations from their assignments, since a variable declared inside a try block can't be used outside of that block. Which would also mean giving every variable some sort of default value, either when they're declared, or in the empty catch block for the first line that assigns them. And don't forget to update the properties of the global Err object, in case the user gave any thought to checking for errors on the following line, and didn't just let their code trundle on regardless and destroy the program state / database / computer / world. Having worked with VBScript many years ago, where this was the only form of error handling allowed, it's an horrendous construct. Whoever came up with the idea deserves a good beating with the clue-bat.


    "These people looked deep within my soul and assigned me a number based on the order in which I joined." - Homer

    M Offline
    M Offline
    Mark_Wallace
    wrote on last edited by
    #24

    Richard Deeming wrote:

    he modern version would require wrapping every single statement in its own "Pokémon exception-handling" block. Which would mean splitting all variable declarations from their assignments, since a variable declared inside a try block can't be used outside of that block. Which would also mean giving every variable some sort of default value, either when they're declared, or in the empty catch block for the first line that assigns them. And don't forget to update the properties of the global Err object, in case the user gave any thought to checking for errors on the following line, and didn't just let their code trundle on regardless and destroy the program state / database / computer / world

    Ah! Now I understand why you love VB so much!

    I wanna be a eunuchs developer! Pass me a bread knife!

    1 Reply Last reply
    0
    • R Richard Deeming

      The only way to use On Error Resume Next properly is to never use it. :)


      "These people looked deep within my soul and assigned me a number based on the order in which I joined." - Homer

      M Offline
      M Offline
      Mark_Wallace
      wrote on last edited by
      #25

      Not the best War Games paraphrase I've ever seen, but it'll do.

      I wanna be a eunuchs developer! Pass me a bread knife!

      1 Reply Last reply
      0
      • N Nagy Vilmos

        Just about any COBOL will fit that, `ADD 1 TO COUNT` for instance.

        veni bibi saltavi

        M Offline
        M Offline
        Mark_Wallace
        wrote on last edited by
        #26

        Well, PERFORM sthg VARYING FROM 1 BY 1 UNTIL COUNT > 5 could do with a little work, but your point is still 90% valid.

        I wanna be a eunuchs developer! Pass me a bread knife!

        1 Reply Last reply
        0
        • R Ryan Peden

          I like INTERCAL's ABSTAIN. You get statements like:

          PLEASE ABSTAIN FROM CALCULATING

          Also, to exit the program, you use:

          PLEASE GIVE UP

          The PLEASE is optional. If you don't use it enough, through, the compiler will reject your program for not being polite enough. You do have to be careful with it: using PLEASE too often will get your program rejected for excessive politeness.

          M Offline
          M Offline
          Mark_Wallace
          wrote on last edited by
          #27

          Does it have private and public statements, too? e.g:

          PRIVATE PLEASE SHAKE_IT_BABY

          I wanna be a eunuchs developer! Pass me a bread knife!

          1 Reply Last reply
          0
          • D DaveAuld

            For some reason, that just popped into my head.......I wasn't even looking at anything code related, was watching the "Couch Commander" video :laugh: Anyway, the question is are there any other "statements" such as the one in the subject' in any other programming language that so eloquently and succinctly tell you exactly what it's doing.......? The more obscure the language the better. And if anyone says this is a programming question, which it is, but it's not, will get a skelped dock!

            Dave Find Me On:Web|Youtube|Facebook|Twitter|LinkedIn Folding Stats: Team CodeProject

            R Offline
            R Offline
            Ryan Peden
            wrote on last edited by
            #28

            Common Lisp's loop macro can be pretty interesting. It lets you do things like:

            (loop for i in *random*
            counting (evenp i) into evens
            counting (oddp i) into odds
            summing i into total
            maximizing i into max
            minimizing i into min
            finally (return (list min max total evens odds)))

            1 Reply Last reply
            0
            • D DaveAuld

              For some reason, that just popped into my head.......I wasn't even looking at anything code related, was watching the "Couch Commander" video :laugh: Anyway, the question is are there any other "statements" such as the one in the subject' in any other programming language that so eloquently and succinctly tell you exactly what it's doing.......? The more obscure the language the better. And if anyone says this is a programming question, which it is, but it's not, will get a skelped dock!

              Dave Find Me On:Web|Youtube|Facebook|Twitter|LinkedIn Folding Stats: Team CodeProject

              M Offline
              M Offline
              Mycroft Holmes
              wrote on last edited by
              #29

              Bloody hell, nobody mentioned GOTO or even GOSUB. It may not be error handling bit it was/is almost as abused as RESUME NEXT. There were some doozies in the Lotus 123 macro language as well but I can't remember them. And did you ever look under the hood of early Lotus Notes, now there was a whole collection of nightmares!

              Never underestimate the power of human stupidity RAH

              1 Reply Last reply
              0
              • D DaveAuld

                For some reason, that just popped into my head.......I wasn't even looking at anything code related, was watching the "Couch Commander" video :laugh: Anyway, the question is are there any other "statements" such as the one in the subject' in any other programming language that so eloquently and succinctly tell you exactly what it's doing.......? The more obscure the language the better. And if anyone says this is a programming question, which it is, but it's not, will get a skelped dock!

                Dave Find Me On:Web|Youtube|Facebook|Twitter|LinkedIn Folding Stats: Team CodeProject

                S Offline
                S Offline
                stoneyowl2
                wrote on last edited by
                #30

                I actually used the MUMPS language when I did a contract for the VA. No reserved word, since everything was by context: This was actually legal MUMPS code, since all things could be shortened to the first letter: GREPTHIS() N S,N,T,I,K,Q S I="K",S="11",K="l1",Q="R",T="K" I I=T D T Q:$Q Q Q T I I,S&K S S=S+K Q The full blown statements weren't much better: GREPTHIS() NEW SET,NEW,THEN,IF,KILL,QUIT SET IF="KILL",SET="11",KILL="l1",QUIT="RETURN",THEN="KILL" IF IF=THEN DO THEN QUIT:$QUIT QUIT QUIT ; (quit) THEN IF IF,SET&KILL SET SET=SET+KILL QUIT Just to put history behind it, MUMPS was the "Massachusetts General Hospital Utility Multi-Programming System", and (colloquially) was designed by doctors.

                1 Reply Last reply
                0
                • D den2k88

                  PLEASE NO!! Don't ever utter tha line ever agian, make it forgotten from the whole world. The damages and catastrophes caused by that line are uncountable!

                  GCS d--- s-/++ a- C++++ U+++ P- L- E-- W++ N++ o+ K- w+++ O? M-- V? PS+ PE- Y+ PGP t++ 5? X R++ tv-- b+ DI+++ D++ G e++>+++ h--- ++>+++ y+++*      Weapons extension: ma- k++ F+2 X If you think 'goto' is evil, try writing an Assembly program without JMP. -- TNCaver When I was six, there were no ones and zeroes - only zeroes. And not all of them worked. -- Ravi Bhavnani

                  Sander RosselS Offline
                  Sander RosselS Offline
                  Sander Rossel
                  wrote on last edited by
                  #31

                  Like catch (Exception) {} ? I pretty much like my catches, so I'll keep using those thank you :) If I couldn't use lines of code, functions, or libraries whose usage has made me cringe in the past I should really find another job. I've seen things :sigh:

                  Read my (free) ebook Object-Oriented Programming in C# Succinctly. Visit my blog at Sander's bits - Writing the code you need. Or read my articles here on CodeProject.

                  Simplicity is prerequisite for reliability. — Edsger W. Dijkstra

                  Regards, Sander

                  D S 2 Replies Last reply
                  0
                  • Sander RosselS Sander Rossel

                    Like catch (Exception) {} ? I pretty much like my catches, so I'll keep using those thank you :) If I couldn't use lines of code, functions, or libraries whose usage has made me cringe in the past I should really find another job. I've seen things :sigh:

                    Read my (free) ebook Object-Oriented Programming in C# Succinctly. Visit my blog at Sander's bits - Writing the code you need. Or read my articles here on CodeProject.

                    Simplicity is prerequisite for reliability. — Edsger W. Dijkstra

                    Regards, Sander

                    D Offline
                    D Offline
                    den2k88
                    wrote on last edited by
                    #32

                    It dones't mean they don't have to be used - I use this one too (Yes, I still work with VB6) - but it would be way better to forget them at all. The problems caused by those lines after years they have been developed... basically unfindable bugs because the sucker acts like there is no problem at all. Add this to the fact that the runtimes throws exceptions like candies instead of returning a status value and you have to manage exceptions for perfectly reasonable beahviours, like opening a non existing file. It can happen, it's usually no big deRUNTIME ERROR! CLOSE THE HATCHES! PREPARE FOR IMMERSION NOW!!! So many times you simply stick to On Error Resume Next and then problems arise, after years of seemingly fine running. It's like having a bazooka for home defence. Effective it is, useful also, but it's farking dangerous.

                    GCS d--- s-/++ a- C++++ U+++ P- L- E-- W++ N++ o+ K- w+++ O? M-- V? PS+ PE- Y+ PGP t++ 5? X R++ tv-- b+ DI+++ D++ G e++>+++ h--- ++>+++ y+++*      Weapons extension: ma- k++ F+2 X If you think 'goto' is evil, try writing an Assembly program without JMP. -- TNCaver When I was six, there were no ones and zeroes - only zeroes. And not all of them worked. -- Ravi Bhavnani

                    Sander RosselS 1 Reply Last reply
                    0
                    • D den2k88

                      It dones't mean they don't have to be used - I use this one too (Yes, I still work with VB6) - but it would be way better to forget them at all. The problems caused by those lines after years they have been developed... basically unfindable bugs because the sucker acts like there is no problem at all. Add this to the fact that the runtimes throws exceptions like candies instead of returning a status value and you have to manage exceptions for perfectly reasonable beahviours, like opening a non existing file. It can happen, it's usually no big deRUNTIME ERROR! CLOSE THE HATCHES! PREPARE FOR IMMERSION NOW!!! So many times you simply stick to On Error Resume Next and then problems arise, after years of seemingly fine running. It's like having a bazooka for home defence. Effective it is, useful also, but it's farking dangerous.

                      GCS d--- s-/++ a- C++++ U+++ P- L- E-- W++ N++ o+ K- w+++ O? M-- V? PS+ PE- Y+ PGP t++ 5? X R++ tv-- b+ DI+++ D++ G e++>+++ h--- ++>+++ y+++*      Weapons extension: ma- k++ F+2 X If you think 'goto' is evil, try writing an Assembly program without JMP. -- TNCaver When I was six, there were no ones and zeroes - only zeroes. And not all of them worked. -- Ravi Bhavnani

                      Sander RosselS Offline
                      Sander RosselS Offline
                      Sander Rossel
                      wrote on last edited by
                      #33

                      Most TrySomething (like TryParse) methods swallow exceptions if you don't check for the return value. The if-statement can be just as harmful. Take those huge nested if-else branches. Impossible to test, impossible to change (without breaking everything). So we replace the if-statements with switch/case-statements, same thing happens. We need to loop through some collection, but it's kind of recursive, and now some programmer uses foreach foreach foreach... (yeah, I've seen it happen). In SQL Server when an exception occurs it's more or less swallowed UNLESS you use try-catch (how many programmers know that?). So I now shouldn't use catch, TryParse, if, switch/case, foreach, and SQL Server :) Well, I agree ON ERROR RESUME NEXT is the most useless of them all :)

                      Read my (free) ebook Object-Oriented Programming in C# Succinctly. Visit my blog at Sander's bits - Writing the code you need. Or read my articles here on CodeProject.

                      Simplicity is prerequisite for reliability. — Edsger W. Dijkstra

                      Regards, Sander

                      D O 2 Replies Last reply
                      0
                      • Sander RosselS Sander Rossel

                        Most TrySomething (like TryParse) methods swallow exceptions if you don't check for the return value. The if-statement can be just as harmful. Take those huge nested if-else branches. Impossible to test, impossible to change (without breaking everything). So we replace the if-statements with switch/case-statements, same thing happens. We need to loop through some collection, but it's kind of recursive, and now some programmer uses foreach foreach foreach... (yeah, I've seen it happen). In SQL Server when an exception occurs it's more or less swallowed UNLESS you use try-catch (how many programmers know that?). So I now shouldn't use catch, TryParse, if, switch/case, foreach, and SQL Server :) Well, I agree ON ERROR RESUME NEXT is the most useless of them all :)

                        Read my (free) ebook Object-Oriented Programming in C# Succinctly. Visit my blog at Sander's bits - Writing the code you need. Or read my articles here on CodeProject.

                        Simplicity is prerequisite for reliability. — Edsger W. Dijkstra

                        Regards, Sander

                        D Offline
                        D Offline
                        den2k88
                        wrote on last edited by
                        #34

                        You're absolutely right about the huge nested ifs, I usually tend to modularize a lot and where multiple checks are involved I use a SEQUENCE of if and a cumulative status, so that it becomes

                        bool keep_going = true;
                        if (error_cond1) keep_going = false;
                        if (keep_going && error_cond2) keep_going = false;
                        ...

                        It's easier to read and modify, also it's not mandatory to have a single cumulative status. Since I work with stdcalls, VB6 and plain old C code on old compilers (long story short: we can't change.) I can't reliably use exceptions outside the deepest functions and being the VS6 stdlib what it is I don't really need them since it's better to stick to CRT functions, which don't have exceptions. Being VS6 CRT what it is many "safe" functions that use SEH exceptions do not exist so I don't use them either.

                        GCS d--- s-/++ a- C++++ U+++ P- L- E-- W++ N++ o+ K- w+++ O? M-- V? PS+ PE- Y+ PGP t++ 5? X R++ tv-- b+ DI+++ D++ G e++>+++ h--- ++>+++ y+++*      Weapons extension: ma- k++ F+2 X If you think 'goto' is evil, try writing an Assembly program without JMP. -- TNCaver When I was six, there were no ones and zeroes - only zeroes. And not all of them worked. -- Ravi Bhavnani

                        F 1 Reply Last reply
                        0
                        • D DaveAuld

                          For some reason, that just popped into my head.......I wasn't even looking at anything code related, was watching the "Couch Commander" video :laugh: Anyway, the question is are there any other "statements" such as the one in the subject' in any other programming language that so eloquently and succinctly tell you exactly what it's doing.......? The more obscure the language the better. And if anyone says this is a programming question, which it is, but it's not, will get a skelped dock!

                          Dave Find Me On:Web|Youtube|Facebook|Twitter|LinkedIn Folding Stats: Team CodeProject

                          R Offline
                          R Offline
                          Rob Grainger
                          wrote on last edited by
                          #35

                          I'd say the If..Then..Else statement is pretty clear, amongst many many others. If anything, your example is a little odd, as it really doesn't tell you what it is doing - resume next what? That's not English. (It's also an extremely dodgy technique of error handling, equivalent of enclosing every statement in:

                          Exception error;
                          try {
                          statement;
                          }
                          catch (Exception ex) {
                          error = ex;
                          }

                          Which just invites people not to bother checking the result. May as well have a statement like

                          On Error Keep Calm and Carry On

                          "If you don't fail at least 90 percent of the time, you're not aiming high enough." Alan Kay.

                          1 Reply Last reply
                          0
                          • D DaveAuld

                            For some reason, that just popped into my head.......I wasn't even looking at anything code related, was watching the "Couch Commander" video :laugh: Anyway, the question is are there any other "statements" such as the one in the subject' in any other programming language that so eloquently and succinctly tell you exactly what it's doing.......? The more obscure the language the better. And if anyone says this is a programming question, which it is, but it's not, will get a skelped dock!

                            Dave Find Me On:Web|Youtube|Facebook|Twitter|LinkedIn Folding Stats: Team CodeProject

                            J Offline
                            J Offline
                            Jirajha
                            wrote on last edited by
                            #36

                            I still love plain old C#.

                            foreach(var exception in MyExceptionCollection)
                            try
                            throw exception;
                            catch()
                            continue;

                            H 1 Reply Last reply
                            0
                            • J Jirajha

                              I still love plain old C#.

                              foreach(var exception in MyExceptionCollection)
                              try
                              throw exception;
                              catch()
                              continue;

                              H Offline
                              H Offline
                              Herbie Mountjoy
                              wrote on last edited by
                              #37

                              The best bit about PERL (in fact the only good bit) is On Error DIE Is that why PERL programmers are becoming scarce? We're philosophical about power outages here. A.C. come, A.C. go.

                              1 Reply Last reply
                              0
                              • D DaveAuld

                                For some reason, that just popped into my head.......I wasn't even looking at anything code related, was watching the "Couch Commander" video :laugh: Anyway, the question is are there any other "statements" such as the one in the subject' in any other programming language that so eloquently and succinctly tell you exactly what it's doing.......? The more obscure the language the better. And if anyone says this is a programming question, which it is, but it's not, will get a skelped dock!

                                Dave Find Me On:Web|Youtube|Facebook|Twitter|LinkedIn Folding Stats: Team CodeProject

                                J Offline
                                J Offline
                                Jim_Snyder
                                wrote on last edited by
                                #38

                                When I worked at CompuServe, a coworker wrote some code I was running a test harness on for connecting to the portal. His variable "IBHosed" showed up in the exception if the connection wasn't established.

                                1 Reply Last reply
                                0
                                • L Lost User

                                  The modern version;

                                  catch
                                  {
                                  // all
                                  }

                                  Bastard Programmer from Hell :suss: If you can't read my code, try converting it here[^][](X-Clacks-Overhead: GNU Terry Pratchett)

                                  L Offline
                                  L Offline
                                  Larry Gibson
                                  wrote on last edited by
                                  #39

                                  catch { // TODO: }

                                  J 1 Reply Last reply
                                  0
                                  • OriginalGriffO OriginalGriff

                                    The COBOL MOVE statement[^]

                                    MOVE 50 TO discountPercentage

                                    Bad command or file name. Bad, bad command! Sit! Stay! Staaaay...

                                    L Offline
                                    L Offline
                                    Lost User
                                    wrote on last edited by
                                    #40

                                    MOVE CORRESPONDING

                                    Still waiting for one of the "modern languages" to implement that one. (I have to resort to reflection in C#).

                                    1 Reply Last reply
                                    0
                                    • D den2k88

                                      You're absolutely right about the huge nested ifs, I usually tend to modularize a lot and where multiple checks are involved I use a SEQUENCE of if and a cumulative status, so that it becomes

                                      bool keep_going = true;
                                      if (error_cond1) keep_going = false;
                                      if (keep_going && error_cond2) keep_going = false;
                                      ...

                                      It's easier to read and modify, also it's not mandatory to have a single cumulative status. Since I work with stdcalls, VB6 and plain old C code on old compilers (long story short: we can't change.) I can't reliably use exceptions outside the deepest functions and being the VS6 stdlib what it is I don't really need them since it's better to stick to CRT functions, which don't have exceptions. Being VS6 CRT what it is many "safe" functions that use SEH exceptions do not exist so I don't use them either.

                                      GCS d--- s-/++ a- C++++ U+++ P- L- E-- W++ N++ o+ K- w+++ O? M-- V? PS+ PE- Y+ PGP t++ 5? X R++ tv-- b+ DI+++ D++ G e++>+++ h--- ++>+++ y+++*      Weapons extension: ma- k++ F+2 X If you think 'goto' is evil, try writing an Assembly program without JMP. -- TNCaver When I was six, there were no ones and zeroes - only zeroes. And not all of them worked. -- Ravi Bhavnani

                                      F Offline
                                      F Offline
                                      firegryphon
                                      wrote on last edited by
                                      #41

                                      I think you could also put in a "goto" instead of setting "keep_going" if you want to break up that nested if architecture. :cool::suss: ;P :laugh:

                                      1 Reply Last reply
                                      0
                                      • Sander RosselS Sander Rossel

                                        Like catch (Exception) {} ? I pretty much like my catches, so I'll keep using those thank you :) If I couldn't use lines of code, functions, or libraries whose usage has made me cringe in the past I should really find another job. I've seen things :sigh:

                                        Read my (free) ebook Object-Oriented Programming in C# Succinctly. Visit my blog at Sander's bits - Writing the code you need. Or read my articles here on CodeProject.

                                        Simplicity is prerequisite for reliability. — Edsger W. Dijkstra

                                        Regards, Sander

                                        S Offline
                                        S Offline
                                        SeattleC
                                        wrote on last edited by
                                        #42

                                        I think you need

                                        catch (void) {}

                                        At least in C++ you can throw any type, not just derivations of

                                        class Exception

                                        1 Reply Last reply
                                        0
                                        • L Larry Gibson

                                          catch { // TODO: }

                                          J Offline
                                          J Offline
                                          jediYL
                                          wrote on last edited by
                                          #43

                                          You've discovered infinite recursion :-D

                                          // TODO
                                          // catch {
                                          // // TODO
                                          // }
                                          

                                          Remain Calm & Continue To Google

                                          1 Reply Last reply
                                          0
                                          Reply
                                          • Reply as topic
                                          Log in to reply
                                          • Oldest to Newest
                                          • Newest to Oldest
                                          • Most Votes


                                          • Login

                                          • Don't have an account? Register

                                          • Login or register to search.
                                          • First post
                                            Last post
                                          0
                                          • Categories
                                          • Recent
                                          • Tags
                                          • Popular
                                          • World
                                          • Users
                                          • Groups