S
Steve
I'm just doing this for learning, and I can't figure it out. What
this is supposed to do is when I click the start button, it constantly
moves anything from 1 folder to another until I click the stop button.
I have 2 problems with my code: 1. strict doesn't like it, and 2. the
button stays pressed forever and I cannot initiate the stop button.
strict doesn't like it because I can't seem to remember exactly how to
declare a global variable. I attempted state $x = 1; but it didn't
like that. So in my code I show it's changed so strict is not in use
and I just declare it as $x = 1; (I know this is wrong
).
here is my code:
#!/usr/bin/perl -w
#use strict;
use Wx;
###########################################################
#
# Define importsvc class that extends Wx::App
#
package importsvc;
use base qw(Wx::App); # Inherit from Wx::App
use Wx::Event qw(EVT_BUTTON);
sub OnInit
# Every application has its own OnInit method that will
# be called when the constructor is called.
{
my $self = shift;
my $frame = Wx::Frame->new( undef, # Parent window
-1, # Window id
'Import Services', # Title
[200,300], # position X, Y
[250, 150] # size X, Y
);
my $panel = Wx:
anel->new($frame,-1); #create a panel in the
parent window $frame
my $start = Wx::Button->new($panel,1,"Start Import",[10,10]);
my $stop = Wx::Button->new($panel,1,"Stop Import",[10,40]);
EVT_BUTTON($start,$start,\&startimport);
EVT_BUTTON($stop,$stop,\&stopimport);
$self->SetTopWindow($frame); # Define the toplevel window
$frame->Show(1); # Show the frame
}
sub startimport {
$x = 1;
while( $x == "1"){
system "mv /home/steve/Desktop/INCOMING/* /home/steve/Desktop/
IMPORTED";
}
}
sub stopimport {
$x = 0;
}
###########################################################
#
# The main program
#
package main;
mkdir "/home/steve/Desktop/INCOMING";
system "touch /home/steve/Desktop/INCOMING/transmission1.txt";
system "touch /home/steve/Desktop/INCOMING/transmission2.txt";
system "touch /home/steve/Desktop/INCOMING/transmission3.txt";
system "touch /home/steve/Desktop/INCOMING/transmission4.txt";
mkdir "/home/steve/Desktop/IMPORTED";
my $wxobj = importsvc->new(); # New HelloWorld application
$wxobj->MainLoop;
this is supposed to do is when I click the start button, it constantly
moves anything from 1 folder to another until I click the stop button.
I have 2 problems with my code: 1. strict doesn't like it, and 2. the
button stays pressed forever and I cannot initiate the stop button.
strict doesn't like it because I can't seem to remember exactly how to
declare a global variable. I attempted state $x = 1; but it didn't
like that. So in my code I show it's changed so strict is not in use
and I just declare it as $x = 1; (I know this is wrong
here is my code:
#!/usr/bin/perl -w
#use strict;
use Wx;
###########################################################
#
# Define importsvc class that extends Wx::App
#
package importsvc;
use base qw(Wx::App); # Inherit from Wx::App
use Wx::Event qw(EVT_BUTTON);
sub OnInit
# Every application has its own OnInit method that will
# be called when the constructor is called.
{
my $self = shift;
my $frame = Wx::Frame->new( undef, # Parent window
-1, # Window id
'Import Services', # Title
[200,300], # position X, Y
[250, 150] # size X, Y
);
my $panel = Wx:
parent window $frame
my $start = Wx::Button->new($panel,1,"Start Import",[10,10]);
my $stop = Wx::Button->new($panel,1,"Stop Import",[10,40]);
EVT_BUTTON($start,$start,\&startimport);
EVT_BUTTON($stop,$stop,\&stopimport);
$self->SetTopWindow($frame); # Define the toplevel window
$frame->Show(1); # Show the frame
}
sub startimport {
$x = 1;
while( $x == "1"){
system "mv /home/steve/Desktop/INCOMING/* /home/steve/Desktop/
IMPORTED";
}
}
sub stopimport {
$x = 0;
}
###########################################################
#
# The main program
#
package main;
mkdir "/home/steve/Desktop/INCOMING";
system "touch /home/steve/Desktop/INCOMING/transmission1.txt";
system "touch /home/steve/Desktop/INCOMING/transmission2.txt";
system "touch /home/steve/Desktop/INCOMING/transmission3.txt";
system "touch /home/steve/Desktop/INCOMING/transmission4.txt";
mkdir "/home/steve/Desktop/IMPORTED";
my $wxobj = importsvc->new(); # New HelloWorld application
$wxobj->MainLoop;