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!
Answers
-
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 okset outerdiameter [hm_getint outer]
set innerdiameter [hm_getint inner]
}
0 -
Hi tinh,
the return command works fine!
I tried the 'while' command too but nothing happens /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
0 -
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} {'
0 -
Altair Forum User said:
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 /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
0