in reply to Re: Re: Re: "this" variable?
in thread "this" variable?

You need to show us where and how you call the &ComboBox subroutine. Follow Abigail-II's advice and read the appropriate man pages.

Rather than sit around and try and second guess what you're doing, I figured I could show you what is going on here. For a quick example of OO in Perl and what is going on here, save the following file as 'Counter.pm':

package Counter; use strict; use Carp; sub new { my ($class,$value) = @_; $value ||= 0; my $self = bless {}, $class; croak "Argument to constructor must be positive integer." if ! $self->_good_value( $value ); $self->{_value} = $value; return $self; } sub value { my $self = shift; $self->{_value} = $_[0] if $self->_good_value($_[0]); return $self->{_value}; } sub increment_value { my $self = shift; $self->{_value}++; } sub decrement_value { my $self = shift; $self->{_value}--; } sub _good_value { my ( $self, $value ) = @_; return 0 if ! defined $value; $value =~ /^\d+$/; } 1;

And then, in the same directory:

#!/usr/bin/perl -w use strict; BEGIN { unshift @INC, '.'; # add current directory to include path use Counter; } my $counter = Counter->new; print $counter->value, "\n"; $counter->increment_value; print $counter->value, "\n"; $counter->decrement_value; print $counter->value, "\n"; $counter->value(3); print $counter->value, "\n";

The above code is rather simple and not how I would really do it, but it gives you an idea of what is going on. If you don't understand it, you really need to learn Perl's OO system, as what I have presented is very basic.

Cheers,
Ovid

Join the Perlmonks Setiathome Group or just click on the the link and check out our stats.

Replies are listed 'Best First'.
Re: Re: Re: Re: Re: "this" variable?
by jsprat (Curate) on May 30, 2002 at 21:25 UTC
    Just to clarify, the OP doesn't control how subroutine is called. When the end user changes the value of the combo box, Windows sends a message to the main window, which in turn dispatches control to the subroutine.