🎉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

How to stop tcl script after warning message?

Hi everybody,

 

how can I stop a tcl script, after a warning message?

I have the following expression:

 

 

if {$outerdiameter > $innerdiameter}  {
} else  {
   tk_messageBox -message 'WARNING - Please check your input! \n
  Outer diameter = $outerdiainput mm \n
  Inner diameter = $innerdiainput mm' -type ok

}

 

outer- and innerdiameter are variables I defined earlier in my script.

 

Now I would like to stop the tcl script from working on, if the message box appears.

Or even better would be if it is possible to add some command that after the message box appears tcl moves back to a specified line in the script. Something like go to line 5.

 

thanks in advance!

Find more posts tagged with

Sort by:
1 - 4 of 41
    tinhUser: "tinh"
    Altair Community Member
    Updated by tinh

    To stop script, use tcl command 'return'

    to jump back a specified line: there is no command to jump but you can do a loop and check condition to break the loop, example

    while {$outerdiameter > $innerdiameter} {

          tk_messageBox -message 'WARNING - Please check your input! \n
      Outer diameter = $outerdiainput mm \n
      Inner diameter = $innerdiainput mm' -type ok

    set       outerdiameter [hm_getint outer]

    set       innerdiameter [hm_getint inner]

    }

    Hi tinh,

     

    the return command works fine!

    I tried the 'while' command too but nothing happens  :unsure:/emoticons/default_unsure.png' title=':unsure:' />

     

    example:

    set outerdiameter [ hm_getstring 'Outer diameter in mm']            --> My input is 10

    set innerdiameter [ hm_getstring 'Inner diameter in mm']            --> My input is 10.5

     

    while {$outerdiameter > $innerdiameter} {

          tk_messageBox -message 'WARNING - Please check your input! \n
      Outer diameter = $outerdiainput mm \n
      Inner diameter = $innerdiainput mm' -type ok 

    set       outerdiameter [hm_getint outer]

    set       innerdiameter [hm_getint inner]

    }

     

    Now I thought it will bring me back to my input dialog, because innerdiameter is bigger than outerdiameter ??? Am I doing something wrong?

     

    Thnaks in advance

     

     

    tinhUser: "tinh"
    Altair Community Member
    Updated by tinh

    Hi

    because 10>10.5 is FALL so body script of 'while' will not be evaluated

     

    you have to change 'while {$outerdiameter > $innerdiameter} {'

    to  'while {$outerdiameter < $innerdiameter} {'

    Hi

    because 10>10.5 is FALL so body script of 'while' will not be evaluated

     

    you have to change 'while {$outerdiameter > $innerdiameter} {'

    to  'while {$outerdiameter < $innerdiameter} {'

     

    Now it works perfectly!!!

    That's what I wanted to have in my tcl-file :D/emoticons/default_biggrin.png' srcset='/emoticons/biggrin@2x.png 2x' title=':D' width='20' />

     

    Thank you very much I really appreciate your support!

     

    Best regards,

    Tomi