Changeset 15 for trunk/readexp.tcl


Ignore:
Timestamp:
Dec 4, 2009 4:58:56 PM (11 years ago)
Author:
toby
Message:

# on 1999/01/01 18:30:08, toby did:
add existsexp, delexp, exphistory
change cdatget to use existsexp to avoid the debug warning

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/readexp.tcl

    • Property rcs:date changed from 1998/12/28 02:34:29 to 1999/01/01 18:30:08
    • Property rcs:lines changed from +4 -2 to +48 -1
    • Property rcs:rev changed from 1.2 to 1.3
    r13 r15  
    145145}
    146146
     147# return the number of records matching ISAM key (may contain wildcards)
     148proc existsexp {key} {
     149    global exparray
     150    # key can contain wild cards so dont pad
     151    return [llength [array names exparray  $key]]
     152}
     153
     154
    147155# replace a section of the exparray with $value
    148156#   replace $char characters starting at character $start (numbered from 1)
     
    183191}
    184192
     193# delete an exp recorde
     194# returns 1 if OK; 0 if not found
     195proc delexp {key} {
     196    global exparray
     197    # truncate long keys & pad short ones
     198    set key [string range "$key        " 0 11]
     199    if [catch {unset exparray($key)}] {
     200        return 0
     201    }
     202    return 1
     203}
    185204# test an argument if it is a valid number; reform the number to fit
    186205proc validreal {val length decimal} {
     
    212231}
    213232
     233# process history information
     234#    action == last
     235#       returns number and value of last record
     236#    action == add
     237#
     238proc exphistory {action "value 0"} {
     239    global exparray
     240    if {$action == "last"} {
     241        set key [lindex [lsort -decreasing [array names exparray *HSTRY*]] 0]
     242        if {$key == ""} {return ""}
     243        return [list [string trim [string range $key 9 end]] $exparray($key)]
     244    } elseif {$action == "add"} {
     245        set key [lindex [lsort -decreasing [array names exparray *HSTRY*]] 0]
     246        if {$key == ""} {
     247            set key "    HSTRY  1"
     248        } else {
     249            set index [string trim [string range $key 9 end]]
     250            if {$index != "***"} {
     251                if {$index < 999} {incr index}
     252                set key [format "    HSTRY%3d" $index]
     253                set exparray($key) $value
     254            }
     255        }
     256        set key [format "    HSTRY%3d" $index]
     257        set exparray($key) $value
     258    }
     259}
    214260# get overall info
    215261#   parm:
     
    245291proc cdatget {key} {
    246292    foreach i {1 2 3 4 5 6 7 8 9} {
     293        if {[existsexp "  GNLS CDAT$i"] == 0} break
    247294        set line [readexp "  GNLS CDAT$i"]
    248295        if {$line == {}} break
Note: See TracChangeset for help on using the changeset viewer.