Quick Quiz - View error checking

The following is not checking for errors correctly, where else should I perform an error check?
i.e. IF ErrorCode()

Open(MyView)
IF ErrorCode()
  Message('An error!')
END

MyView{PROP:Filter} = 'test'

Set(MyView)
LOOP
  Next(MyView)
  IF ErrorCode()
    BREAK
  END
END

Close(MyView)
IF ErrorCode()
  Message('An error!')
END

Not sure what you mean by not checking for errors correctly.

Things I see possibly wrong with the code:

  1. ‘Test’ is not a logical expression.
  2. If test is a variable containing a logical expression it is not BINDed
  3. PROP:Filter should come before the open(MyView)

It came up as an issue in my code today. Something was the results of my Set/Next to be not what I expected.

Looking at the database trace showed me what was wrong but it took me a little while to figure out why the code, similar to the above, was not giving me an error at runtime but instead failing quietly.

Oh, I am not sure about that one actually. I think that the filter only gets used when Set() is called but now I need to test!

EDIT: Actually, it doesn’t seem to matter if you do the Open() or the PROP:Filter first.

Brahn, I would use this to trap errors. Really there is only one errorcode after next where you just want to break.

Next(MyView)
IF ERRORCODE()
  IF ERRORCODE() <> BadRecErr
    MESSAGE('Error')
  END
  BREAK
END

Hey Rick,

Well…

Good point about being specific about the BadRecErr but that is not the one I was after. There is actually still one other place that you can (and need!) to check for error.

After setting Prop:Filter :smile:

1 Like

And we have a winner!!

If there is a bind error PROP:Filter will let you know but you have to look for it :smile:

Welcome to the Quiz Master club

http://clarionhub.com/badges/104/quiz-master-