Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

TCL Bug

Status
Not open for further replies.

nater

Programmer
Jun 14, 2002
21
CA
Found a minor bug - I think - in TCL.. Specifically, regexp can't seem to store a match into an entry text variable. IE

set entryspace "Initial"

entry .e -textvar entryspace

set head "Line header:"
set inline "Line header: entry"
set yap [regexp "$head ?(.*)$" $inline match entryspace]

does not work. It blows up as soon as you try to do the regexp. If you put in an intermediate variable, then set "entryspace" explicitly, it works fine..

Prolly no-one but me will ever run into this, and spend a whack of time trying to figure out why this harmless regexp causes this insane memory fault error.. But hey.

Is there an official place to submit bug reports to?
 
Yes, you can submit Tcl/Tk bugs at However...

I didn't have any problems with the code you posted. Copied and pasted into a fresh wish, it worked fine with no error. I tried it on Windows 2000 with Tcl 8.3.2, 8.3.4, and 8.4a4; and on Linux with Tcl 8.3.4 and 8.4a4.

Which isn't to say that there isn't a bug somewhere in Tcl. What version are you using, and on what platform? - Ken Jones, President
Avia Training and Consulting
866-TCL-HELP (866-825-4357) US Toll free
415-643-8692 Voice
415-643-8697 Fax
 
Hmm.. that's interesting.. when I have a minute I'll make a small test program and see if I can re-create my bug..

I'm on 2000 with 8.3.4, so that's not why.. there must be another factor here..

I'll post again.
 
OK.. that makes a bit more sense now.. I still think I'd classify it as a bug though..

the difference was my entry also had a validatecommand.

Soooo

set entryspace "Initial"

entry .e -textvar entryspace -validate key -validatecommand "set wack 1"

set head "Line header:"
set inline "Line header: entry"
set yap [regexp "$head ?(.*)$" $inline match entryspace]

I have copied this into wish as is, and it blows up.
 
But.. this works fine:

set entryspace "Initial"

entry .e -textvar entryspace -validate key -validatecommand "set wack 1"

set head "Line header:"
set inline "Line header: entry"
set yap [regexp "$head ?(.*)$" $inline match temp]
set entryspace $temp

 
Very odd. I'm getting sporadic errors with the first code listing you just provided. (I also added a pack .e in there after creating the entry.) If I source the script into a wish interpreter, it crashes either immediately or as soon as I click in the entry widget. If I enter the commands into an interactive wish, it sometimes crashes and sometimes doesn't.

So, while I don't understand what the cause of the error might be, I'd agree that it's a bug worth submitting. Definitely mention that the error was not observed without the -validatecommand option. You might also mention in the bug report that the error has been independently confirmed by another user in both Tcl 8.3.2 and 8.4a4 on a Windows 2000 system. - Ken Jones, President
Avia Training and Consulting
866-TCL-HELP (866-825-4357) US Toll free
415-643-8692 Voice
415-643-8697 Fax
 
I should have also remembered to mention the warning that appears in the entry manual page, under the "Validation" heading:

"In general, the textVariable and validateCommand can be dangerous to mix. Any problems have been overcome so that using the validateCommand will not interfere with the traditional behavior of the entry widget. Using the textVariable for read-only purposes will never cause problems. The danger comes when you try set the textVariable to something that the validateCommand would not accept, which causes validate to become none (the invalidCommand will not be triggered). The same happens when an error occurs evaluating the validateCommand...."

It goes on to explain a couple more issues regarding mixing the -textvariable and -validatecommand options.

So in general, it's a bad idea to mix the -textvariable and -validatecommand options with an entry. But still, it shouldn't crash your application if you do. So it's still worth submitting as a bug. - Ken Jones, President
Avia Training and Consulting
866-TCL-HELP (866-825-4357) US Toll free
415-643-8692 Voice
415-643-8697 Fax
 
Hmm ok, I didn't see that warning..

I will still report the bug.

Maybe you can answer something for me.. What's a better way to perform a command when the textvariable of an entry is modified?

Actually, I guess I could do a key bind. I'm sure I rejected that for some reason though.. Right. As far as I could see, you can only bind an event to a *specific* key..
But.. seems like you know more than smee. =)
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top