print NXOpen.Update.ErrorList into listing window

Hello,

I'm writing my first script using visual basics and running it as a journal.

The script basically changes expressions for the model and exports a parasolid.

During the loop, some work some don't.

I have a try and catch so if there is an error it will just jump to the next loop

Catch ex As NXException
lw.WriteLine("*** ERROR RUNNING MAIN LOOP***")
lw.WriteLine("Error Message: " & ex.Message)

gives me the error undo session on update.

How can I show the errors on the listing window using the .Update.ErrorList
I'm new to visual basic, can't really figure out what to do, how to call the list and print every element of that list.

Thanks
Kiko

Once you have a reference to an error list, you can loop through the list and write them to the listing window like this:




For i As Integer = 0 To myErrList.Length - 1
lw.WriteLine("Error number: " & i.ToString)
lw.WriteLine(" " & myErrList.GetErrorInfo(i).ErrorCode & ": " & myErrList.GetErrorInfo(i).Description)
lw.WriteLine("")
Next

Thanks, I tried it but can't make it work, have an error saying "GetErrorInfo" is not a member of system.array.

This is my code:

Catch ex As NXException
lw.WriteLine("*** ERROR RUNNING MAIN LOOP***")
lw.WriteLine("Error Message: " & ex.Message)
'Exit Sub
Dim myErrList() As NXOpen.ErrorList
For i As Integer = 0 To myErrList.Length - 1
lw.WriteLine("Error number: " & i.ToString)
lw.WriteLine(" " & myErrList.GetErrorInfo(i).ErrorCode & ": " & myErrList.GetErrorInfo(i).Description)
lw.WriteLine("")
Next

I'm new to Visual Basic, always getting stuck at this system rules.
Thanks again

You've defined myErrList as an array of error lists; this isn't necessary, declare it as a normal variable.

change

Dim myErrList() As NXOpen.ErrorList

to the following:

Dim myErrList As NXOpen.ErrorList

i.e. get rid of the parentheses in the Dim statement.

Thanks, What an easy stupid mistake.

I'm getting another error, on the

For i As Integer = 0 To myErrList.Length - 1

Error message: System.NullReferebceException: Object reference not set to an instance of an object.

Really thanks for all your help,
Is helping me learn alot on this jornaling