error collection with try or catch
+ Reply to Thread
Results 1 to 8 of 8
  1. #1
    Join Date
    Sep 2017
    Posts
    25

    Default error collection with try or catch

    Within PBP3.0 is there any type of error collection like with a try or catch type statement?

    Thanks
    George

  2. #2
    Join Date
    Mar 2003
    Location
    Commerce Michigan USA
    Posts
    1,190

    Default Re: error collection with try or catch

    What do you mean by "Try or Catch"?
    Dave Purola,
    N8NTA
    EN82fn

  3. #3

    Default Re: error collection with try or catch

    From a PC compiler
    A structured method of trapping and responding to run-time errors.

    Statements in the TRY section are executed normally. The first time a run-time error occurs, control is transferred to the CATCH section. If no run-time errors are generated in the TRY section, the CATCH section is skipped entirely.
    Fairly safe to say this compiler (and every other compiler in its class) does not detect run time errors, the answer is no. Indeed what would be the point of detecting run time errors without a mechanism, like stdout, to report them?
    George

  4. #4
    Join Date
    Oct 2005
    Location
    Sweden
    Posts
    3,258

    Default Re: error collection with try or catch

    Not all errors have to be reported to the user via a console, certainly not in a small embedded system. But yeah, I believe something like TRY/CATCH is more for programs running on top of an underlying OS (which can also raise exceptions).

    What I "usually" do is to have various subroutines etc generate a RESULT or STATUS variable. If the content of that variable is '0' when returning then whatever else that particular subroutine was suposed to do was done without error(s), anything but '0' means something went wrong (1=slave does not respond, 2=CRC error, 3=unexpected return value etc), something like that.

    /Henrik.

  5. #5

    Default Re: error collection with try or catch

    I'm not saying you can't adopt a personal errror reporting system to suit your hardware, my point is that the compiler has no certain way to report errors.
    George

  6. #6
    Join Date
    Sep 2009
    Posts
    768

    Default Re: error collection with try or catch

    Because there is no error to occur. Divide by 0, and over flow are only two error that can occur. And with single line IF THEN can be prevented/detected.

  7. #7
    Join Date
    Sep 2017
    Posts
    25

    Default Re: error collection with try or catch

    The main reason I am asking is because I am currently working to port over java code written for an older uController by Parallax called the Javelin and it supported a try/catch error handling which was useful in the event of a divide by zero, overflow etc which would otherwise cause execution to halt.

    I was just curious of there was something that I may have missed.

  8. #8
    Join Date
    Sep 2009
    Posts
    768

    Default Re: error collection with try or catch

    If divider=0 will solve problem. If you divide by 0 nothing bad will happen in PBP, also on over flow. I use overflow all the time... Eg to create cnt 0-255, you need i=i+1...
    Also you can detect overflow of multiplication
    Code:
    R=A*B
    IF R <  A or R  < B Then...
    Also to calculate checksum
    Code:
    for i
    sum=sum+Array[i]
    next
    Arow broke forum
    Code:
    R=A*B
    IF R
    
    Last edited by pedja089; - 4th April 2019 at 09:19.

Similar Threads

  1. ERROR line 90: Sintax error----> [TabIndex]
    By martintorres in forum mel PIC BASIC Pro
    Replies: 7
    Last Post: - 9th September 2012, 04:29
  2. Replies: 1
    Last Post: - 30th March 2012, 04:13
  3. Compile error & syntax error on the word "loop:" as a label?
    By jellis00 in forum mel PIC BASIC Pro
    Replies: 4
    Last Post: - 7th March 2010, 04:14
  4. Too many error !!
    By Johan in forum mel PIC BASIC Pro
    Replies: 2
    Last Post: - 30th June 2007, 14:33
  5. Error!
    By fowardbias in forum Off Topic
    Replies: 0
    Last Post: - 28th February 2006, 02:08

Members who have read this thread : 18

You do not have permission to view the list of names.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts