[tcltk-perl] RE: scalar($w->getOpenFile)
Brought to you by:
hobbs
From: Jeff H. <je...@ac...> - 2004-04-22 18:19:25
|
> my $mw = MainWindow->new; > my $label = $mw->Label(-text => "Hello")->pack; > if (my $file = $mw->getOpenFile) { > $label->configure(-text => "File [$file]"); ... > and then hit "Cancel" to the dialog that pops up, then we > fill in the field with something like "File > [ARRAY(0x8141ad8)]". Apparently tk_getOpenFile returns a > list instead of string, but this is not documented. Since I have identified the source of this problem, and it has to do with promiscuous object literal sharing in Tcl. The empty object (string rep "") is being converted to a list at some point (perfectly valid, as you can still request the string). The problem is that when the literal "" object is passed through to Perl, I check for tclListType first and create an (empty) array. My solution to this is to not create an array until the list actually has length > 0. This is all in SvFromTclObj, BTW. My question is, should I create the alternate "empty" list as newSV(0) (== undef), or newSVpvn("", 0) (== "" I think)? BTW, the messageBox issue was the same - the literal "yes" was being used as a boolean (which it validly is), and I was checking for boolean type without regard to the fact that the string rep of a boolean can be lots of things other than 0/1. The solution there is to make sure that I only convert booleans with no string rep to boolSVs. Jeff |