Catch Method similar to VBA

Jouher_20929
Jouher_20929 Altair Community Member
edited October 2020 in Community Q&A

In VBA, we have lot of error handling say like:

On Error GoTo ErrorMsg

          --> Code

Done: 

   Exit Function

Error Msg;

  - do in error case

 

 

I sthere any similar way in TCL??

 

 

Answers

  • Mario_21478
    Mario_21478 Altair Community Member
    edited December 2019

    Hello,

     

    Most commands supporting the catch error handling.

     

    if { [ catch {command_name...} ] } {

         # Handle error

    }

     

    e.g. error handling if already a panel is open, it is not allowed in HW to stack panels:

     

                if { [catch {*createmarkpanel lines 1 'Select first line ...'}] } {
                    set Info01Label 'Warning: Can't Stack Panels'
                    update
                    return
                }

     

    Best Regards,

    Mario