INTELLIGENT WORK FORUMS
FOR COMPUTER PROFESSIONALS

Log In

Come Join Us!

Are you a
Computer / IT professional?
Join Tek-Tips Forums!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!

*Tek-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

Jobs

How to make a tcl script running through the end if there is failure in a command in the script

How to make a tcl script running through the end if there is failure in a command in the script

How to make a tcl script running through the end if there is failure in a command in the script

(OP)
I am creating a TCL script namely test.tcl in that script I use many built-in Tcl commands to test a tool in batch mode. This is contents of the script, for example

a $myname
b $last $first
c $occupation

where a, b and c are Tcl built-in commands
somehow the variables are passing incorrectly and cause one of the commands failure (for example command b will fail if $first is empty string) then it will stops the script running through the end.
I am thinking a way to keep the test.tcl script running through the end in that case and report the error if there is any but I dont know how to do that.
I guess I need to have a check in each command to capture the error if it fails but it is beyond my knowledge since I just learn Tcl.
I would like to have your help to help me to resolve the issue.
Thanks a lot
Tony

RE: How to make a tcl script running through the end if there is failure in a command in the script

Posttpham1002002 I've had this problem too. The 'catch' procedure can be used to catch errors. The way I've used is:
set errorval {}
catch {tclscripts} errorval
Here, if tclscript does not generate an error the errorval variable will be blank. If there is an error the errorval will contain some script. The program will just continue and you can interrogate the variable an any time.

Red Flag This Post

Please let us know here why this post is inappropriate. Reasons such as off-topic, duplicates, flames, illegal, vulgar, or students posting their homework.

Red Flag Submitted

Thank you for helping keep Tek-Tips Forums free from inappropriate posts.
The Tek-Tips staff will check this out and take appropriate action.

Reply To This Thread

Posting in the Tek-Tips forums is a member-only feature.

Click Here to join Tek-Tips and talk with other members!

Resources

Close Box

Join Tek-Tips® Today!

Join your peers on the Internet's largest technical computer professional community.
It's easy to join and it's free.

Here's Why Members Love Tek-Tips Forums:

Register now while it's still free!

Already a member? Close this window and log in.

Join Us             Close