Wagner-David wrote:
>Given the code supplied, unsure what you are really trying to do. If an array is not
>empty, then the test
> scalar(@value) would come back true.
>
>If you could supply more code, errors generated, etc, might give the list a little
>more info on what is really happening.
>
>Wags ;)
>
>-----Original Message-----
>From: Chris Anderson [mailto:[EMAIL PROTECTED]]
>Sent: Saturday, January 26, 2002 09:36
>To: [EMAIL PROTECTED]
>Subject: Trying to get NULL with use strict; - How???
>
>
>The following code fails:
>
> if ( $i != NULL ) {
> if ($j < 10) {
> print DUMPFILE " $j) ", "$value[$i]\n" ;
> } else {
> print DUMPFILE " $j) ", "$value[$i]\n" ;
> }
> }
>as I have:
>
>use strict;
>
>At the very top.
>
>But I need a way to check and see if the array is empty...
>
>(4 items, but can have 20)
>
>How would I do this???
>
>TIA!
>
>
Here is the complete code! :)
use strict;
use Tk;
#***********************************************************
#*
#* Create the variables
#*
#***********************************************************
my @value;
my $mw = tkinit;
my $f = $mw->Frame->pack;
my $i = 0;
$mw->geometry('500x486');
#***********************************************************
#*
#* Add the Summary Label
#*
#***********************************************************
$f->Label( -text => 'Summary:',
-width => 0,)->grid(
-row => 0,
-column => 0,
-sticky => 'w',
);
#***********************************************************
#*
#* Add the Summary Textbox
#*
#***********************************************************
$f->Entry(
-textvariable => \$value[1],
-width => 60,)->grid(
-row => 0,
-column => 1,
-sticky => 'w',
);
#***********************************************************
#*
#* Add the Reproducable Label
#*
#***********************************************************
$f->Label( -text => 'Reproducible:',
)->grid(
-row => 1,
-column => 0,
-sticky => 'w',
);
#***********************************************************
#*
#* Add the Reproducable TextBox
#*
#***********************************************************
$f->Entry(
-textvariable => \$value[2],
-width => 3,)->grid(
-row => 1,
-column => 1,
-sticky => 'w',
);
#***********************************************************
#*
#* Add a '-' line
#*
#***********************************************************
$f->Label( -text => '',
)->grid(
-row => 2,
-column => 0,
-sticky => 'w',
);
#***********************************************************
#*
#* Add the Steps Label
#*
#***********************************************************
$f->Label( -text => 'Steps to Reproduce:',
)->grid(
-row => 3,
-column => 0,
-sticky => 'w',
);
#***********************************************************
#*
#* Increment Counter
#*
#***********************************************************
$i++;
#***********************************************************
#*
#* Loop 20 times and create 20 steps...
#*
#***********************************************************
for ($i = 4; $i < 23; $i++) {
$f->Label(
-text => "Step " . (($i + 1)-4),
)->grid(
-row => $i,
-column => 0,
-sticky => 'w',
);
#***********************************************************
#*
#* Loop 20 times and create 20 Textboxes
#*
#***********************************************************
$f->Entry(
-textvariable => \$value[$i],
)->grid(
-row => $i,
-column => 1,
-sticky => 'w',
);
}
#***********************************************************
#*
#* Add a blank label
#*
#***********************************************************
$f->Label( -text => '',
)->grid(
-row => $i++,
-column => 0,
-sticky => 'w',
);
#***********************************************************
#*
#* Create the button at the bottom of the form
#* and write everything out to the screen...
#*
#***********************************************************
$mw->Button(
-text => 'Write Data',
-command => sub {
#***********************************************************
#*
#* If the Write Data button is clicked...
#* Open up the DUMPFILE, and start looping through the
#* array.
#*
#***********************************************************
open (DUMPFILE,"> SCR.txt");
for (my $i = 0; $i < @value; $i++) {
my $j = ($i - 3);
#***********************************************************
#*
#* Ignore the 0th entry, if exist..
#* This is entered iin, as the DUMPFILE was getting some
#* wierd garbage before the first real item..
#*
#* Do printf statsments to the screen, so the user can see
#* what is being dumped, as a verificaion step!
#*
#***********************************************************
if ($i == 0) {
#***********************************************************
#*
#* Very first item of the array - The Summary of the defect.
#*
#***********************************************************
} elsif ($i == 1) {
print DUMPFILE "Summary:\n";
print DUMPFILE " $value[$i]\n";
printf "Summary: \n", $value[$i]
#***********************************************************
#*
#* Is this puppy reproducable, or a one time issue.
#* Can't reproduce it?? Hmm.. USer error???
#*
#***********************************************************
} elsif ($i == 2) {
print DUMPFILE "Reproducible:\n";
print DUMPFILE " $value[$i]\n";
printf "Reproducible: \n", $value[$i]
#***********************************************************
#*
#* Okay, put in a blank line, then lets label the Steps
#* header...
#*
#***********************************************************
} elsif ($i == 3) {
print DUMPFILE "\n";
print DUMPFILE "Steps to Reproduce:\n";
printf "Steps to Reproduce: \n"
#***********************************************************
#*
#* Start looping throught eh rest of the array, putting in
#* the steps of how to reproduce it.
#*
#***********************************************************
} else {
#***********************************************************
#*
#* If we have stuff entered into the array, lets dump it!
#*
#***********************************************************
if ( $i != NULL ) {
#***********************************************************
#*
#* This is just a neatness step. So that 1 and 10
will line
#* up nice and neat:
#* 1)
#* 10)
#*
#***********************************************************
if ($j < 10) {
print DUMPFILE " $j) ", "$value[$i]\n" ;
} else {
print DUMPFILE " $j) ", "$value[$i]\n" ;
}
}
printf " %d) %s\n", $j, $value[$i]
if $value[$i];
}
}
#***********************************************************
#*
#* Close the DUMPFILE.
#*
#***********************************************************
close (DUMPFILE);
},
)->pack;
MainLoop;
#***********************************************************
#*
#* As a test, open notepad with the file to verify the
#* results. This will NOT be int he final release...
#*
#***********************************************************
`notepad SCR.txt`;
--
Chris Anderson
CTO
C&P Enterprises
http://www.candp-ent.com/
--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]