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

  • SEARCH
  • Home
  • 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 8134709
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 6, 20262026-06-06T10:07:52+00:00 2026-06-06T10:07:52+00:00

I have the following piece of TCL code: #wrong format: set in_val 12 0

  • 0

I have the following piece of TCL code:

    #wrong format:
    set in_val "12 0 2 0 0 0 1 0 3 698"
    #correct format:
    #set in_val "12 0 1 0 0 0 1 0 3 698"
    set val_ok [regexp {(\d+)\s([01]\s)([01]\s)([01]\s)([01]\s)([01]\s)([01]\s)([01]\s)(\d+)\s(\d+).*} $in_val Var1 Var2 Var3 Var4 Var5 Var6 Var7 Var8 Var9 Var10 Var11]
    if {$val_ok==1} {
       # correct format
       puts "Correct format, continuing..."
       puts "$Var2 $Var3 $Var4 $Var5 $Var6 $Var7 $Var8 $Var9 $Var10 $Var11"
    } else {
       # wrong format
       puts "Wrong format, stimulus [$in_val]"
    }

I want to check if the format described with the regexp function is correct.
When the in_val var has the correct format, everything’s fine, the if block is exectuted.
However, when the format is wrong, instead of entering the else block, I get the following error:

invalid command name "12 0 2 0 0 0 1 0 3 698"
    while executing
"$in_val"
    invoked from within
"if {$val_ok==1} {
# correct format
puts "Correct format, continuing..."
puts "$Var2 $Var3 $Var4 $Var5 $Var6 $Var7 $Var8 $Var9 $Var10 $Var11"

} else {..."
    (file "xxx.tcl" line 3)

I’m using ActiveState ActiveTcl 8.5.11.1 for windows.
Any idea about why the error appears when val_ok=0 and the regex doesn’t match?
Thanks!

J-B

  • 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-06T10:07:53+00:00Added an answer on June 6, 2026 at 10:07 am

    It’s because you’re trying to execute $in_val:

    puts "Wrong format, stimulus [$in_val]"
                                     ^
                                     |
                   you are trying to execute $in_val here
    

    see the square brackets? Removing them would prevent the error:

    puts "Wrong format, stimulus : $in_val"
    

    If you still want to print the square brackets then you can backslash escape them:

    puts "Wrong format, stimulus \[$in_val\]"
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have the following piece of code: void TestFunc(const void * const Var1, const
I have the following piece of code (C#): is it correct? Thread[] threads =
I have following piece of code: It compiles without problems under gcc-3.4, gcc-4.3, intel
I have following piece of code : public Hashmap<String,String> tempmap = new HashMap<String,String>(); and
I have the following piece of code taken from the PHP manual on the
I have the following piece of code in C++. int arr[] = {1, 2,
I have the following piece of code: // setup the AJAX request var pageRequest
I have the following piece of code from a book. There is this function
I have the following piece of code: for i := 0 to FControlList.Count -
I have the following piece of pseudo-C/Java/C# code: int a[]= { 30, 20 };

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.