Changeset 19 for trunk/readexp.tcl


Ignore:
Timestamp:
Dec 4, 2009 4:59:00 PM (14 years ago)
Author:
toby
Message:

# on 1999/01/06 04:06:41, toby did:
add createexp to create an EXP file
fix bug in exphistory when no HSTRY records are present
add title to expinfo
add set option for name (phase name) in phaseinfo
fix padding in expwrite

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/readexp.tcl

    • Property rcs:date changed from 1999/01/01 18:30:08 to 1999/01/06 04:06:41
    • Property rcs:lines changed from +48 -1 to +37 -10
    • Property rcs:rev changed from 1.3 to 1.4
    r15 r19  
    3838    close $fil
    3939    return 0
     40}
     41
     42proc createexp {expfile title} {
     43    global exparray expmap
     44    catch {unset exparray}
     45    foreach key   {"     VERSION" "      DESCR" "ZZZZZZZZZZZZ" " EXPR NPHAS"} \
     46            value {"   6"         ""            "  Last EXP file record" } {
     47        # truncate long keys & pad short ones
     48        set key [string range "$key        " 0 11]
     49        set exparray($key) $value
     50    }
     51    expinfo title set $title
     52    exphistory add " created readexp.tcl [lindex $expmap(Revision) 1] [clock format [clock seconds]]"
     53    expwrite $expfile
    4054}
    4155
     
    5266    # get the defined phases
    5367    set line [readexp " EXPR NPHAS"]
    54     if {$line == ""} {
    55         set msg "No EXPR NPHAS entry. This is an invalid .EXP file"
    56         tk_dialog .badexp "Error in EXP" $msg error 0 Exit
    57         destroy .
    58     }
     68#    if {$line == ""} {
     69#       set msg "No EXPR NPHAS entry. This is an invalid .EXP file"
     70#       tk_dialog .badexp "Error in EXP" $msg error 0 Exit
     71#       destroy .
     72#    }
    5973    set expmap(phaselist) {}
    6074    # loop over phases
     
    148162proc existsexp {key} {
    149163    global exparray
    150     # key can contain wild cards so dont pad
     164    # key can contain wild cards so don't pad
    151165    return [llength [array names exparray  $key]]
    152166}
     
    245259        set key [lindex [lsort -decreasing [array names exparray *HSTRY*]] 0]
    246260        if {$key == ""} {
    247             set key "    HSTRY  1"
     261            set index 1
    248262        } else {
    249263            set index [string trim [string range $key 9 end]]
     
    262276#     print     -- GENLES print option (*)
    263277#     cycles    -- number of GENLES cycles (*)
     278#     title     -- the overall title (*)
    264279proc expinfo {parm "action get" "value {}"} {
    265280    switch ${parm}-$action {
     281        title-get {
     282            return [string trim [readexp "      DESCR"]]
     283        }
     284        title-set {
     285            setexp "      DESCR" " $value" 1 68
     286        }
     287
    266288        cycles-get {
    267289            return [string trim [cdatget MXCY]]
     
    355377        name-get {
    356378            return [string trim [readexp "CRS$phase    PNAM"]]
     379        }
     380
     381        name-set {
     382            setexp "CRS$phase    PNAM" " $value" 1 68
    357383        }
    358384
     
    10821108proc expwrite {expfile} {
    10831109    global tcl_platform exparray
     1110    set blankline "                                                                   "
    10841111    set fp [open ${expfile} w]
    10851112    set keylist [lsort [array names exparray]]
     
    10901117        foreach key $keylist {
    10911118            puts $fp [string range \
    1092                     "$key$exparray($key)                " 0 79]
     1119                    "$key$exparray($key)$blankline" 0 79]
    10931120        }
    10941121    } else {
    10951122        foreach key $keylist {
    10961123            puts -nonewline $fp [string range \
    1097                     "$key$exparray($key)                " 0 79]
     1124                    "$key$exparray($key)$blankline" 0 79]
    10981125        }
    10991126    }
Note: See TracChangeset for help on using the changeset viewer.