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 8820577
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T05:38:37+00:00 2026-06-14T05:38:37+00:00

I want to bind an action to two commands that will be done one

  • 0

I want to bind an action to two commands that will be done one after the other. I’ve tried the following syntax:

$g marker bind $point <Button-1> [list $table HighLightCell 1 [expr [lindex $value 1] + 3] \; __highlight_selected $table $sparam $eyes sparam_eyes $graph]

I’ve also tried few other variations, but none of them worked.

$g is a blt graph, and it handles binds like normal binds in Tk. What happens is that Tcl thinks that all the parameters are parameters for $table HighLightCell and doesn’t interprate the ; as the end of one command and start of a new command.

I can’t use {...} syntax because I need to put variables in the commands, which I’m not able to do using {...}. How can I put 2 commands that will be done when the event happens, without creating a new proc that will call those commands?

  • 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-14T05:38:38+00:00Added an answer on June 14, 2026 at 5:38 am

    Even if I agree that the proc way is the better one, you can try the following two ways.

    The first one, is to use double quotes for grouping, "...", which are similar to braces, but allows variable expansion and command substitution. Your code will be something like:

    $g marker bind $point <Button-1> "$table HighLightCell 1 [expr [lindex $value 1] + 3] ; __highlight_selected $table $sparam $eyes sparam_eyes $graph"
    

    (Note that the semicolon is not escaped.)

    The second one, is to use eval, and to defer the execution of the two commands to it. You can try this:

    $g marker bind $point <Button-1> [list eval $table HighLightCell 1 [expr [lindex $value 1] + 3] \; __highlight_selected $table $sparam $eyes sparam_eyes $graph]
    

    eval just calls the interpreter on a command formed by its arguments. If among them there is a semicolon, the commands will be two. The semicolon must be escaped, this time, because it must be interpreted by the eval and not before.

    I tried both the methods with the following simple codes, and they both works:

    set x 1
    set y 2
    pack [button .b1 -text Test1]
    pack [button .b2 -text Test2]
    bind .b1 <Button-1> "puts $x; puts $y"
    bind .b2 <Button-2> [list eval puts $x \; puts $y]
    

    Clicking on either the buttons gives the same result, which is the expected

    1
    2
    

    One more thing, it’s better to put the arguments of the expr command inside braces, so in your code you should replace

    expr [lindex $value 1] + 3
    

    with

    expr {[lindex $value 1] + 3}
    

    You don’t have to worry about the substitution of the $value variable and about the execution of the lindex command: expr does that for you, but it also optimize the execution. You can find some more information in the wiki (http://wiki.tcl.tk/583), or in the expr manual page (http://www.tcl.tk/man/tcl8.5/TclCmd/expr.htm).

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I want to bind one property to multiple sources. My reason for this are
I want to render the same view after a successful action (rather than use
I want to use a form that has two submit buttons. Each button calls
I got two submit buttons in a form. One that deletes the post, and
I've got two types of contact entity. One that just has an email address
I have a DataGrid that two of its columns are ComboBoxes (one contains few
I have the following method set as the action of an NSComboBox and two
I want to bind a function to an event but I want to change
I want to bind a string value to a text box but only if
I want to bind Groupboxes to my stackpanel. c#: internal ObservableCollection<GroupBox> BindingTest { get

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.