Shop OBEX P1 Docs P2 Docs Learn Events
Abort (able) method with a return value in SPIN — Parallax Forums

Abort (able) method with a return value in SPIN

mcstarmcstar Posts: 144
edited 2007-07-03 23:17 in Propeller 1
Is it possible to return a result value from a method that has been called with an abort trap?
IOW,
I have code like ...
·if NOT \recbyte
·· <code to display error etc>

where recbyte is a method that·can return a byte,· but it can also abort with a false... is it possible to get the result byte from recbyte into a variable under normal conditions,·but also have code like this handle the error condition?· What would be the syntax for this?

Would something like this work

·if NOT b := \recbyte

where b is a local variable?

Comments

  • rokickirokicki Posts: 1,000
    edited 2007-07-03 22:54
    Sure. The trick is, you need to make the abort return be a value that is "out of range". In this case (as in
    the fsrw stuff for SD support) I picked negative values as "out of range". So:

    if (byte := \recbyte) < 0
       display error
    
    



    Note I fixed a typo in the above code.

    Post Edited (rokicki) : 7/3/2007 11:25:00 PM GMT
  • mcstarmcstar Posts: 144
    edited 2007-07-03 23:17
    Ah, thanks!
Sign In or Register to comment.