From 1dff2798a12004f361ec68603f780e266c1c8b81 Mon Sep 17 00:00:00 2001 From: Zaher Salman Date: Thu, 27 Aug 2015 15:50:33 +0200 Subject: [PATCH] Fixed some bugs and cleaned up the code. --- trimsp/src/TrimSPGUI4/TrimSPGUI4.pm | 23 +++++++++++++++-------- 1 file changed, 15 insertions(+), 8 deletions(-) diff --git a/trimsp/src/TrimSPGUI4/TrimSPGUI4.pm b/trimsp/src/TrimSPGUI4/TrimSPGUI4.pm index 1f5cb35..8f93810 100644 --- a/trimsp/src/TrimSPGUI4/TrimSPGUI4.pm +++ b/trimsp/src/TrimSPGUI4/TrimSPGUI4.pm @@ -359,7 +359,11 @@ sub CreateInpFile my $Comp = this->{ui}->layerTable->item($i-1,0)->text(); $All{$LComp} = $Comp; my %LElComp=Chem::parse_formula($Comp); - foreach my $key (keys %LElComp) {if ($key eq "") {$Check++;}} + foreach my $key (keys %LElComp) { + if ($key eq "") { + $Check++; + } + } if ($Comp eq "") {$Check++;} # Write composition to results file header @@ -393,19 +397,23 @@ sub CreateInpFile if ($Sum==0) {$Sum=1;} my @Els = keys %LElComp; - #print join("--",@Els)."\n"; - my $El=""; + for (my $NEl=1;$NEl<=5;$NEl++) { - if ($NEl <= $#Els) { + my $El = ""; + if ($#Els >= $NEl-1) { $El = $Els[$NEl-1]; } my $LEkey = "L".$i."EL"; my $ElZ = Chem::Zof($El); my $ElW = Chem::Massof($El); - my $ElC = $LElComp{$El}/$Sum; my $ElE = Chem::Elastof($El); + my $ElC = 0; my $El030 = 30; - if ($El eq "") { $El030 = 0.0;} + if ($El) { + $ElC = $LElComp{$El}/$Sum; + } else { + $El030 = 0.0; + } $All{$LEkey."Z".$NEl}=sprintf("%8.4f",$ElZ); $All{$LEkey."W".$NEl}=sprintf("%8.4f",$ElW); @@ -571,7 +579,6 @@ sub StartSequenceOne } $iScan++; print "iScan=".$iScan."\n"; - } } else { # For a single run @@ -695,7 +702,7 @@ sub OpenFile my $Attrib=""; foreach my $line (@lines) { # Remove white spaces -# $line =~ s/\s+//g; + $line =~ s/\s+//g; my @InitPar = split (/=/,$line); # Check it is not empty or title line if ($InitPar[0] || $InitPar[1]) {