From cf9777c5071cfdd30944d75fdc8ee0f3f3ba10cf Mon Sep 17 00:00:00 2001 From: Zaher Salman Date: Mon, 12 Oct 2015 16:43:02 +0200 Subject: [PATCH] Added checking for chemical formula in perl-qt3. --- trimsp/src/TrimSPGUI/TrimSPGUI.pl | 10 ++++++++-- trimsp/src/TrimSPGUI4/TrimSPGUI4.pm | 3 +-- 2 files changed, 9 insertions(+), 4 deletions(-) diff --git a/trimsp/src/TrimSPGUI/TrimSPGUI.pl b/trimsp/src/TrimSPGUI/TrimSPGUI.pl index 860de7e..76fbf3e 100644 --- a/trimsp/src/TrimSPGUI/TrimSPGUI.pl +++ b/trimsp/src/TrimSPGUI/TrimSPGUI.pl @@ -2388,6 +2388,12 @@ sub CreateInpFile my $Comp = layerTable->text($i-1,0); $All{$LComp} = $Comp; my %LElComp=Chem::parse_formula($Comp); + foreach my $key (keys %LElComp) { +# Check if composition is understood + if ($key eq "" || Chem::Zof($key) eq "") { + $Check++; + } + } if ($Comp eq "") {$Check++;} # Densities of layers @@ -2403,8 +2409,8 @@ sub CreateInpFile if ($d eq "") {$Check++;} # Sanity check, is the layer supposed to have value? are they all there? - if ($Check!=0) { - my $ErrMsg="Error: Layer $i is empty. Expecting it to be defined!\n"; + if ($Check!=0 ) { + my $ErrMsg="Error: Bad chemical formula in Layer $i.\nPleach check!\n"; print STDERR $ErrMsg; my $HelpWindow = Qt::MessageBox::information( this, "Error!",$ErrMsg); return "ERROR"; diff --git a/trimsp/src/TrimSPGUI4/TrimSPGUI4.pm b/trimsp/src/TrimSPGUI4/TrimSPGUI4.pm index 7ffc42f..8b12acb 100644 --- a/trimsp/src/TrimSPGUI4/TrimSPGUI4.pm +++ b/trimsp/src/TrimSPGUI4/TrimSPGUI4.pm @@ -363,8 +363,7 @@ sub CreateInpFile # Check if composition is understood if ($key eq "" || Chem::Zof($key) eq "") { $Check++; - } - + } } if ($Comp eq "") {$Check++;} # Write composition to results file header