Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8529447
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T09:02:21+00:00 2026-06-11T09:02:21+00:00

I wanted to know how to implement GOTO in tcl. I am writing a

  • 0

I wanted to know how to implement GOTO in tcl.
I am writing a test case where I have say 5 steps.
If my step 1 fails I don’t want to proceed further and I want to skip the existing things and goto a common clean up section.

Please help me with if there are any GOTO commands in tcl.

Thanks,
Ramya.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-11T09:02:22+00:00Added an answer on June 11, 2026 at 9:02 am

    There is no goto in Tcl, and for relatively technical reasons it’s impossible to implement one.

    But you can do what you’re after in other ways. Since you’re dealing with test cases, I hope you’re using the tcltest package for the job. With that, you can specify cleanup code quite easily:

    tcltest::test test-1.1 "verify that the foo works" -setup {
        allocate some resources
    } -body {
        whatever to do the test...
        return [our results]
    } -cleanup {
        drop those resources
        make sure that we are nice and clean
    } -result "the expected test result"
    

    You can skip out of the body of a test easily by just doing a return; the tcltest::test command will detect it and treat that as the result. It is usually better to try to keep each test independent of the others though: that makes it much easier to track down what’s going wrong when a test fails.

    If you’re not using tcltest, you are still best refactoring into something where you can use return to skip out early. You can combine that with try…finally… (either natively in Tcl 8.6, or with this code on the Tcler’s Wiki) to make things easy:

    proc doThings {} {
        try {
            # do thing-1
            if {$no_more} return
            # do thing-2
            if {$no_more} return
            # do thing-3
            if {$no_more} return
            # do thing-4
            if {$no_more} return
            # do thing-5
        } finally {
            # do cleanup
        }
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am going to implement StoreKit in an iPhone application and wanted to know
I wanted to know if there is an implement of timeout on VB6. I
I wanted to know how to implement customization in your apps, like the design
I wanted to know what is the best way to implement multiple cell types.
I am developing API using django-tasty-pie and wanted to know which library to implement
i wanted to know how can we implement call back mechanism in .net, since
I just wanted to know how you could implement a bookcase, like in iBooks,
I wanted to know how can we implement the cover flow effect for the
I wanted to know whether it is possible to implement code like this? public
i want to implement english language for all regions like africa,america,uk and china.I have

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.