🎉Community Raffle - Win $25

An exclusive raffle opportunity for active members like you! Complete your profile, answer questions and get your first accepted badge to enter the raffle.
Join and Win

Remove error

User: "Jouher_20929"
Altair Community Member
Updated by Jouher_20929

@tinh @Pandurang

I have option for selection of node (*createmarkpanel) followed by set of operations. If, i am not selecting any node, while execution of command, I want to exit from command instead of throwing errors. please help me to sort this out.

Find more posts tagged with

Sort by:
1 - 9 of 91
    User: "Imoto"
    Altair Employee
    Updated by Imoto

    Hi Jouher,

     

    *createmarkpanel nodes 1 'Please select nodes';
    if {[hm_marklength nodes 1] > 0} {
     *nodemarkaddtempmark 1;
    } else {
     tk_messageBox -message '0 nodes selected' -icon error;
    }

     

    Or You can use 'catch' command.

    https://www.tcl.tk/man/tcl8.4/TclCmd/catch.htm

     

    Thanks,

    Imoto

    User: "Jouher_20929"
    Altair Community Member
    OP
    Updated by Jouher_20929

    Thanks @Imoto ,

    But, If i select any node, then press esc it wont work. similarly for string too, if I type name and instead of proceed, if i press esc key, it will proceed further.

    Please help me to solve this too.

    User: "tinh"
    Altair Community Member
    Updated by tinh

    Hi Jouher,

    so you want : press ESC => will NOT proceed, don't you?

    I had the code

    User: "Jouher_20929"
    Altair Community Member
    OP
    Updated by Jouher_20929

    Hi Jouher,

    so you want : press ESC => will NOT proceed, don't you?

    I had the code

    Yes, @tinh

    User: "Imoto"
    Altair Employee
    Updated by Imoto

    Hi Jouher,

     

    You can add the bind for Escape key.

     

    proc ESCkeyClearAll {args} {
     hm_markclearall 1;
     hm_markclearall 2;
    }
    bind . <Escape> ESCkeyClearAll


    *createmarkpanel nodes 1 'Please select nodes';
    if {[hm_marklength nodes 1] > 0} {
     *nodemarkaddtempmark 1;
    } else {
     tk_messageBox -message '0 node selected' -icon error;
    }

     

    Thanks,
    Imoto

    User: "Jouher_20929"
    Altair Community Member
    OP
    Updated by Jouher_20929

    Hi Jouher,

     

    You can add the bind for Escape key.

     

    proc ESCkeyClearAll {args} {
     hm_markclearall 1;
     hm_markclearall 2;
    }
    bind . <Escape> ESCkeyClearAll


    *createmarkpanel nodes 1 'Please select nodes';
    if {[hm_marklength nodes 1] > 0} {
     *nodemarkaddtempmark 1;
    } else {
     tk_messageBox -message '0 node selected' -icon error;
    }

     

    Thanks,
    Imoto

    Its not working

    User: "tinh"
    Altair Community Member
    Updated by tinh

    Hi

    we should not bind a script to '.' toplevel, because it will trigger every widgets

    the main widget receives ESC key to exit panel is .hmContainer

    User: "Imoto"
    Altair Employee
    Updated by Imoto

    Thanks Tinh,

     

    bind .hmContainer <Escape> {hm_markclearall 1; hm_markclearall 2; hm_notifykeydown %N %k;}
    

    User: "tinh"
    Altair Community Member
    Updated by tinh

    I wrote a proc like this:

     

    proc p_SelectMark {EntityType MarkId args} {

            #this binding code can be set once at level #0, but i embed here, so this proc is working everytime

             if {![string match '*set ::v_PressEsc 1*' [bind .hmContainer <Key-Escape>]]} {

                    bind .hmContainer <Key-Escape> {+set ::v_PressEsc 1}

             }

             if {![hm_info functionlock]} {

                    set ::v_PressEsc 0

                   *createmarkpanel $EntityType $MarkId $args

                    if {$::v_PressEsc} {

                        *clearmark $EntityType $MarkId

                    }

                    hm_getmark $EntityType $MarkId

             }

    }