TABLE OF CONTENTS


::pwtk::input::namelistGetVarNoCase

SYNOPSIS

proc ::pwtk::input::namelistGetVarNoCase {name varName} {

PURPOSE

Get the correct-case name of a variable in the namelist "name". The search rules are: 1. a case-sensitive search of "varName" 2. a case-insensitive search of "varName" 3. if 1+2 fail, "varName" is returned

ARGUMENTS

RETURN VALUE

Either "varName" (case-sensitive) or any other lowercase/uppercase variant of "varName" if present in the namelist. If no lowercase/uppercase variant of "varName" is present in the namelist, a verbatim "varName" is returned.

SOURCE

    global pwtk::input::namelist

    # 1. case-sensitive search
    if { [info exists pwtk::input::namelist($name,var=$varName)] } {
        return $varName
    }

    # 2. case-insensitive search
    set vars [regsub -all $name,var= [array names pwtk::input::namelist -glob $name,var=*] {}]
    set ind  [lsearch -nocase $vars $varName]
    if { $ind > -1 } {
        return [lindex $vars $ind]            
    }

    # 3. varName does not exists in the namelist, return "varName" verbatim
    return $varName
}