0

I'm working on Catia Automation.

The scenario is that whenever a particular licence is not available, a message pops out saying no licences are available and displays a partial list of users using the licence.

Is there any way in which the message can be read through code and used as a string?

agua from mars
  • 16,428
  • 4
  • 61
  • 70
  • Yes it is possible to get message value from the message object. Could you post some sample code that your might have written. – vcp Mar 14 '16 at 02:19

2 Answers2

0

From official documentation "CAA V5 Automation Coding Rules":

As a default behavior the interpreter will stop and display an error message box whenever an error is raised. When you want to take corrective actions on an error, disabling the automatic error handing mechanism using "On Error Resume Next" becomes mandatory.

That means you should disable default error handling and instead write a custom logic using error object Err.

Dim CATIA As Object
On Error Resume Next      ' Disable automatic error handling
    Set CATIA=GetObject(,"CATIA.Application")
    iErr = Err.Number     ' For BasicScript parser (Unix)
    If (iErr <> 0) Then   ' Manually handle all errors
       On Error Goto 0    ' Invalidates the Resume Next and clears the error
        set CATIA=CreateObject("CATIA.Application")
    End If
On Error Goto 0           ' Invalidates the Resume Next and clears the error
vcp
  • 962
  • 7
  • 15
0

Err is the error object that holds information about the error.

you can use Err.Message, Err.description, Err.number to get the information

Sub yoursub
On Error goto error      ' goto error handling block
    Set CATIA=GetObject(,"CATIA.Application")

    // your code 

error:
Debug.print Err.Description  ' print description to immediate window
Debug.print Err.Source       ' print source of error to immediate window
Debug.print Err.Number       ' print error number to immediate window
End Sub
Sree Harsha
  • 108
  • 6