tcl expressions fail

2010-06-26
2013-04-22
  • I'm trying to write some tcl scripts for mged, but the expr command fails.
    Several examples in: http://brlcad.org/wiki/Image:TclTk_Integration.pdf fail.

    On page 14:
    mged> in ball.s sph 0 0 0
    Error: ERROR, radius must be greater than zero!
    ERROR, sph not made!

    On page 17:

    mged> for {set time 3} {$time>0} {set time [expr $time - 1} {puts "Time is $time" }
    Error: wrong # args: should be "set varName ?newValue?"
    Time is 3

    Has the syntax for tcl been changed? If so, to what?

    Gilligan

     
  • Sean Morrison
    Sean Morrison
    2010-06-26

    The syntax for Tcl has not changed.  You have a typo in your script where you are missing a "]" closing square bracket.   The third parameter to 'for' should be:

    { set time  }

    Not

    { set time [expr $time - 1}

    Note also that you'll have to escape the globbing characters if "set glob_compat_mode" is 1.  The PDF you reference mention this on page 12 in the section talking about special character conflicts.  Basically you can run "set glob_compat_mode 0" or escape your square brackets (e.g., "in ball.s sph 0 0 0 ")

    Cheers!
    Sean

     
  • Sean Morrison
    Sean Morrison
    2010-06-26

    Oops, that example was supposed to be "in ball.s sph 0 0 0 \" with the backslashes preceding the brackets.  That's if glob_compat_mode is 1.  If it's 0, then you don't need the backslashes.