Re: [perl-win32-gui-users] SelectedItems method

2001-02-15 Thread Aldo Calpini
Erick J. Bourgeois wrote:
 [...]
 When Button is pressed it always falls through the if
 statement. Even in the case of no selection it falls through
 because @index[0], in this case, is undef. I know undef is
 the same as 0, but how could I get around this?

UNDEF IS NOT THE SAME AS 0! this is, speaking in perl terms,
an heresy and you shall be punished with eternal fire ;-)
undef is *evaluated* as 0 in numerical context and as  in
string context, but is not 'the same'.
perl has a defined() function to check if something is
'not undef', including 0 and . your if statement should
look like this:

if( defined( $index[0] ) ) {


cheers,
Aldo

__END__
$_=q,just perl,,s, , another ,,s,$, hacker,,print;





Re: [perl-win32-gui-users] SelectedItems method

2001-02-15 Thread Erick J. Bourgeois
Sorry to bother the list again, but Aldo, checking it's
undefness with defined does not work either, it falls
through not matter what. I tried putting print
$index[0]\n; to see it's value and indeed it is undef (ie.
it did not print anything), so why does it pass the if
statement?

erick
never stop questioning
www.jeb.ca




Re: [perl-win32-gui-users] SelectedItems method

2001-02-15 Thread Aldo Calpini
Erick J. Bourgeois wrote:
 Sorry to bother the list again, but Aldo, checking it's
 undefness with defined does not work either, it falls
 through not matter what. I tried putting print
 $index[0]\n; to see it's value and indeed it is undef (ie.
 it did not print anything), so why does it pass the if
 statement?

that's true, there's a bug in the XS code: it doesn't really
returns undef, but a false value (eg. 0). will be corrected
in the next release :-)

cheers,
Aldo

__END__
$_=q,just perl,,s, , another ,,s,$, hacker,,print;





Re: [perl-win32-gui-users] SelectedItems method

2001-02-15 Thread Erick J. Bourgeois
Aldo, can I correct it myself and compile it with DJGCC?

erick
never stop questioning
www.jeb.ca




Re: [perl-win32-gui-users] SelectedItems method

2001-02-15 Thread Erick J. Bourgeois
Aldo, I had a look at the GUI.XS (Version: 0.0.558) and I
found the following lines (at line: 9930~) for SelectedItems
return:

scount = ListView_GetSelectedCount(handle);
if(scount  0) {
index = -1;
tcount = 0;
EXTEND(SP, scount);
index = ListView_GetNextItem(handle, index,
LVNI_SELECTED);
while(tcount  scount  index != -1) {
XST_mIV(tcount, (long) index);
tcount++;
index = ListView_GetNextItem(handle, index,
LVNI_SELECTED);
}
XSRETURN(scount);
} else {
XSRETURN_NO; #Is the problem here?#
}

erick
never stop questioning
www.jeb.ca




Re: [perl-win32-gui-users] SelectedItems method

2001-02-15 Thread Aldo Calpini
Erick J. Bourgeois wrote:
 Aldo, can I correct it myself and compile it with DJGCC?

I hope so :-)
I could not compile it with cygwin's gcc, but I'll be very
happy to know how it goes with djgcc. but please post build
reports and pleas for help on the Perl-Win32-GUI-Hackers
mailing list, since this is a topic that doesn't interest
general Win32::GUI usage.

cheers,
Aldo

__END__
$_=q,just perl,,s, , another ,,s,$, hacker,,print;





Re: [perl-win32-gui-users] SelectedItems method

2001-02-15 Thread Aldo Calpini
Erick J. Bourgeois wrote:
 XSRETURN_NO; #Is the problem here?#

exxxactly, should be

XSRETURN_UNDEF;

instead.


cheers,
Aldo

__END__
$_=q,just perl,,s, , another ,,s,$, hacker,,print;





[perl-win32-gui-users] SelectedItems method

2001-02-14 Thread Erick J. Bourgeois
I'm trying to test if any items have been selected in a
listview with a button event and I have used the -singlesel
option on the listview. So, therefore, if the user clicks
the button without selecting anything, I would like to have
a MsgBox, else take the value of the the choosen selection
and do some computation.

$MainWin-AddListView(
-name  = ListView,
-pos   = [85, 100],
-size  = [$MainWin-ScaleWidth-160,
$MainWin-ScaleHeight-170],
-style = WS_CHILD | WS_VISIBLE | 1 |
WS_HSCROLL | WS_VSCROLL,
-fullrowselect = -1,
-gridlines = 0,
-hottrack  = 0,
-visible   = 0,
-view  = 1,
-tabstop   = 4,
-singlesel = 1,
);
$width = $MainWin-ListView-ScaleWidth;
$MainWin-ListView-InsertColumn(
-index   = 0,
-subitem = 0,
-width   = $width-15,
-text= Column,
);
for (sort keys %SomeHash) {
$MainWin-ListView-InsertItem(-text=[$_]);
}
$MainWin-AddButton(
-name   = Button,
-text   = Ok,
-pos= [347, 350],
-height = 20,
 );

