Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations dencom on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Program running without errors but cannot see O/P..Please Help!

Status
Not open for further replies.

arun10427

Programmer
Oct 24, 2009
29
US
#!C:\perl\bin
#use Date::Day;
use warnings;
use XBase;
my @data7;
my $sum = 0;
my $table = new XBase "Input.dbf";
my $new_table=XBase->create("name"=>"Output.dbf",
"field_names" =>["X", "Y", "SPEED", "BOX", "DATE_","TIME", "TimeDay","DayWeek","Date_Format","TimeStamp"],
"field_types"=>["F", "F", "N", "N", "C", "C", "C", "C","D","N" ],
"field_lengths"=>[19, 19, 10, 10, 30, 30, 10, 10,10,18],
"field_decimals"=>[11, 11, 0, 0, 0, 0, 0, 0,0,0]);
my $array = @_;

my $data9 = @_;
my @array=();
my $start=0;my $final;
my $end=0;
my $i;my $j;
my $recCount=0;
my @data;
for ($i=1;$i<$table->last_record;$i++)
{
@rec_cur = $table->get_record($i,"TimeStamp", "BOX");
@rec_prev = $table->get_record($i-1,"TimeStamp", "BOX");
$recCount++;
if ($rec_cur[2] != $rec_prev[2])
{
$end=$i-1;
if ($recCount >60)
{
for ($j=$start; $j<=$end; $j++)
{
@data=$table->get_record($i);
#Fix the next line
$new_table->set_record($i,$data[1],$data[2],$data[3],$data[4],$data[5],$data[6],$data[7],$data[8],$data[9],$data[10]);
}
}
$start=$i;
$end=$i;
next;
}


$diff = $rec_cur[1] - $rec_prev[1];
if ($diff> 1)
{
$end=$i-1;
if ($recCount >60)
{
for ($j=$start;$j<=$end; $j++)
{
@data=$table->get_record($i);
#Fix the next line

$new_table->set_record($i,$data[1],$data[2],$data[3],$data[4],$data[5], $data[6],$data[7],$data[8],$data[9],$data[10]);

}
}
$start=$i;
$end=$i;
next;
}
}
$new_table->close;
$table->close;


The code basically reads a file and writes only certain records which meet the constraints in the new Output file. But my Output file is empty even though it is of bigger size. Where am I going wrong?
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top