#======================================================
proc scrib_lib_feature_read_variable_file {file} {
global mv_set
 
  set mv_set(var_nm_lst) ""
  set mv_set(prt_nm_lst) ""
  set mv_set(var_vl_lst) ""
  if ![file exist $file] return
  set f [open $file "r"]
  gets $f txt
  set var_nm [lrange [split $txt ,] 1 end]
  foreach var $var_nm {lappend var_nm_lst [lindex [split $var " "] 0]}
  set var_ln [llength $var_nm_lst]
  while {[gets $f txt] >= 0 } {
        if {[string first "\#" $txt] == 0} continue
        if {[string first "\"" $txt] == 0} continue
        set prt_nm [lindex [split $txt ,] 0]
        if {$prt_nm == ""} continue
        set var_vl [lrange [split $txt ,] 1 end]
        if {$var_ln == [llength $var_vl]} {
           lappend prt_nm_lst $prt_nm
           lappend var_vl_lst $var_vl
           }
     }
   close $f
   if [info exist prt_nm_lst] {
      set mv_set(var_nm_lst) $var_nm_lst
      set mv_set(prt_nm_lst) $prt_nm_lst
      set mv_set(var_vl_lst) $var_vl_lst
      return 1
      }
}
 
#======================================================
proc scrib_lib_feature_set_variable_file {tetin} {
global mv_set proc_scrib_data
 
   for {set i 0} {$i < [llength $mv_set(prt_nm_lst)]} {incr i} {
      set prt [lindex $mv_set(prt_nm_lst) $i]
      if {[string first $prt $tetin] == -1} continue
      set var_vl [lindex $mv_set(var_vl_lst) $i]
      for {set j 0} {$j < [llength $mv_set(var_nm_lst)]} {incr j} {
         set nm [lindex $mv_set(var_nm_lst) $j]
         set vl [string trim [lindex $var_vl $j]]
         if {$vl != ""} {set proc_scrib_data($nm) $vl; ic_mess "NM == $nm   VL == $vl\n" red}
         }
      return 1
      }
}
 

