Changeset 128 for trunk/readexp.tcl


Ignore:
Timestamp:
Dec 4, 2009 5:00:52 PM (11 years ago)
Author:
toby
Message:

# on 2000/05/16 21:48:45, toby did:
set expload return value to indicate when .EXP files are "fixed"
add expmap(phasetype) to indicate phase types
ignore * histgrams (I forget why)
fix error that caused 1st character in phase & overall titles to be lost

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/readexp.tcl

    • Property rcs:date changed from 2000/02/02 17:42:20 to 2000/05/16 21:48:45
    • Property rcs:lines changed from +12 -3 to +23 -13
    • Property rcs:rev changed from 1.12 to 1.13
    r124 r128  
    66#   ... reading an EXP file into an array
    77proc expload {expfile} {
    8     global exparray tcl_platform
     8    global exparray
    99    # $expfile is the path to the data file.
    1010    if [catch {set fil [open "$expfile" r]}] {
    1111        tk_dialog .expFileErrorMsg "File Open Error" \
    12                 "Unable to open file $expfile" error 0 "Exit" ; return 1
     12                "Unable to open file $expfile" error 0 "Exit" ; return -1
    1313    }
    1414    set len [gets $fil line]
     
    1717                "You are using an old version of Tcl/Tk and your .EXP file has binary characters; run convstod or upgrade" \
    1818                error 0 "Exit"
    19         exit
     19        return -1
     20    }
     21    catch {
     22        unset exparray
    2023    }
    2124    if {$len > 160} {
     25        set fmt 0
    2226        # a UNIX-type file
    2327        set i1 0
     
    3135        }
    3236    } else {
     37        set fmt 1
    3338        while {$len > 0} {
    3439            set key [string range $line 0 11]
     
    3843    }
    3944    close $fil
    40     return 0
     45    return $fmt
    4146}
    4247
     
    5863#   creates the following entries in global array expmap
    5964#     expmap(phaselist)     gives a list of defined phases
     65#     expmap(phasetype)     gives the phase type for each defined phase
     66#                           =1 nuclear; 2 mag+nuc; 3 mag; 4 macro
    6067#     expmap(atomlist_$p)   gives a list of defined atoms in phase $p
    6168#     expmap(htype_$n)      gives the GSAS histogram type for histogram
     
    7380#    }
    7481    set expmap(phaselist) {}
     82    set expmap(phasetype) {}
    7583    # loop over phases
    7684    foreach iph {1 2 3 4 5 6 7 8 9} {
     
    7987        set flag [string trim [string range $line $i5s $i5e]]
    8088        if {$flag == ""} {set flag 0}
    81         if $flag {lappend expmap(phaselist) $iph}
     89        if $flag {
     90            lappend expmap(phaselist) $iph
     91            lappend expmap(phasetype) $flag
     92        }
    8293    }
    8394    # get the list of defined atoms for each phase
     
    116127        set expmap(htype_$ihist) [lindex $line $j]
    117128        # at least for now, ignore non-powder histograms
    118         if {[string range $expmap(htype_$ihist) 0 0] == "P"} {
     129        if {[string range $expmap(htype_$ihist) 0 0] == "P" && \
     130                [string range $expmap(htype_$ihist) 3 3] != "*"} {
    119131            lappend expmap(powderlist) $ihist
    120132        }
     
    206218}
    207219
    208 # delete an exp recorde
     220# delete an exp record
    209221# returns 1 if OK; 0 if not found
    210222proc delexp {key} {
     
    284296        }
    285297        title-set {
    286             setexp "      DESCR" " $value" 1 68
     298            setexp "      DESCR" " $value" 2 68
    287299        }
    288300
     
    386398
    387399        name-set {
    388             setexp "CRS$phase    PNAM" " $value" 1 68
     400            setexp "CRS$phase    PNAM" " $value" 2 68
    389401        }
    390402
     
    11761188    return [llength [array names exparray {    HSTRY*}]]
    11771189}
    1178 
    1179 
Note: See TracChangeset for help on using the changeset viewer.