I got a 2000+ lines TCL-Script, whch I have to maintain now.
Using tclsh to source the script gives me not more than:
missing close bracket.
Is it possible to get a little bit more of information about
this (and other possible syntax errors) out of the tcl-interpreter ?
I am near desparation and time.
Thanks a lot in advance for any help!
Kind regards,
Meino Cramer
--
----------------------------------------------------------------------
Disclaimer:
This is a private mail.All opinions expressed are my own and may not
represent those of my employer. Not for commercial publication unless
expressly permitted via e-mail or writing.
Copyright (c) 2000/2001 - Meino Cramer - All rights reserved.
----------------------------------------------------------------------
The variable ::errorInfo always contains more detailed information
about where the last error occurred in an interpreter.
Try a [puts $::errorInfo] when you see the error message.
--
| Don Porter Mathematical and Computational Sciences Division |
| donald...@nist.gov Information Technology Laboratory |
| http://math.nist.gov/~DPorter/ NIST |
|______________________________________________________________________|
The problem is: which bracket is missing? It's hard to know what's missing when
it isn't there... :^/ You have my sympathy. (This is why many people use
editors with support for bracket-matching.)
Donal.
--
Donal K. Fellows http://www.cs.man.ac.uk/~fellowsd/ fell...@cs.man.ac.uk
-- A large ASCII art .sig is the Usenet equivalent of walking around in
public with your asscrack sticking out past the top of your sweatpants.
You be the judge. -- Mike Hoye <mh...@prince.carleton.ca>
"Donal K. Fellows" <fell...@cs.man.ac.uk> wrote in message
news:3D246253...@cs.man.ac.uk...
This is exactly the point of something like procheck:
http://www.activestate.com/Products/TclPro/
It prevents the small things wasting your time so you can focus on
the real work.
--
Jeff Hobbs The Tcl Guy
Senior Developer http://www.ActiveState.com/
Tcl Support and Productivity Solutions
Also, frink (http://catless.ncl.ac.uk/Programs/Frink/) lets you do
static error checking, with its -J option.
--
Glenn Jackman
gle...@ncf.ca
> emacs is good for this, I heard.
I use emacs for Tcl editing all the time, and still brackets go missing
sometimes. I usually work with 'show-paren-mode', which highlights the
matching parentheses. Another nice way to find them is selecting a region that
should be balanced and then pressing ctrl-alt-\ to re-indent the region -
that usually shows which one is missing in two or three tries.
- Pascal.
You have been pointed to some debugging aids. One of the simplest, if
the "missing bracket" comes out of the blue from a larger script, is to
distribute some "milestones" through the file - say every 100 lines or
so, outside of proc definitions (i.e. in global scope) insert commands
like
puts ---1
...
puts ---2
...
Source your script again, see how many milestones print out their unique
ID. Then you have narrowed down the problem to the area between the last
that printed and the first that didn't. Repeat with "yardstones" at
smaller distances until you have the offending line.
--
Schoene Gruesse/best regards, Richard Suchenwirth - +49-7531-86 2703
Siemens Dematic AG, PA RC D2, Buecklestr.1-5, 78467 Konstanz,Germany
Personal opinions expressed only unless explicitly stated otherwise.
Useful emacs keybindings for this task:
ctrl-alt-space - marks the next S-expression
ctrl-alt-f - forward over next S-expression
ctrl-alt-b - backward over preceding S-expression
Donal
--
"[He] would have needed to sell not only his own soul, but have somehow gotten
in on the ground floor of an Amway-like pryamid scheme delivering the souls
of kindergarten students to Satan by the truckload like so many boxes of Girl
Scout Cookies." -- John S. Novak, III <j...@concentric.net>
Using vi/vim (ctrl-b on pfe) try starting at the last proc level close
brace in the source file and press % (percent) to locate its match.
This should show the open brace of the proc. Continue until you find a
match which is not a proc statement, and viola, the problem opening
brace is revealed.
I regularly start a TCL source file with a comment, right after
the #! autostart stuff thus:
# {[( For finding mis-matches
and at the end, I combine the match with my vim auto-start setup
control line:
# )]} find mismatches # vim: set ... ff=unix syntax=tcl:
Finally, I type the code between these two.
And I always try to remember to check before I try to execute for
the first time and after any substantial edit. I'm very surprised
at how often the check fails and I have to go back and find out
where/why. Usually it happens around some uncomplicated piece of
code that didn't require intense thought, where my thoughts got way
ahead of my typing.
--
R. T. Wurth / rwu...@att.net / Rumson, NJ USA
Consultant to the telecommunications industry
if {[string length $foo] > 0} {
set foo "${foo}bar"
}
I first type
if {[]} {
}
This minimizes the chance of leaving a hanging bracket or brace.
TclPro's procheck pinpoints missing closing brackets well, but
not closing braces. (After all, how does it know where you intend
an "if" or "for" to end?)
Jeff David