TABLE OF CONTENTS
::pwtk::ATOMIC_SPECIES_math_parser
SYNOPSIS
proc ::pwtk::ATOMIC_SPECIES_math_parser {content} {
PURPOSE
Specially supplied math-parser for ATOMIC_SPECIES card to yield nicely formated output.
RETURN VALUE
Nicely formated ATOMIC_SPECIES card.
SOURCE
variable fmt_atmPos set charge 0 set result "" set species [split [::pwtk::skipEmptyLines $content] \n] # get the max length of symb & mass number set sl 0 set ml 0 foreach line $species { if { ! [::pwtk::is_comment $line] } { lassign $line symb mass if {[string length $symb] > $sl} { set sl [string length $symb] } set mass [evalExpr $mass] if {[string length $mass] > $ml} { set ml [string length $mass] } } } # nicely format foreach line $species { if { [::pwtk::is_comment $line] } { append result [string trim $line]\n continue } if { [llength $line] != 3 } { ::pwtk::error "wrong format of the ATOMIC_SPECIES card. Each line must consists of 3 columns, but got:\n\n$content" 1 } lassign $line symb mass ppFile if { ! [is_double $mass] } { ::pwtk::error "expected a number for atomic mass, but got $mass" 1 } append result [format {%-4s%-*s %-*s %s} { } $sl $symb $ml [evalExpr $mass] $ppFile]\n } return $result }