8 Replies Latest reply: Jun 19, 2013 12:59 AM by WE RSS

    On Error Programming

    ptc-5152170 Copper

      Hey

       

       

      I'm kinda new to Mathcad, but it works ;D
      Now I'm wondering if there is any possibility to use "on error" programming. (see attachement)

       

       

      I want to return "1" if the match function found at least one zero element in a collumn of the given and "0" if not.
      "0" won't work because of the error message by Matchcad.


      The example is in German, so here the commands in English:

      vergleich(z,A) = match(z,A)

      And my own procedure: istNullVorhanden="isAnyZeroElement"

       

      I use Mathcad 15. I also try to find a clue in previous community entries, but I only found the statement that "on error" programming is a way for the match() function.

       

      Thank you for every help ♥

        • Re: On Error Programming
          AlanStevens Platinum

          Like so:

           

          match.PNG

          Alan

          • Re: On Error Programming
            WE Platinum

            In the future please attach the Mathcad worksheet, not just a pic.

             

            You are right, you will need the "on error" construct as match will  throw an error in case it does not find a match.

             

            One possible way

            Nullen.png

            Another way would be to do without match and simply compare the product of the vector elements against zero - see attached.

            A more natural way would be to write ones own count() routine.

            • Re: On Error Programming
              ptc-5152170 Copper

              Thank you so much you two! ^.^

              AlanStevens' answer help atm but thank you Werner for your annotations! I think I can use them later.

               

              Well, but after I read "on error" and searched for it in Mathcad (programming window) I was little ashamed... I didn't noticed that there was "on error" function already displayed before... Sorry guys!

              Actually I'm not a fan of "programming by clicking" everything together, but there is no other opportunity,isn't it? :/

                • Re: On Error Programming
                  WE Platinum

                  Actually I'm not a fan of "programming by clicking" everything together, but there is no other opportunity,isn't it? :/

                  You cannot just type in those tokens, only alternative to clicking is the use of the keyboard shortcuts. But be aware that in the localized version they do not all work as stated in the help or tooltip. E.g. "on error" is not Ctrl+' but Ctrl+ä in the German version, or better said with a German keyboord layout.

                    • Re: On Error Programming
                      ptc-5152170 Copper

                      E.g. "on error" is not Ctrl+' but Ctrl+ä in the German version, or better said with a German keyboord layout.

                       

                      Yup, I noticed that.

                      So I rather will just click. But you accustom yourself to it in time I think.