sub Button_Click {
my @index = $MainWin-ListView-SelectedItems();
if (@index[0] = 0) { #I need the zero because of the
zero-based index
#do something...
} else {
Win32::MsgBox(...);
}

When Button is pressed it always falls through the if
statement. Even in the case of no selection it falls through
because @index[0], in this case, is undef. I know undef is
the same as 0, but how could I get around this?

erick
never stop questioning
www.jeb.ca




Re: [perl-win32-gui-users] SelectedItems method

2001-02-14 Thread Jeremy Blonde
Well, I don't know if this will actually fix your
problem, but you should definitely be using
$index[0] instead of @index[0].

Just my 2 cents,
jb


--- Erick J. Bourgeois [EMAIL PROTECTED] wrote:
 I'm trying to test if any items have been selected
 in a
 listview with a button event and I have used the
 -singlesel
 option on the listview. So, therefore, if the user
 clicks
 the button without selecting anything, I would like
 to have
 a MsgBox, else take the value of the the choosen
 selection
 and do some computation.
 
 $MainWin-AddListView(
 -name  = ListView,
 -pos   = [85, 100],
 -size  = [$MainWin-ScaleWidth-160,
 $MainWin-ScaleHeight-170],
 -style = WS_CHILD | WS_VISIBLE | 1
 |
 WS_HSCROLL | WS_VSCROLL,
 -fullrowselect = -1,
 -gridlines = 0,
 -hottrack  = 0,
 -visible   = 0,
 -view  = 1,
 -tabstop   = 4,
 -singlesel = 1,
 );
 $width = $MainWin-ListView-ScaleWidth;
 $MainWin-ListView-InsertColumn(
 -index   = 0,
 -subitem = 0,
 -width   = $width-15,
 -text= Column,
 );
 for (sort keys %SomeHash) {
 $MainWin-ListView-InsertItem(-text=[$_]);
 }
 $MainWin-AddButton(
 -name   = Button,
 -text   = Ok,
 -pos= [347, 350],
 -height = 20,
  );
 
 sub Button_Click {
 my @index = $MainWin-ListView-SelectedItems();
 if (@index[0] = 0) { #I need the zero because
 of the
 zero-based index
 #do something...
 } else {
 Win32::MsgBox(...);
 }
 
 When Button is pressed it always falls through the
 if
 statement. Even in the case of no selection it falls
 through
 because @index[0], in this case, is undef. I know
 undef is
 the same as 0, but how could I get around this?
 
 erick
 never stop questioning
 www.jeb.ca
 
 
 ___
 Perl-Win32-GUI-Users mailing list
 Perl-Win32-GUI-Users@lists.sourceforge.net

http://lists.sourceforge.net/lists/listinfo/perl-win32-gui-users


__
Do You Yahoo!?
Get personalized email addresses from Yahoo! Mail - only $35 
a year!  http://personal.mail.yahoo.com/



Re: [perl-win32-gui-users] SelectedItems method

2001-02-14 Thread Erick J. Bourgeois
Jeremy, sorry what I gave was a typo, I did indeed have
$Index[0] (Cutting and pasting error :) ). It should look
like this:

$MainWin-AddListView(
-name  = ListView,
-pos   = [85, 100],
-size  =
[$MainWin-ScaleWidth-160,$MainWin-ScaleHeight-170],
-style = WS_CHILD | WS_VISIBLE | 1
|WS_HSCROLL | WS_VSCROLL,
-fullrowselect = -1,
-gridlines = 0,
-hottrack  = 0,
-visible   = 0,
-view  = 1,
-tabstop   = 4,
-singlesel = 1,
);
$width = $MainWin-ListView-ScaleWidth;
$MainWin-ListView-InsertColumn(
-index   = 0,
-subitem = 0,
-width   = $width-15,
-text= Column,
);
for (sort keys %SomeHash) {
$MainWin-ListView-InsertItem(-text=[$_]);
}
$MainWin-AddButton(
-name   = Button,
-text   = Ok,
-pos= [347, 350],
-height = 20,
 );

sub Button_Click {
my @index = $MainWin-ListView-SelectedItems();
if ($index[0] = 0) { #I need the zero because of the
zero-based index
#do something...
} else {
Win32::MsgBox(...);
}

Any more ideas are more than welcome.

erick
never stop questioning
www.jeb.ca
- Original Message -
From: Jeremy Blonde [EMAIL PROTECTED]
To: perl-win32-gui-users@lists.sourceforge.net
Sent: Wednesday, February 14, 2001 11:04 PM
Subject: Re: [perl-win32-gui-users] SelectedItems method


 Well, I don't know if this will actually fix your
 problem, but you should definitely be using
 $index[0] instead of @index[0].

 Just my 2 cents,
 jb