#!/usr/bin/perl
# $Id: fd.pl,v 1.1 2006/03/28 13:21:40 skoch Exp $
use AFM;

if ( scalar(@ARGV) < 1 ) {
    print
'Use: fd.pl $rig type  [optional: $testno], where $rig is the rig number'
      . "\n";
    print
'$testno is the test number if an other test than the current is to be processed',
      "\n";
    exit 1;
}
    $trigno = $ARGV[0];
    $trigno =~ /(\d+)/;
    $rigno = $1;

$type=$ARGV[1];

if ( scalar(@ARGV) > 1 ) {
    $ttestno = $ARGV[2];
    $ttestno =~ /(\d+)/;
    $testno = $1;
}
else {
    $testno = &AFM::get_test_nr($rigno);
}
$folder = $AFM::publicdir.'rig' . $rigno . "/" . $rigno . "test" . $testno."/iv";
opendir DIR, $folder;
@files= readdir DIR;

@values = (
"emf0_3" ,
"emf0_5" ,
"emf0_8" ,
"c1000" ,
"c800" ,
"c700" ,
"c600" 
	   );
foreach (@files) { 
    if (    /(.*$type.*par)$/ ) { $fn=$1; # print $1," ",substr($1,0,19),"\n";
$fn= $folder."/".$1;
$date=substr($1,0,19);
open(INFILE,"< $fn " );
			  while (<INFILE>) { #print;
    chomp;	# strip record separator
    @Fld = split(' ', $_, 9999);
    $a{$Fld[0]} = $Fld[$#Fld];

}			

  print $date; 
##values;$i++)    
			   for ( $i=0 ;$i<=$#values;$i++) { 
print " ",$values[$i]," ",$a{$values[$i]};

};
  print "\n";

 


		      }}
