RobotStudio event

a question on error-handling in API

Hi,

for a target freshly created, the attempt to read the target's robotconfiguration property arises an "No configuration" error, and goes to my error-handling code. Is there any way to detect this so that it won't go to the errorr-handling code? I tried IsEmpty, and a few other Is.. functions in vB in vain.

Thank you very much.

John

Comments

  • Hi
    What you could do is something like this

    On Error Resume Next

    Dim t as Target
    Set t = ActiveStation.Targets("your target")
    if t.RobotConfiguration.Cf1 = null then
      ' Do the error handling
    End If

    Per Svensson
    Robotics and Vision Specialist
    Consat Engineering
  • Hi, thank you very much for your reply.

    I may not make myself understood. My code would be like this:

    On Error Goto HandleError

    ...

    If t.RobotConfiguration.cf1 = null Then

    ... do stuff ...

    Else 

    ... do other stuff ...

    End If

    ...

    HandleError:

    ... Error handling code ...

     

    When executing the "If t.RobotConfiguration.cf1 = null Then", it immediately goes to the error handling routine below. I have also tried " if IsNull(t.RobotConfiguration) then ", and the same thing happened.

    It looks like any reference to t.RobotConfiguration in any fashion leads to an error, while I am trying to find a API or VB function to acheive the logic structure similar to the above code. 

     

  • Hi
    The difference is that instead of jumping to the error handler you define that if there is an error you continue with the next instruction


    On Error Resume Next

    instead of

    On Error Goto HandleError

    You can also turn off or change how the error handler should behave during program execution.

    Per Svensson
    Robotics and Vision Specialist
    Consat Engineering
  • Got it. Thank you very much.