# ===========================================================================
#  Copyright 1999 SAS IP, Inc. Proprietary Data.
#  Unauthorized use, distribution, or duplication is prohibited.
#  All Rights Reserved.
# ============================================================================
#  $Revision: 615939 $
#  $Date: 2013-01-30 14:21:14 -0500 (Wed, 30 Jan 2013) $
# ============================================================================
# File Name:     ModelControl.eui
# Description:   Define Material Models for ANSYS
# ============================================================================

package require msgcat

set imagePath [file join $env(EUIDL_DIR) gui $::euidl::euidlArray(language) images]

image create photo mtlclose -file [file join $imagePath mtlclose16x16.png]
image create photo mtlopen  -file [file join $imagePath mtlopen16x16.png]
image create photo mtlicon  -file [file join $imagePath mtlicon16x16.png]

namespace eval ::euidl::material::ModelControl {} {

   variable matModelArr
   variable externalMatlInfoArr
   variable localMatlInfoArr
   #variable ::euidl::material::ModelControl::matModelArr

   option add *MatOpts*padX 5 startupFile
   option add *MatOpts*padY 3 startupFile
   option add *MatOpts*EuidlEntry*width 12 startupFile

   ::euidl::setImageDir [file join $env(EUIDL_DIR) gui $euidl::euidlArray(language) images]
   
   proc create { {matlID 0} {cb {}} {extMatlArr {}} {WBMode 0} } {
      variable parent
      variable childsite
      variable treeParent
      variable child
      variable matid
      variable left
      variable treeMaterialParent
      variable treeModelParent
      variable modControlMenu
      variable emptyfolder
      variable treeChildsite
      variable matModelArr

      variable extCallback
      variable extMatlID
      variable ptrMatlInfoArr
      variable localMatlInfoArr

      variable menuItems

      variable numFavorites
      variable favoritesList
      variable WBModeGlobal
      
      catch {AnsysGUI::AnsysToolbarState ANS_STD__N AnsDynamic disabled}
      ans_greygui 0 0
      ans_greygui 1 0
      ans_greygui 3 0
      ans_greygui 4 0

      set WBModeGlobal $WBMode
      set extCallback $cb

      set extMatlID $matlID
      set ptrMatlInfoArr $extMatlArr
      unset extMatlArr
 
      # Resume the favorites automatically when leaving the dialog
      set lsdyna [ans_getvalue active,,keyw,,lsdyna]

      if {$lsdyna == 0} {
         ::euidl::material::favorites::resume
      } else {
         ::euidl::material::favorites::resumedyna
      }

      if {[info exists localMatlInfoArr]} {
         unset localMatlInfoArr
      }

      if {![string match {} $ptrMatlInfoArr]} {
         upvar #0 $ptrMatlInfoArr extMatlArr
         array set localMatlInfoArr [array get extMatlArr]
      }
      
       if {[winfo exists .modControl]} {
             if {$extMatlID} {
                set matid $extMatlID
             }
             refresh
             wm deiconify $parent
             raise $parent
             return
       }
      #BINDINGS#
     
      # The use of /NOPR and /GO should not be used the usage in this
      # file is very convoluted and so just get the value coming in
      # and set it back when exiting
      set matModelArr(printStatus) [ans_getvalue active,,prkey]


      #bind all <Alt-KeyPress-d> [code delete]
      #bind all <Alt-KeyPress-c> [code ans_sendcommand Fnc_CopyMatModel]
      #bind all <Alt-KeyPress-n> [code New]
  
      set emptyfolder [ list ]

      set parent [euidl::dialog .modControl -class EUIDL \
             -master NULL \
             -okbutton 0 -helpbutton 0 -cancelbutton 0 ]

      # The window needs to be registered to cause another UIDL call
      # to withdraw this window.
      ::uidl::registerWindow $parent 

      set matModelArr(parent) $parent

      set childsite [$parent component childsite]
      wm title $parent [msgcat::mc "Define Material Model Behavior"]
      wm minsize $parent 500 300

      # Create the menubar
      set modControlMenu [menu $childsite.menubar]

      if {$WBMode} {
         set menuItems [list Material Help]
      } else {
         set menuItems [list Material Edit Favorite Help]
      }

      foreach m $menuItems {
           if {[string match $m Help]} {
               continue
           }
           set $m [menu $modControlMenu.m$m -tearoff 0]
           $modControlMenu add cascade -label [msgcat::mc "$m"] \
             -menu $modControlMenu.m$m
      }
      
      if {!$WBMode} {
         $Material add command \
               -label [msgcat::mc "New Model ..."] -command  [code New]
      }

      $Material add command -label [msgcat::mc "Exit"] -command  [code exitMaterialModel]
      if {!$WBMode} {
         $Edit add command -label [msgcat::mc "Copy ..."] \
            -command  [ code  copy]
         $Edit add command -label [msgcat::mc "Delete"] \
            -command  [ code delete]
      }

      if {!$WBMode} {
         $Favorite add command \
               -label [msgcat::mc "New Favorite ..."] -command  [code NewFavorite]
      }
      if {!$WBMode} {
         $Favorite add command \
               -label [msgcat::mc "Delete Favorite ..."] -command  [code DeleteFavorite]
      }

      $modControlMenu add command -label [msgcat::mc "Help"] \
          -command  [list ans_loadhelp Hlp_UI_def_mat]

      $parent config -menu $modControlMenu -cancelcommand [code exitMaterialModel]



       # get key for LS-DYNA to branch off if LS-DYNA is chosen
       set lsdyna [ans_getvalue active,,keyw,,lsdyna]

        set maxMatlDef [ans_evalexpr mpinqr(0,0,14)]
        set matnum 1
        set matid 1
        if {$extMatlID} {
            set matid $extMatlID
        }

        set matidlocal [ans_evalexpr mpnext(0)]

        if {$maxMatlDef > 0} {
            while {$matidlocal > 0} {
               lappend matlist {[list $matidlocal] %n}
               set matnum $matidlocal
               set matidlocal [ans_evalexpr mpnext($matidlocal)]
            }

         } else {
            set matnum 1
            set matid 1
            lappend matlist [list $matnum ]
         }


        set left [euidl::labeledframe $childsite.left \
                 -text [msgcat::mc "Material Models Defined"]]
        grid $left -row 1 -column 0  -sticky news
        set left [$left childsite]
        set right [euidl::labeledframe $childsite.right \
                 -text [msgcat::mc "Material Models Available"]]
        grid $right -row 1 -column 1  -sticky news
        set right [$right childsite]
        grid  columnconfigure $childsite 1 -weight 2
        grid  columnconfigure $childsite 0 -weight 1
        grid  rowconfigure $childsite 1 -weight 1

       

       
        #Tree for the left side

        set treeMaterialParent [euidl::hierarchy $left.modelControl \
         -querycommand [list [namespace code getMaterialNodes] %n] \
         -selectcommand [list [namespace code Selection] %n %s ] \
         -execcommand [list [namespace code select_Materialnode] %n %s] \
              -alwaysquery 1 \
              -closedicon mtlclose \
              -openicon mtlopen \
              -nodeicon mtlicon \
              -style single \
         -contextmenu 1 \
         -width 250 \
         -height 251 \
      ]
      $treeMaterialParent deleteContextMenu end
      set cmindex 0
      $treeMaterialParent insertContextMenu $cmindex command \
            -label [::msgcat::mc "Delete"] \
            -underline 0 \
            -command [namespace code delete]
      incr cmindex
      $treeMaterialParent insertContextMenu $cmindex command \
            -label [::msgcat::mc "Copy"] \
            -underline 0 \
            -command [namespace code copy]

        grid $treeMaterialParent -sticky news  -row 0 -column 0
    
 
      #Tree for the right side

      set treeModelParent [euidl::hierarchy $right.modelControl \
         -querycommand [list [namespace code getModelNodes] %n ] \
        -selectcommand [list [namespace code SelectionFake] %n %s ] \
         -execcommand [list [namespace code select_Modelnode] %n %s ]\
              -alwaysquery 1 \
              -closedicon mtlclose \
              -openicon mtlopen \
              -nodeicon mtlicon \
              -style single \
        -width 350 \
        -height 250 \
      ]
        grid $treeModelParent -sticky news
        grid  columnconfigure $right 0 -weight 1
        grid  columnconfigure $left 0 -weight 1
        grid  rowconfigure $right 0 -weight 1
        grid  rowconfigure $left 0 -weight 1

        set treeChildsite $childsite

        update idletasks
        wm minsize $parent [winfo reqwidth $parent] \
                           [winfo reqheight $parent]

        after 250 [list $parent activate]
        return 0
   }
   

    proc refreshL {} {
         
        variable treeMaterialParent 
        variable matid  
            

#        $treeMaterialParent configure \
#             -querycommand [list [namespace code getMaterialNodes] %n] \
#             -execcommand [list [namespace code select_Materialnode] %n %s]\
#             -selectcommand [list [namespace code Selection] %n %s]
#
#       update idletasks
#       
#       catch {$treeMaterialParent expand matroot_$matid}

        if { ![catch {$treeMaterialParent expanded matroot_$matid} expanded] } {
           if { !$expanded } {
               catch {$treeMaterialParent expand matroot_$matid}
           }
        }
        $treeMaterialParent draw
        
    }
    
    proc refresh {} {
        
         variable treeMaterialParent
         variable treeModelParent
       
        

      if { ![winfo exists $treeMaterialParent] } {
         return 0
      }
        $treeMaterialParent clear
        $treeMaterialParent draw
        $treeModelParent draw
#        $treeMaterialParent configure \
#             -querycommand [list [namespace code getMaterialNodes] %n] \
#             -execcommand [list [namespace code select_Materialnode] %n %s]\
#             -selectcommand [list [namespace code Selection] %n %s]
      return 0
    }


     proc Selection { node args } {
       variable treeMaterialParent
       variable matid
       variable label
       
       variable curvenum
      
       $treeMaterialParent selection clear
       $treeMaterialParent selection add $node


      
       set toto  [lindex $node 0]
       set list [split $toto _]
       set label  [lindex $list 0]
       set matid  [lindex $list 1]
       if {$label == "matroot"} {
          set label "ALL"
       }
       set curvenum [lindex $list 2]  
       
    }
    
     proc SelectionFake { node args } {
       variable treeModelParent
       
       $treeModelParent selection clear
       $treeModelParent selection add $node
             
    }

    proc delete {} {
       variable matid
       variable label
       variable emptyfolder
       variable curvenum
      
       if { ![info exists label] } {
          return
       }

       if {$label == "ALL"} {
           set mod [ans_evalexpr mpinqr($matid,0,1)]
           set cfit 0
       #    uncomment for using curvefit data in LHS
       #    set cfit [::euidl::material::CurveFit::CurveFitExists $matid]
           set tot [expr $mod + $cfit]
           if {$tot > 0} {
              if {$mod >0} {
                 catch {ans_sendcommand MPDE,$label,$matid}
                 catch {ans_sendcommand TBDE,$label,$matid}
                 catch {ans_sendcommand MPTEMP,,,,,,,}
              }
              if {$cfit > 0} {
                 catch {ans_sendcommand TBFT,MDEL,$matid}
              }
           } else {
             
              set hx [lsearch -exact $emptyfolder $matid]
              # remove the material from the empty folder list
              set emptyfolder [lreplace $emptyfolder $hx $hx]  
           }
       } else {
         set listTBnames {NLIS MELA CHAB MISO BISO ANEL HILL PLAS1 PLAS4\
                        BKIN ANAN ANIS DPER MKIN EVIS KINH USER FCON\
                        HFLM BH RATE CONC STAT SWEL FAIL PIEZ PZRS MOON}
       
         set ix [lsearch -exact $listTBnames $label]
         if {$ix >= 0} {
             catch {ans_sendcommand TBDE,$label,$matid}
         } else {
         
            set listMPmulti {ISOT ORTH ALPI ALPO KORT MURO MGOR PERO RSVO\
                           CTEI CTEO THSI THSO DP0 DP1 DP2 SBKO\
                           CREE CREE1 CREE2 CREE3 CREE4 CREE5 CREE6 CREE7\
                           CREE8 CREE9 CREE10 CREE11 CREE12 CREE13 CREE100\
                           HYPEmo2 HYPEmo3 HYPEmo5 HYPEmo9 \
                           HYPEog1 HYPEog2 HYPEog3 HYPEog4 HYPEog5 HYPEogG \
                           HYPEye1 HYPEye2 HYPEye3 HYPEye4 HYPEye5 HYPEyeG \
                           HYPEfo1 HYPEfo2 HYPEfo3 HYPEfo4 HYPEfo5 HYPEfoG \
                           HYPE5 HYPEpo1 HYPEpo2  HYPEpo3 HYPEpo4 HYPEpo5 HYPEpoG \
                           HYPE8 HYPE100 ISOTdyn ORTHdyn ANELdyn FLUIdyn BLAT\
                           HYPE3 HYPE4 HYPE10 HYPE11\
                           EVISC MOONdyn MOON1dyn BISOdyn BISOtmp BKINdyn KINEdyn\
                           ANISdyn ANISfld JOINTSTIF JOINTDAMP JOINTFRIC\
                           JOINTJNSA JOINTJNS4 JOINTJNS6\
                           JOINTJNDA JOINTJND4 JOINTJND6\
                           JOINTJNFA JOINTJNF4 JOINTJNF6\
                           BAR3dyn BARLdyn COMPdyn CONCdyn SENSdyn DEPdyn\
                           LINRdyn LINR1dyn PLAWdyn HYDRdyn GEOdyn THERMdyn \
                           CELLdyn  VISCdyn DENSdyn\
                           CRSHdyn HONEdyn JOHN1dyn NULL1dyn ZERI1dyn STEN1dyn\
                           JOHN2dyn NULL2dyn ZERI2dyn STEN2dyn JOHN3dyn \
                           NULL3dyn ZERI3dyn STEN3dyn BAMMdyn SPNGdyn NLSPdyn\
                           NLESdyn ELSPdyn INSPdyn MAXSdyn LNVIdyn NLVIdyn\
                           CABLdyn RIGIdyn UNIACOMP UNIATENS CAST CAST1 CAST2\
                           SHIFT SHIFT1 SHIFT2 SHIFT3 PRONYSHEAR PRONYBULK \
                           GASKPARA GASKCOMP GASKLUNL GASKNUNL GASKTSS \
                           BETI BETO DORT }
         
            set mx [lsearch -exact $listMPmulti $label]
         
            if {$mx >= 0} {                           
             switch -glob -- $label {
             
             ISOT {
                   foreach lab {EX PRXY NUXY} {
                        catch {ans_sendcommand MPDE,$lab,$matid}
                   }
             } 
             ISOTdyn {
                   foreach lab {DENS EX NUXY PRXY} {
                        catch {ans_sendcommand MPDE,$lab,$matid}
                   }
             } 
             ORTHdyn {
                   foreach lab {DENS EX EY EZ \
                              NUXY NUYZ NUXZ GXY GYZ GXZ} {
                        catch {ans_sendcommand MPDE,$lab,$matid}
                   }
             } 
             ANELdyn {
                   foreach lab {DENS EX} {
                        catch {ans_sendcommand MPDE,$lab,$matid}
                   }
                   catch {ans_sendcommand TBDE,ANEL,$matid}
             } 
             FLUIdyn {
                   foreach lab {DENS EX NUXY FLUI} {
                        catch {ans_sendcommand MPDE,$lab,$matid}
                   }
             } 
             BLAT {
                   foreach lab {DENS GXY} {
                        catch {ans_sendcommand MPDE,$lab,$matid}
                   }
             } 
             MOONdyn {
                   foreach lab {DENS NUXY} {
                        catch {ans_sendcommand MPDE,$lab,$matid}
                   }
                   catch {ans_sendcommand TBDE,MOONEY,$matid}
             } 
             MOON1dyn {
                   foreach lab {DENS NUXY} {
                        catch {ans_sendcommand MPDE,$lab,$matid}
                   }
                   catch {ans_sendcommand TBDE,MOONEY,$matid}
             } 
             EVISC {
                   foreach lab {DENS} {
                        catch {ans_sendcommand MPDE,$lab,$matid}
                   }
                   catch {ans_sendcommand TBDE,EVIS,$matid}
             } 
             BISOdyn {
                   foreach lab {DENS EX NUXY} {
                        catch {ans_sendcommand MPDE,$lab,$matid}
                   }
                   catch {ans_sendcommand TBDE,BISO,$matid}
             } 
             BISOtmp {
                   catch {ans_sendcommand MPTEMP,,,,,,,,}
                   foreach lab {DENS EX NUXY ALPX} {
                        catch {ans_sendcommand MPDE,$lab,$matid}
                   }
                   catch {ans_sendcommand TBDE,BISO,$matid}
             } 
             ANISdyn {
                   foreach lab {DENS EX NUXY} {
                        catch {ans_sendcommand MPDE,$lab,$matid}
                   }
                  catch {ans_sendcommand TBDE,PLAW,$matid}
             } 
             ANISfld {
                   foreach lab {DENS EX NUXY} {
                        catch {ans_sendcommand MPDE,$lab,$matid}
                   }
                   catch {ans_sendcommand TBDE,PLAW,$matid}
             } 
             BKINdyn {
                   foreach lab {DENS EX NUXY} {
                        catch {ans_sendcommand MPDE,$lab,$matid}
                   }
                   catch {ans_sendcommand TBDE,BKIN,$matid}
             } 
             KINEdyn {
                   foreach lab {DENS EX NUXY} {
                        catch {ans_sendcommand MPDE,$lab,$matid}
                   }
                   catch {ans_sendcommand TBDE,PLAW,$matid}
             } 
             BAR3dyn {
                   foreach lab {DENS EX NUXY} {
                        catch {ans_sendcommand MPDE,$lab,$matid}
                   }
                   catch {ans_sendcommand TBDE,PLAW,$matid}
             } 
             BARLdyn {
                   foreach lab {DENS EX NUXY} {
                        catch {ans_sendcommand MPDE,$lab,$matid}
                   }
                   catch {ans_sendcommand TBDE,PLAW,$matid}
             } 
             COMPdyn {
                   foreach lab {DENS EX EY EZ GXY GYZ\
                        GXZ NUXY NUYZ NUXZ} {
                        catch {ans_sendcommand MPDE,$lab,$matid}
                   }
                   catch {ans_sendcommand TBDE,COMP,$matid}
             } 
             CONCdyn {
                   foreach lab {DENS NUXY} {
                        catch {ans_sendcommand MPDE,$lab,$matid}
                   }
                   catch {ans_sendcommand TBDE,CONCR,$matid}
             } 
             SENSdyn {
                   foreach lab {DENS EX NUXY} {
                        catch {ans_sendcommand MPDE,$lab,$matid}
                   }
                   catch {ans_sendcommand TBDE,PLAW,$matid}
             } 
             DEPdyn {
                   foreach lab {DENS EX NUXY} {
                        catch {ans_sendcommand MPDE,$lab,$matid}
                   }
                   catch {ans_sendcommand TBDE,PLAW,$matid}
             } 
             LINRdyn {
                   foreach lab {DENS EX NUXY} {
                        catch {ans_sendcommand MPDE,$lab,$matid}
                   }
                   catch {ans_sendcommand TBDE,PLAW,$matid}
             } 
             LINR1dyn {
                   foreach lab {DENS EX NUXY} {
                        catch {ans_sendcommand MPDE,$lab,$matid}
                   }
                   catch {ans_sendcommand TBDE,PLAW,$matid}
             } 
             PLAWdyn {
                   foreach lab {DENS EX NUXY} {
                        catch {ans_sendcommand MPDE,$lab,$matid}
                   }
                   catch {ans_sendcommand TBDE,PLAW,$matid}
             } 
             HYDRdyn {
                   foreach lab {DENS EX GXY} {
                        catch {ans_sendcommand MPDE,$lab,$matid}
                   }
                   catch {ans_sendcommand TBDE,PLAW,$matid}
             } 
             GEOdyn {
                   foreach lab {DENS GXY} {
                        catch {ans_sendcommand MPDE,$lab,$matid}
                   }
                   catch {ans_sendcommand TBDE,GCAP,$matid}
             } 
             THERMdyn {
                   foreach lab {DENS EX NUXY ALPX} {
                        catch {ans_sendcommand MPDE,$lab,$matid}
                   }
                   catch {ans_sendcommand TBDE,PLAW,$matid}
             } 
             CELLdyn {
                   foreach lab {DENS EX} {
                        catch {ans_sendcommand MPDE,$lab,$matid}
                   }
                   catch {ans_sendcommand TBDE,FOAM,$matid}
             } 
             VISCdyn {
                   foreach lab {DENS EX NUXY} {
                        catch {ans_sendcommand MPDE,$lab,$matid}
                   }
                   catch {ans_sendcommand TBDE,FOAM,$matid}
             } 
             DENSdyn {
                   foreach lab {DENS EX} {
                        catch {ans_sendcommand MPDE,$lab,$matid}
                   }
                   catch {ans_sendcommand TBDE,FOAM,$matid}
             } 
             CRSHdyn {
                   foreach lab {DENS EX NUXY} {
                        catch {ans_sendcommand MPDE,$lab,$matid}
                   }
                   catch {ans_sendcommand TBDE,FOAM,$matid}
             } 
             HONEdyn {
                   foreach lab {DENS EX NUXY} {
                        catch {ans_sendcommand MPDE,$lab,$matid}
                   }
                   catch {ans_sendcommand TBDE,HONE,$matid}
             } 
             JOHN* {
                   foreach lab {DENS EX NUXY} {
                        catch {ans_sendcommand MPDE,$lab,$matid}
                   }
                   catch {ans_sendcommand TBDE,EOS,$matid}
             } 
             NULL* {
                   foreach lab {DENS EX NUXY} {
                        catch {ans_sendcommand MPDE,$lab,$matid}
                   }
                   catch {ans_sendcommand TBDE,EOS,$matid}
             } 
             ZERI* {
                   foreach lab {DENS EX NUXY} {
                        catch {ans_sendcommand MPDE,$lab,$matid}
                   }
                  catch {ans_sendcommand TBDE,EOS,$matid}
             } 
             STEN* {
                   foreach lab {DENS GXY NUXY} {
                        catch {ans_sendcommand MPDE,$lab,$matid}
                   }
                   catch {ans_sendcommand TBDE,EOS,$matid}
             } 
             BAMMdyn {
                   foreach lab {DENS EX NUXY} {
                        catch {ans_sendcommand MPDE,$lab,$matid}
                   }
                   catch {ans_sendcommand TBDE,EOS,$matid}
             } 
             SPNGdyn {
                   foreach lab {DENS EX NUXY} {
                        catch {ans_sendcommand MPDE,$lab,$matid}
                   }
                   catch {ans_sendcommand TBDE,DISC,$matid}
             } 
             NLSPdyn {
                   foreach lab {DENS EX NUXY} {
                        catch {ans_sendcommand MPDE,$lab,$matid}
                   }
                   catch {ans_sendcommand TBDE,DISC,$matid}
             } 
             NLESdyn {
                   foreach lab {DENS EX NUXY} {
                        catch {ans_sendcommand MPDE,$lab,$matid}
                   }
                   catch {ans_sendcommand TBDE,DISC,$matid}
             } 
             ELSPdyn {
                   foreach lab {DENS EX NUXY} {
                        catch {ans_sendcommand MPDE,$lab,$matid}
                   }
                   catch {ans_sendcommand TBDE,DISC,$matid}
             } 
             INSPdyn {
                   foreach lab {DENS EX NUXY} {
                        catch {ans_sendcommand MPDE,$lab,$matid}
                   }
                   catch {ans_sendcommand TBDE,DISC,$matid}
             } 
             MAXSdyn {
                   foreach lab {DENS EX NUXY} {
                        catch {ans_sendcommand MPDE,$lab,$matid}
                   }
                   catch {ans_sendcommand TBDE,DISC,$matid}
             } 
             LNVIdyn {
                   foreach lab {DENS EX NUXY} {
                        catch {ans_sendcommand MPDE,$lab,$matid}
                   }
                   catch {ans_sendcommand TBDE,DISC,$matid}
             } 
             NLVIdyn {
                   foreach lab {DENS EX NUXY} {
                        catch {ans_sendcommand MPDE,$lab,$matid}
                   }
                   catch {ans_sendcommand TBDE,DISC,$matid}
             } 
             CABLdyn {
                   foreach lab {DENS EX CABL} {
                        catch {ans_sendcommand MPDE,$lab,$matid}
                   }
             } 
             RIGIdyn {
                   foreach lab {DENS EX NUXY RIGI} {
                        catch {ans_sendcommand MPDE,$lab,$matid}
                   }
             } 
             HYPE* {                  
                  catch {ans_sendcommand TBDE,HYPE,$matid}
             }
             CREE* {                  
                  catch {ans_sendcommand TBDE,CREE,$matid}
             }
             DP* {                  
                  catch {ans_sendcommand TBDE,DP,$matid}
             }
             SHIFT* {
                  catch {ans_sendcommand TBDE,SHIFT,$matid}
             }
             CAST* {
                  catch {ans_sendcommand TBDE,CAST,$matid}
             }
             UNIACOMP {                  
                  catch {ans_sendcommand TBDE,UNIA,$matid,,,COMP}
             }
             UNIATENS {                  
                  catch {ans_sendcommand TBDE,UNIA,$matid,,,TENS}
             }
             PRONYSHEAR {                  
                  catch {ans_sendcommand TBDE,PRONY,$matid,,,SHEAR}
             }
             PRONYBULK {                  
                  catch {ans_sendcommand TBDE,PRONY,$matid,,,BULK}
             }
             GASKPARA {                  
                  catch {ans_sendcommand TBDE,GASK,$matid,,,PARA}
             }
             GASKCOMP {                  
                  catch {ans_sendcommand TBDE,GASK,$matid,,,COMP}
             }
             GASKLUNL {                  
                  catch {ans_sendcommand TBDE,GASK,$matid,,,LUNL}
             }
             GASKNUNL {                  
                  catch {ans_sendcommand TBDE,GASK,$matid,,,NUNL}
             }
             GASKTSS {                  
                  catch {ans_sendcommand TBDE,GASK,$matid,,,TSS}
             }
             JOINTSTIF {                  
                  catch {ans_sendcommand TBDE,JOINT,$matid,,,STIF}
             }
             JOINTDAMP {                  
                  catch {ans_sendcommand TBDE,JOINT,$matid,,,DAMP}
             }
             JOINTFRIC {                  
                  catch {ans_sendcommand TBDE,JOINT,$matid,,,FRIC}
             }
             JOINTJNSA {                  
                  catch {ans_sendcommand TBDE,JOINT,$matid,,,JNSA}
             }
             JOINTJNS4 {                  
                  catch {ans_sendcommand TBDE,JOINT,$matid,,,JNS4}
             }
             JOINTJNS6 {                  
                  catch {ans_sendcommand TBDE,JOINT,$matid,,,JNS6}
             }
             JOINTJNDA {                  
                  catch {ans_sendcommand TBDE,JOINT,$matid,,,JNDA}
             }
             JOINTJND4 {                  
                  catch {ans_sendcommand TBDE,JOINT,$matid,,,JND4}
             }
             JOINTJND6 {                  
                  catch {ans_sendcommand TBDE,JOINT,$matid,,,JND6}
             }
             JOINTJNFA {                  
                  catch {ans_sendcommand TBDE,JOINT,$matid,,,JNFA}
             }
             JOINTJNF4 {                  
                  catch {ans_sendcommand TBDE,JOINT,$matid,,,JNF4}
             }
             JOINTJNF6 {                  
                  catch {ans_sendcommand TBDE,JOINT,$matid,,,JNF6}
             }
             ORTH { 
                   foreach lab {EX EY EZ PRXY PRYZ PRXZ \
                        NUXY NUYZ NUXZ GXY GYZ GXZ} {
                        catch {ans_sendcommand MPDE,$lab,$matid}
                   }
             } 
             ALPI {
                   foreach lab {ALPX REFT} {
                        catch {ans_sendcommand MPDE,$lab,$matid}
                   }
             }
             ALPO {
                   foreach lab {ALPX ALPY ALPZ REFT} {
                        catch {ans_sendcommand MPDE,$lab,$matid}
                   }
             }
             CTEI {
                   foreach lab {CTEX REFT} {
                        catch {ans_sendcommand MPDE,$lab,$matid}
                   }
             }
             CTEO {
                   foreach lab {CTEX CTEY CTEZ REFT} {
                        catch {ans_sendcommand MPDE,$lab,$matid}
                   }
             }
             THSI {
                   foreach lab {THSX REFT} {
                        catch {ans_sendcommand MPDE,$lab,$matid}
                   }
             }
             THSO {
                   foreach lab {THSX THSY THSZ REFT} {
                        catch {ans_sendcommand MPDE,$lab,$matid}
                   }
             }
             KORT {
                   foreach lab  {KXX KYY KZZ} {
                        catch {ans_sendcommand MPDE,$lab,$matid}
                   }
             }
             DORT {
                   foreach lab  {DXX DYY DZZ} {
                        catch {ans_sendcommand MPDE,$lab,$matid}
                   }
             }
             BETI {
                   foreach lab {BETX CREF} {
                        catch {ans_sendcommand MPDE,$lab,$matid}
                   }
             }
             BETO {
                   foreach lab {BETX BETY BETZ CREF} {
                        catch {ans_sendcommand MPDE,$lab,$matid}
                   }
             }
             MURO {
                   foreach lab  {MURX MURY MURZ} {
                        catch {ans_sendcommand MPDE,$lab,$matid}
                   }
             }
             MGOR {
                   foreach lab  {MGXX MGYY MGZZ} {
                        catch {ans_sendcommand MPDE,$lab,$matid}
                   }
             }
             PERO {
                   foreach lab  {PERX PERY PERZ} {
                        catch {ans_sendcommand MPDE,$lab,$matid}
                   }
             }
             RSVO {
                   foreach lab  {RSVX RSVY RSVZ} {
                        catch {ans_sendcommand MPDE,$lab,$matid}
                   }
             }
             SBKO {
                   foreach lab  {SBKX SBKY SBKZ} {
                        catch {ans_sendcommand MPDE,$lab,$matid}
                   }
             }
            }
           } elseif {$label == "exp"} {
               #matid is the material number
               #curvenum is the curve number
               ::euidl::material::CurveFit::deletebyexpid $matid $curvenum
           } elseif {$label == "func"} {
               #matid is the material number
               #curvenum is the function number in this case
               ::euidl::material::CurveFit::deletebyfuncid $matid $curvenum
           } else {
             catch {ans_sendcommand MPDE,$label,$matid}
           }
         }
       }
       refreshL             
    }

    proc copy {} {
      variable matid
      variable parent
      
      ans_sendcommand )/NOPR
      catch {ans_sendcommand )*SET,_zfromat,$matid}
      ans_sendcommand )/GO
      uidl::registerWindow $parent 0
      matTable_State 0
      ::uidl::callFnc Fnc_CopyMatModel [namespace code copyCB ] 1
    }

     proc copyCB { uidlButton } {
        variable treeMaterialParent
        variable parent

        raise $parent

        matTable_State 1

        if {$uidlButton != 1} {
           $treeMaterialParent configure \
              -querycommand [list [namespace code getMaterialNodes] %n] \
              -execcommand [list [namespace code select_Materialnode] %n %s]\
              -selectcommand [list [namespace code Selection] %n %s]
        } 
        if {$uidlButton == 2} {
            copy
        } else {    
            uidl::registerWindow $parent
        }
    }

    proc New {} {
      variable parent1
      variable childsite
      variable emptyfolder
      variable matidnew
      variable matModelArr

#
#     bind Entry <FocusIn> []
      if [winfo exists .modControl1] {
         $parent1 activate
         return
      }

      set parent1 [::euidl::dialog .modControl1 \
            -master $matModelArr(parent) \
            -class EUIDL]

      $parent1 configure \
            -okcommand [code ok_fornew]\
            -cancelcommand [code destroy $parent1]\
            -helpcommand [list ans_loadhelp Hlp_UI_def_mid]

      unset childsite
      set childsite [$parent1 component childsite]
      wm title $parent1 [msgcat::mc "Define Material ID"]
      wm minsize $parent1 50 50

      set maxmat [expr [ans_evalexpr mpinqr(0,0,14)]]
      set matd 0
      if {$maxmat > 0} {
      set matincr 0
           set matidlocal [ans_evalexpr mpnext(0)]
           while {$matidlocal > 0} {
              set matd $matidlocal
              set matidlocal [ans_evalexpr mpnext($matidlocal)]
           }
      }
      set matmaxi $matd
      foreach vari $emptyfolder {
           if { $vari >= $matd} {
              set matmaxi $vari
           }
      }
   
      set matidnew [expr $matmaxi + 1 ]
      
      euidl::label $childsite.lbl -height 3 -text [msgcat::mc " Define Material ID"]
      euidl::entry  $childsite.cmb -width 10 \
                 -variable [scope matidnew]


     grid $childsite.lbl -row 0 -column 0
     grid $childsite.cmb -row 0 -column 1

     update idletasks
     wm minsize $parent1 [winfo reqwidth $parent1] \
                         [winfo reqheight $parent1]

     $parent1 activate

     

    }

   proc NewFavorite {} {
      variable matModelArr
      variable parent
      variable childsite
      variable matid
      variable newfavoritedlg
      variable MyFavName

      if [winfo exists .newfav] {
         # Set the display correctly
         $newfavoritedlg activate
         return
      }

      set newfavoritedlg [::euidl::dialog .newfav -class EUIDL \
             -master $matModelArr(parent) ]

      set MyFavName ""
      $newfavoritedlg configure \
            -okcommand [code OKNewFavorite] \
            -cancelcommand [code CancelNewFavorite] \
            -helpcommand [list ans_loadhelp Hlp_fav_mat]

      set childsi [$newfavoritedlg component childsite]
      wm title $newfavoritedlg [msgcat::mc "Add a Favorite"]
 
      set text "Create a Favorite from material $matid"
      euidl::label $childsi.lbl -text [msgcat::mc $text]

      grid $childsi.lbl -row 0 -column 0 -columnspan 2

      euidl::label $childsi.namelbl -height 1 -text [msgcat::mc "Name"]
      grid $childsi.namelbl -row 1 -column 0

      euidl::entry $childsi.name  \
            -variable [scope MyFavName]

      grid $childsi.name -row 1 -column 1

      $newfavoritedlg activate
   }

   proc OKNewFavorite {} {

      variable matid
      variable MyFavName
      variable newfavoritedlg

      set errflag 0

      if {[regexp {\\} $MyFavName]} {
         ans_senderror 3 "A Favorite cannot have a back slash ( \\ ) in the name.  Please use a new name"
         set errflag 1

      } elseif {![string match $MyFavName ""]} {
         # get key for LS-DYNA to branch off if LS-DYNA is chosen
         set lsdyna [ans_getvalue active,,keyw,,lsdyna]

         if {$lsdyna == 0} {
            set matstuff [getMaterialStuff $matid ]
         } else {
            set matstuff [getDYNAstuff $matid]
         }

         foreach {stuff tag} $matstuff {
            append favlist "_" $tag
         }
      
         if { [info exists favlist] } {

            set errflag [::euidl::material::favorites::create2 $MyFavName $favlist]

         } else {
           ans_senderror 3 "A Favorite cannot be created for material $matid.  No properties are defined."
           set errflag 1
         }

         refresh

         update idletasks

         if {$errflag == 0} {
           CancelNewFavorite
         }
      } else {

         ans_senderror 3 "A Favorite cannot have a blank name.  Please use a new name"
         set errflag 1
      }
      if {$errflag == 1} {
         raise $newfavoritedlg
      }
   }

   proc CancelNewFavorite {} {

      if [winfo exists .newfav] {
         destroy .newfav
         return
      }

   }

   proc DeleteFavorite {} {
      variable matModelArr
      variable parent
      variable childsite
      variable delfavoritedlg
      variable MyFavName

      if [winfo exists .delfav] {
         # Set the display correctly
         $delfavoritedlg activate
         return
      }

      set delfavoritedlg [::euidl::dialog .delfav -class EUIDL \
             -master $matModelArr(parent) ]

      set MyFavName ""
      $delfavoritedlg configure \
            -okcommand [code OKDeleteFavorite] \
            -cancelcommand [code CancelDeleteFavorite] \
            -helpcommand [list ans_loadhelp Hlp_fav_mat]

      set childsi [$delfavoritedlg component childsite]
      wm title $delfavoritedlg [msgcat::mc "Delete a Favorite"]

      set text "Delete a Favorite from the list:"
      euidl::label $childsi.lbl -text [msgcat::mc $text]

      grid $childsi.lbl -row 0 -column 0 -columnspan 2

      euidl::label $childsi.namelbl -height 1 -text [msgcat::mc "Name"]
      grid $childsi.namelbl -row 1 -column 0

      set numFavorites [::euidl::material::favorites::getNumberOfFavorites]

      set lblList [ list ]

      if {$numFavorites > 0} {
         set favIncr 1
         while {$favIncr <= $numFavorites} {
            set thisFavoriteLabel [::euidl::material::favorites::getFavoriteLabel $favIncr]
            lappend lblList  $thisFavoriteLabel "$thisFavoriteLabel"
            incr favIncr
           }
      }

      euidl::combobox  $childsi.name  \
            -variable [scope MyFavName]
      $childsi.name insert list end $lblList

      grid $childsi.name -row 1 -column 1

      $delfavoritedlg activate
   }



   proc OKDeleteFavorite {} {

      variable MyFavName

      ::euidl::material::favorites::delete $MyFavName

      refresh

      update idletasks

      CancelDeleteFavorite

   }

   proc CancelDeleteFavorite {} {

      if [winfo exists .delfav] {
         destroy .delfav
         return
      }

   }

   proc exitMaterialModel {} {
       variable ::euidl::material::ModelControl::matModelArr
       variable extCallback
       variable localMatlInfoArr
       variable ptrMatlInfoArr

       variable parent

       ans_greygui 0 1
       ans_greygui 1 1
       ans_greygui 3 1
       ans_greygui 4 1
       catch {AnsysGUI::AnsysToolbarState ANS_STD__N AnsDynamic normal}
      
       ans_sendcommand )/NOPR
       catch {ans_sendcommand )_zbigmat= }
       catch {ans_sendcommand )_zfromat= }
       ans_sendcommand )/GO
 
       euidl::material::ModelControl::matTable_State 1     

       wm withdraw $parent
      
       if [winfo exists .dlgMatOpts ] {
          destroy .dlgMatOpts
          return
       }
      
       if [winfo exists .modControl2] {
          destroy .modControl2
          return
       }

       # Set the printing to what the customer had it set to coming in
       if {$matModelArr(printStatus)} {
          ans_sendcommand )/GO
       } else {
          ans_sendcommand )/NOPR
       }

      if {![string match {} $ptrMatlInfoArr]} {
         upvar #0 $ptrMatlInfoArr extMatlArr
         array set extMatlArr [array get localMatlInfoArr]
      }


      if {![string match {} $extCallback]} {
         uplevel #0 $extCallback
      }

      # Save the favorites automatically when leaving the dialog
      set lsdyna [ans_getvalue active,,keyw,,lsdyna]

      if {$lsdyna == 0} {
         ::euidl::material::favorites::save
      } else {
         ::euidl::material::favorites::savedyna
      }

   }

   proc ok_fornew {} {
         variable emptyfolder 
         variable matid 
         variable matidnew
         variable label
         variable parent1
         variable treeMaterialParent
                
         set varlen [string length $matidnew]
         if {$varlen > 9 } {
           set matidnew 1
         }         

         #Convert the MatID to an integer
         if { [ catch { set matid [ans_evalexpr $matidnew] }] } {
            set matidnew 1
            ans_senderror 3 "The Expression does not evaluate to an integer"
            return
         }

         if { [info exists matid] } {
            set matid [ expr int($matid) ]
         } else {
            ans_senderror 2 "The Expression does not evaluate to an integer"
            return
         }

         if {$matid == "" || $matid <= 0 || $matid > 999999999 } {
             set matid 1
         }

         set label ALL
         set tx [lsearch -exact $emptyfolder $matid]
        
         if {$tx != 0} {
            lappend emptyfolder $matid 
         }
         $treeMaterialParent selection clear
         $treeMaterialParent selection add matroot_$matid
         destroy $parent1
         refreshL
            
   }

   proc select_Materialnode { node args } {

         variable curvenum
         
         set list [split $node _]
         set charuse  [lindex $list 0]
         set matuse  [lindex $list 1]
         set curvenum [lindex $list 2]

         table_choice $charuse $matuse 0
         
         
    }

     proc getMaterialNodes { node} {
       
        variable material
        variable emptyfolder 
        variable treeMaterialParent
        variable matid
        variable lsdyna
        variable WBModeGlobal

        variable extMatlID
        variable localMatlInfoArr

        # get key for LS-DYNA to branch off if LS-DYNA is chosen
        set lsdyna [ans_getvalue active,,keyw,,lsdyna]

        set nodename [split $node _]
        set name  [lindex $nodename 0]
        set matnum  [lindex $nodename 1]
        if {$node == "" } {
           set node root
           set matnum 1
        }

        # A *GET loop to determine what matlID's are defined.
        set maxMatlNum [ans_evalexpr mpinqr(0,0,14)]
        set maxMatlDef [ans_evalexpr mpinqr(0,0,12)]
        set matidlocal 1

        # Add curve fit materials to the list
        set maxCurveDef [ans_getvalue tbft,,nmat]

        set modSelect 0
        set makeList 0
        if {$maxMatlDef == 0 && [string match $emptyfolder ""] && $maxCurveDef == 0} {
           set emptyfolder [list 1]
        }
        set matdef [list]

        set matidlocal [ans_evalexpr mpnext(0)]
        if {$maxMatlNum > 0} {
          while {$matidlocal > 0} {
             lappend matdef [list $matidlocal]
             set makeList 1
             set matidlocal [ans_evalexpr mpnext($matidlocal)]
          }
        }
   
        set matidlocal 1
        # Loop through each material model with a curve fit
        if {$maxCurveDef > 0} {
           while {$matidlocal <= $maxCurveDef} {
             set m [ans_getvalue tbft,,matnum,$matidlocal]
             set a root$m
             set b "Curve $m"
             # if this material is not in the list, add it
             set i [lsearch $matdef $m]
             if {$i == -1} {
                lappend matdef [list $m]
                set makeList 1
             }
             incr matidlocal
           }
        }
       
        # If a material ID was passed in use it instead of the defined.
        if {$extMatlID} {
            set matdef [list $extMatlID]
        }


        set tempfolder [ list ]
        if ![string match $emptyfolder ""] {
           foreach var $emptyfolder {
              set modSelect2 [ans_evalexpr mpinqr($var,0,1)]
              set curvSelect2 0
           #   uncomment for using curvefit data in LHS
              set curvSelect2 [::euidl::material::CurveFit::CurveFitExists $var]
              if {$modSelect2 == 0 && $curvSelect2 == 0} {
                 lappend matdef [list $var]
                 lappend tempfolder [list $var]
                 set makeList 1

              }
           }
           set emptyfolder $tempfolder

        }
        
        if {$makeList > 0} {
           set matdef [lsort -integer $matdef]
           set material(root) [ list ]
           # use nowSelectMat in case of delete (matid not in matdef)
           set nowSelectMat [lindex $matdef 0]
           foreach matidlocal $matdef {
              if {[info exists localMatlInfoArr]} {
                  lappend material(root) [list matroot_$matidlocal \
                        [msgcat::mc $localMatlInfoArr(matl,$matidlocal,name)]]
              } else {
                  lappend material(root) [list matroot_$matidlocal "Material Model Number $matidlocal" ]
              }
              if {$matid == $matidlocal} {
                 set nowSelectMat $matid
              }
           }
           
           if {!$WBModeGlobal} {
               set matid $nowSelectMat
               Selection matroot_$matid 0
           }

           ans_sendcommand )/NOPR
           catch {ans_sendcommand )*SET,_zbigmat,$matidlocal}
           ans_sendcommand )/GO
           if {$name == "matroot" } {
             if {$lsdyna != 0} {
                set matstuff [getDYNAstuff $matnum]
                set  material(matroot_$matnum) [list ]
                foreach {stuff tag} $matstuff {
                   lappend material(matroot_$matnum) [list ${tag}_$matnum $stuff]
                }
             } else {
                set material(matroot_$matnum) [ list ]
                set matstuff [getMaterialStuff $matnum ]
                # Put curve fitting here?
                set experiments [ list ]
                set curvefolders [ list ]
                set functions [ list ]
                set curvefolders "none"
           #   uncomment for using curvefit data in LHS
           #     set curvefolders [::euidl::material::CurveFit::getCurveFitData $matnum folders ]

                foreach {stuff tag} $matstuff {
                   lappend material(matroot_$matnum) [list ${tag}_$matnum $stuff]
                }
                if {$curvefolders != "none"} {
                   set experiments [::euidl::material::CurveFit::getCurveFitData $matnum expe ]
                   set functions [::euidl::material::CurveFit::getCurveFitData $matnum func ]
                   foreach {tag stuff} $curvefolders {
                      lappend material(matroot_$matnum) [list $tag $stuff ]
                   }
                   set material(exp_$matnum) [ list ]
                   set maxExp [ans_getvalue tbft,$matnum,nexp]
                   set maxExp [ans_evalexpr $maxExp]
                   if {$maxExp > 0} {
                      foreach {tag stuff} $experiments {
                         lappend material(exp_$matnum) [list $tag $stuff]
                      }
                   }

                   set material(func_$matnum) [ list ]
                   set maxFunc [ans_getvalue tbft,$matid,nfun]
                   set maxFunc [ans_evalexpr $maxFunc]
                   if {$maxFunc > 0} {
                      foreach {tag stuff} $functions {
                         lappend material(func_$matnum) [list $tag $stuff]
                      }
                   }
                }
                # End of curve fitting tree create
             }
           }
        }
        if {$node == "" } {
           set node root
        }
        if {[string match {} [array names material $node]]} {
           return ""

        }
     
        return $material($node)
     }

        proc getMaterialStuff { matid } {

             set tiny [expr pow(2,-100)]
             set stuff ""
             set isotkey 0
             set isotALPkey 0
             set isotCTEkey 0
             set isotTHSkey 0
             set isotBETkey 0
             set isotKXkey 0
             set isotDXkey 0
             set isotMUkey 0
             set isotMGkey 0
             set isotPERkey 0
             set isotRSVkey 0
             set isotSBKkey 0
             set orthkey 0
             set orthALPkey 0
             set orthCTEkey 0
             set orthTHSkey 0
             set orthBETkey 0
             set orthKXkey 0
             set orthDXkey 0
             set orthMUkey 0
             set orthMGkey 0
             set orthPERkey 0
             set orthRSVkey 0
             set orthSBKkey  0
             set mpEX [ans_getvalue EX,$matid,EXIS]
             set mpEY [ans_getvalue EY,$matid,EXIS]
             set mpEZ [ans_getvalue EZ,$matid,EXIS]
             set mpNUXY [ans_getvalue NUXY,$matid,EXIS]
             set mpNUYZ [ans_getvalue NUYZ,$matid,EXIS]
             set mpNUXZ [ans_getvalue NUXZ,$matid,EXIS]
             set mpPRXY [ans_getvalue PRXY,$matid,EXIS]
             set mpPRYZ [ans_getvalue PRYZ,$matid,EXIS]
             set mpPRXZ [ans_getvalue PRXZ,$matid,EXIS]
             set mpGXY [ans_getvalue GXY,$matid,EXIS]
             set mpGYZ [ans_getvalue GYZ,$matid,EXIS]
             set mpGXZ [ans_getvalue GXZ,$matid,EXIS]
             set mpALPI [ans_getvalue REFT,$matid,EXIS]
             set mpALPI [ans_getvalue ALPX,$matid,EXIS]
             set mpALPY [ans_getvalue ALPY,$matid,EXIS]
             set mpALPZ [ans_getvalue ALPZ,$matid,EXIS]
             set mpCTEX [ans_getvalue CTEX,$matid,EXIS]
             set mpCTEY [ans_getvalue CTEY,$matid,EXIS]
             set mpCTEZ [ans_getvalue CTEZ,$matid,EXIS]
             set mpTHSX [ans_getvalue THSX,$matid,EXIS]
             set mpTHSY [ans_getvalue THSY,$matid,EXIS]
             set mpTHSZ [ans_getvalue THSZ,$matid,EXIS]
             set mpDENS [ans_getvalue DENS,$matid,EXIS]
             set mpMU [ans_getvalue MU,$matid,EXIS]
             set mpKXX [ans_getvalue KXX,$matid,EXIS]
             set mpKORT [ans_getvalue KYY,$matid,EXIS]
             set mpKORT [ans_getvalue KZZ,$matid,EXIS]
             set mpDXX [ans_getvalue DXX,$matid,EXIS]
             set mpDORT [ans_getvalue DYY,$matid,EXIS]
             set mpDORT [ans_getvalue DZZ,$matid,EXIS]
             set mpBETI [ans_getvalue CREF,$matid,EXIS]
             set mpBETI [ans_getvalue BETX,$matid,EXIS]
             set mpBETY [ans_getvalue BETY,$matid,EXIS]
             set mpBETZ [ans_getvalue BETZ,$matid,EXIS]
             set mpCREF [ans_getvalue CREF,$matid,EXIS]
             set mpCSAT [ans_getvalue CSAT,$matid,EXIS]
             set mpC [ans_getvalue C,$matid,EXIS]
             set mpHF [ans_getvalue HF,$matid,EXIS]
             set mpQRAT [ans_getvalue QRAT,$matid,EXIS]
             set mpENTH [ans_getvalue ENTH,$matid,EXIS]
             set mpEMIS [ans_getvalue EMIS,$matid,EXIS]
             set mpMURX [ans_getvalue MURX,$matid,EXIS]
             set mpMURO [ans_getvalue MURY,$matid,EXIS]
             set mpMURO [ans_getvalue MURZ,$matid,EXIS]
             set mpMGXX [ans_getvalue MGXX,$matid,EXIS]
             set mpMGOR [ans_getvalue MGYY,$matid,EXIS]
             if {$mpMGOR == 0} {
                set mpMGOR [ans_getvalue MGZZ,$matid,EXIS]
             }
             set mpPERX [ans_getvalue PERX,$matid,EXIS]
             set mpPERY [ans_getvalue PERY,$matid,EXIS]
             set mpPERZ [ans_getvalue PERZ,$matid,EXIS]
             set mpRSVX [ans_getvalue RSVX,$matid,EXIS]
             set mpRSVO [ans_getvalue RSVY,$matid,EXIS]
             set mpRSVO [ans_getvalue RSVZ,$matid,EXIS]
             set mpSONC [ans_getvalue SONC,$matid,EXIS]
             #set mpMUAC [ans_getvalue MU,$matid,EXIS]
             set mpVISC [ans_getvalue VISC,$matid,EXIS]
             set mpDAMP [ans_getvalue DAMP,$matid,EXIS]
             set mpALPD [ans_getvalue ALPD,$matid,EXIS]
             set mpBETD [ans_getvalue BETD,$matid,EXIS]
             set mpDMPR [ans_getvalue DMPR,$matid,EXIS]
             set mpLSST [ans_getvalue LSST,$matid,EXIS]
             set mpSBKX [ans_getvalue SBKX,$matid,EXIS]
             set mpSBKY [ans_getvalue SBKY,$matid,EXIS]
             set mpSBKZ [ans_getvalue SBKZ,$matid,EXIS]

             if {[expr $mpEX != 0]} {
                 set isotkey 1
             }
             if {[expr $mpEY != 0]} {
                 set orthkey 1
             }
             if {[expr $mpEZ != 0]} {
                 set orthkey 1
             }
             if {[expr $mpNUXY != 0]} {
                 set isotkey 1
             }
             if {[expr $mpNUYZ != 0]} {
                 set orthkey 1
             }
             if {[expr $mpNUXZ != 0]} {
                 set orthkey 1
             }
             if {[expr $mpPRXY != 0]} {
                 set isotkey 1
             }
             if {[expr $mpPRYZ != 0]} {
                 set orthkey 1
             }
             if {[expr $mpPRXZ != 0]} {
                 set orthkey 1
             }
             if {[expr $mpGXY != 0]} {
                 set orthkey 1
             }
             if {[expr $mpGYZ != 0]} {
                  set orthkey 1
             }
             if {[expr $mpGXZ != 0]} {
                 set orthkey 1
             }
             if {[expr $mpALPI != 0]} {
                 set isotALPkey 1
             }
             if {[expr $mpALPY != 0]} {
                 set orthALPkey 1
                 set mpALPO 1
             }
             if {[expr $mpALPZ != 0]} {
                 set orthALPkey 1
                 set mpALPO 1
             }
             if {[expr $mpCTEX != 0]} {
                 set isotCTEkey 1
             }
             if {[expr $mpCTEY != 0]} {
                 set orthCTEkey 1
             }
             if {[expr $mpCTEZ != 0]} {
                 set orthCTEkey 1
             }
             if {[expr $mpTHSX != 0]} {
                 set isotTHSkey 1
             }
             if {[expr $mpTHSY != 0]} {
                 set orthTHSkey 1
             }
             if {[expr $mpTHSZ != 0]} {
                 set orthTHSkey 1
             }
             if {[expr $mpSBKX != 0]} {
                 set isotSBKkey 1
             }
             if {[expr $mpBETI != 0]} {
                 set isotBETkey 1
             }
             if {[expr $mpBETY != 0]} {
                 set orthBETkey 1
                 set mpBETO 1
             }
             if {[expr $mpBETZ != 0]} {
                 set orthBETkey 1
                 set mpBETO 1
             }
             if {[expr $mpSBKY != 0]} {
                 set orthSBKkey 1
             }
             if {[expr $mpSBKZ != 0]} {
                 set orthSBKkey 1
             }
             if {[expr $mpDENS != 0]} {
                 lappend stuff "Density"              DENS
             }
             if {[expr $mpMU != 0]} { 
                 set flui [ans_getvalue active,,keyw,,FLUID]
                 if {$flui == 1 } {
                    lappend stuff "Boundary Admittance" MUAC
                 } else { 
                    lappend stuff "Friction Coefficient" MU
                 }
             }
             if {[expr $mpKXX != 0]} {
                 set isotKXkey 1
             }
             if {[expr $mpKORT != 0]} {
                 set orthKXkey 1
             }
             if {[expr $mpDXX != 0]} {
                 set isotDXkey 1
             }
             if {[expr $mpDORT != 0]} {
                 set orthDXkey 1
             }
             if {[expr $mpC != 0]} {
                 lappend stuff "Specific Heat"        C
             }
             if {[expr $mpENTH != 0]} {
                 lappend stuff "Enthalpy"             ENTH
             }
             if {[expr $mpEMIS != 0]} {
                 lappend stuff "Emissivity"           EMIS
             }
             if {[expr $mpHF != 0]} {
                 lappend stuff "Convection or Film Coef."     HF
             }
             if {[expr $mpQRAT != 0]} {
                 lappend stuff "Heat Generation Rate" QRAT
             }
             if {[expr $mpLSST != 0]} {
                 lappend stuff "Loss Tangent"         LSST
             }
             if {[expr $mpMURX != 0]} {
                 set isotMUkey 1
             }
             if {[expr $mpMURO != 0]} {
                 set orthMUkey 1
             }
             if {[expr $mpMGXX != 0]} {
                 set isotMGkey 1
             }
             if {[expr $mpMGOR != 0]} {
                 set orthMGkey 1
             }
             if {[expr $mpPERX != 0]} {
                 set isotPERkey 1
             }
             if {[expr $mpPERY != 0]} {
                 set orthPERkey 1
             }
             if {[expr $mpPERZ != 0]} {
                 set orthPERkey 1
             }
             if {[expr $mpRSVX != 0]} {
                 set isotRSVkey 1
             }
             if {[expr $mpRSVO != 0]} {
                 set orthRSVkey 1
             }
             if {[expr $mpSONC != 0]} {
                 lappend stuff "Sonic Velocity"       SONC
             }
            # if {[expr $mpMUAC != 0]} {
            #       lappend stuff "Boundary Admittance"  MUAC
            #       }
             if {[expr $mpVISC != 0]} {
                 lappend stuff "Viscosity"            VISC
             }
             if {[expr $mpDAMP != 0]} {
                 lappend stuff "Damping (Constant)"    DAMP
             }
             if {[expr $mpALPD != 0]} {
                 lappend stuff "Damping (Mass)"    ALPD
             }
             if {[expr $mpBETD != 0]} {
                 lappend stuff "Damping (Stiffness)"    BETD
             }
             if {[expr $mpDMPR != 0]} {
                 lappend stuff "Damping (Freq Indep)"    DMPR
             }

          # Check for duplicates of Isotropic and Orthotropic (lao)
             if {$isotkey == 1} {
                if {$orthkey != 1} {
                   lappend stuff "Linear Isotropic"           ISOT
                }
             }
             if {$orthkey == 1} {
                   lappend stuff "Linear Orthotropic"         ORTH
             }

             if {$isotALPkey == 1} {
                if {$orthALPkey != 1} {
                   lappend stuff "Thermal Expansion (secant-iso)"    ALPI
                }
             }
             if {$orthALPkey == 1} {
                   lappend stuff "Thermal Expansion (secant-ortho)"  ALPO
             }

             if {$isotCTEkey == 1} {
                if {$orthCTEkey != 1} {
                   lappend stuff "Thermal Expansion (instant-iso)"    CTEI
                }
             }
             if {$orthCTEkey == 1} {
                   lappend stuff "Thermal Expansion (instant-ortho)"  CTEO
             }

             if {$isotTHSkey == 1} {
                if {$orthTHSkey != 1} {
                   lappend stuff "Thermal Expansion (strain-iso)"    THSI
                }
             }
             if {$orthTHSkey == 1} {
                   lappend stuff "Thermal Expansion (strain-ortho)"  THSO
             }

             if {$isotKXkey == 1} {
                if {$orthKXkey != 1} {
                   lappend stuff "Thermal conduct. (iso)"     KXX
                }
             }
             if {$orthKXkey == 1} {
                   lappend stuff "Thermal conduct. (ortho)"   KORT
             }
             if {$isotDXkey == 1} {
                if {$orthDXkey != 1} {
                   lappend stuff "Diffusivity (iso)"     DXX
                }
             }
             if {$orthDXkey == 1} {
                   lappend stuff "Diffusivity (ortho)"   DORT
             }
             if {$isotBETkey == 1} {
                if {$orthBETkey != 1} {
                   lappend stuff "Diffusion Expansion (iso)"    BETI
                }
             }
             if {$orthBETkey == 1} {
                   lappend stuff "Diffusion Expansion (ortho)"  BETO
             }
             if {$mpCSAT == 1} {
                   lappend stuff "Saturated Concentration"  CSAT
             }
             if {$isotMUkey == 1} {
                if {$orthMUkey != 1} {
                   lappend stuff "Permeability (constant) "   MURX
                }
             }
             if {$orthMUkey == 1} {
                   lappend stuff "Permeability (ortho)"       MURO
             }
             if {$isotMGkey == 1} {
                if {$orthMGkey != 1} {
                   lappend stuff "Coercive force (const)"     MGXX
                }
             }
             if {$orthMGkey == 1} {
                   lappend stuff "Coercive force (ortho)"     MGOR
             }
             if {$isotPERkey == 1} {
                if {$orthPERkey != 1} {
                   lappend stuff "Permittivity (constant)"    PERX
                }
             }
             if {$orthPERkey == 1} {
                   lappend stuff "Permittivity (ortho)"       PERO
             }
             if {$isotRSVkey == 1} {
                if {$orthRSVkey != 1} {
                   lappend stuff "Resistivity (constant)"     RSVX
                }
             }
             if {$orthRSVkey == 1} {
                   lappend stuff "Resistivity (ortho)"        RSVO
             }
             if {$isotSBKkey == 1} {
                if {$orthSBKkey != 1} {
                   lappend stuff "Seebeck Coefficients (constant) "   SBKX
                }
             }
             if {$orthSBKkey == 1} {
                   lappend stuff "Seebeck Coefficients (ortho)"       SBKO
             }

# Set tblabels array
                array set tblabels {
                   "Nonlinear Isotropic"      NLIS
                   "Multilinear Elastic"      MELA
                   "Chaboche"                 CHAB
                   "Multilinear Isotropic"    MISO 
                   "Bilinear Isotropic"       BISO 
                   "Anisotropic Elastic"      ANEL 
                   "Permittivity (aniso)"     DPER
                   "Creep"                    CREE 
                   "Hill"                     HILL 
                   "Bilinear Kinematic"       BKIN
                   "Anand"                    ANAN
                   "Anisotropic"              ANIS
                   "Drucker-Prager"           DP
                   "Multilinear Kinematic(Fixed)"    MKIN
                   "Maxwell Viscoelastic"     EVIS
                   "Multilinear Kinematic(General)"  KINH
                   "Hyper-Elastic"            HYPE
                   "Mooney-Rivlin (TB,MOON)"  MOON
                   "User Constants"           USER
                   "Rate-Dependent"           RATE
                   "Concrete"                 CONC
                   "Swelling"                 SWEL
                   "Failure Criteria"         FAIL
                   "State Variables"          STAT
                   "Film Coefficient"         HFLM
                   "B-H Curve"                BH
                   "Fluid Conductance"        FCON
                   "Water Table"              WATE
                   "Piezoelectric matrix "    PIEZ
                   "Piezoresistive matrix"    PZRS
                   "Gasket"                   GASK
                   "Cast-Iron"                CAST
                   "Uniaxial"                 UNIA
                   "Prony"                    PRONY
                   "Shift Function"           SHIFT
                   "Shape Memory Alloy"       SMA
                   "Joint"                    JOINT
                   "Plasticity"               PLAS
                }

                #   "Elasticity"               ELAS
                #   "Damping (Freq Dependent)" SDAMP      

                # Foreach type of thing do the check
                foreach { labels key} [ array get tblabels] {
                   set bob [ans_getvalue $key,$matid,EXIS]
                   if {$bob == 1} {
                     
                      if {$key == "HYPE"} {
                         #For Hype, Cast, Gask & Cree, a different TBOPT leads to a different tabel
                         #Moreover for Hype, the value of NPT is also important.
                         # Set hyplabels array
                         array set hyplabels {
                              "Gent"                  4
                              "Neo-Hookean"           5
                              "Arruda-Boyce"          8
                              "Blatz-Ko (Foam)"       10
                              "Hyper-Elas User def."  100
                         }
                         set tbopt [ans_getvalue HYPE,$matid,TBOP]
                         #tbop =1 is the mooney case (2,3,5,9 parameters)
                         if {$tbopt == 1 } {
                            set tvalue [ans_getvalue HYPE,$matid,TVAL,1]
                            set npar [expr int([ans_getvalue \
                                     HYPE,$matid,TEMP,$tvalue,NCON])]
                            set npts 2
                            if {$npar > 3 } {
                               set npts 3
                            } 
                            if {$npar > 4} {
                               set npts 5
                            } 
                            if {$npar > 7} { 
                               set npts 9 
                            }     
                            lappend stuff "Mooney-Rivlin\
                                        ($npts parameters)" HYPEmo$npts
                         }
                         if {$tbopt == 2 } {
                            set tvalue [ans_getvalue HYPE,$matid,TVAL,1]
                            set npar [expr int([ans_getvalue \
                                     HYPE,$matid,TEMP,$tvalue,NCON])]
                            set npts [expr int($npar/3)]
                            if {$npts <= 5} {
                               lappend stuff "Ogden\
                                        ($npts terms)" HYPEog$npts
                            } else {
                               lappend stuff "Ogden\
                                        (General)" HYPEogG
                            }
                         }
                         if {$tbopt == 3 } {
                            set tvalue [ans_getvalue HYPE,$matid,TVAL,1]
                            set npar [expr int([ans_getvalue \
                                     HYPE,$matid,TEMP,$tvalue,NCON])]
                            set npts [expr int($npar/2)]
                            if {$npts <= 5} {
                               lappend stuff "Yeoh\
                                        (Order $npts)" HYPEye$npts
                            } else {
                               lappend stuff "Yeoh\
                                        (General)" HYPEyeG
                            }
                         }
                         if {$tbopt == 11 } {
                            set tvalue [ans_getvalue HYPE,$matid,TVAL,1]
                            set npar [expr int([ans_getvalue \
                                     HYPE,$matid,TEMP,$tvalue,NCON])]
                            set npts [expr int($npar/3)]
                            if {$npts <= 5} {
                               lappend stuff "Ogden-Foam\
                                        (Order $npts)" HYPEfo$npts
                            } else {
                               lappend stuff "Ogden-Foam\
                                        (General)" HYPEfoG
                            }
                         }
                          if {$tbopt == 6 } {
                            set tvalue [ans_getvalue HYPE,$matid,TVAL,1]
                            set npar [expr int([ans_getvalue \
                                     HYPE,$matid,TEMP,$tvalue,NCON])]
                            set delta [expr sqrt(25 + 8 * $npar)]
                            set npts [expr int(-5 + $delta)/2]
                            if {$npts <= 5} {
                               lappend stuff "Polynomial form\
                                        ($npts terms)" HYPEpo$npts
                            } else {
                               lappend stuff "Polynomial form\
                                        (General)" HYPEpoG
                            }
                         }
                         if {$tbopt == 7} {set tbopt 8}
                         foreach { labs tbo} [ array get hyplabels] {
                            if {$tbopt == $tbo} { 
                               lappend stuff $labs HYPE$tbo
                            }
                         }
                     } elseif {$key == "CREE"} {
                          # Set creelabels array
                         array set creelabels {
                 "Creep: Explicit"              0
                 "Creep: Implicit (1:Strain Hard-P)"          1
                 "Creep: Implicit (2:Time Hard-P)"            2
                 "Creep: Implicit (3:Gen Exp-P)"              3
                 "Creep: Implicit (4:Gen Graham-P)"           4
                 "Creep: Implicit (5:Gen Blackburn-P)"        5
                 "Creep: Implicit (6:Mod Time Hard-P)"        6
                 "Creep: Implicit (7:Mod Strain Hard-P)"      7
                 "Creep: Implicit (8:Gen Garofalo-S)"         8
                 "Creep: Implicit (9:Exp Form-S)"             9
                 "Creep: Implicit (10:Norton-S)"              10
                 "Creep: Implicit (11:Time Hard-P+S)"         11
                 "Creep: Implicit (12:Rational Poly-P+S)"     12
                 "Creep: Implicit (13:Gen Time Hard-P)"       13
                 "Creep: User Defined"                        100 
                         }
                         set tbopt [ans_getvalue CREE,$matid,TBOP]
                         foreach { labs tbo} [ array get creelabels] {
                            if {$tbopt == $tbo} { 
                               if {$tbo == 0} {
                                   lappend stuff $labs CREE
                               } else {
                                   lappend stuff $labs CREE$tbo
                               }
                            }
                         }
                     } elseif {$key == "GASK"} {
                         # Set gasklabels array
                         array set gasklabels {
                         "Gasket: General"              PARA
                         "Gasket: Compression"          COMP
                         "Gasket: Linear Unloading"     LUNL
                         "Gasket: Nonlinear Unloading"  NUNL
                         "Gasket: Transverse Shear"     TSS
                         }
                         foreach { labs tbo} [ array get gasklabels] {
                            set bob [ans_getvalue $key,$matid,EXIS,,,,$tbo]
                            if {$bob == 1} {
                               lappend stuff $labs GASK$tbo
                            }
                         }
                     } elseif {$key == "CAST"} {
                         # Set castlabels array
                         array set castlabels {
                         "Cast-Iron: Isotropic Hardening"   1
                         "Cast-Iron: Kinematic Hardening"   2
                         }
                         # set tbopt [ans_getvalue CAST,$matid,TBOP]
                         # only tbopt 1 is valid now
                         set tbopt 1
                         foreach { labs tbo} [ array get castlabels] {
                            if {$tbopt == $tbo} { 
                               lappend stuff $labs CAST$tbopt
                            }
                         }
                     } elseif {$key == "DP"} {
                         # Set dplabels array
                         array set dplabels {
                         "Drucker-Prager"          1
                         "Drucker-Prager (Cap)"    2
                         }
                         set tbopt [ans_getvalue DP,$matid,TBOP]
                         if {$tbopt == 0} {
                            set tbopt 1
                         }
                         foreach { labs tbo} [ array get dplabels] {
                            if {$tbopt == $tbo} {
                               lappend stuff $labs DP$tbopt
                            }
                         }
                     } elseif {$key == "PLAS"} {
                         # Set dplabels array
                         array set plaslabels {
                         "Multilinear Isotropic"   1
                         "Multilinear Kinematic(General)"  4
                         }
                         set tbopt [ans_getvalue PLAS,$matid,TBOP]
                         if {$tbopt == 0} {
                            set tbopt 1
                         }
                         foreach { labs tbo} [ array get plaslabels] {
                            if {$tbopt == $tbo} {
                               lappend stuff $labs PLAS$tbopt
                            }
                         }
                     } elseif {$key == "ELAS"} {
                         # Set elaslabels array
                         array set elaslabels {
                         "Freq-Dependent Elasticity (iso)"    2
                         "Freq-Dependent Elasticity (ortho)"  9
                         "Freq-Dependent Elasticity (aniso)" 21
                         }
                      #   set tbopt [ans_getvalue ELAS,$matid,NCON]
                      #   if {$tbopt == 0} {
                      #      set tbopt 2
                      #   }
                      #   foreach { labs tbo} [ array get elaslabels] {
                      #      if {$tbopt == $tbo} {
                      #         lappend stuff $labs ELAS$tbopt
                      #      }
                      #   }
                     } elseif {$key == "UNIA"} {
                         # Set uniaxlabels array
                         array set uniaxlabels {
                         "Uniaxial: Compression"   COMP
                         "Uniaxial: Tension"       TENS
                         }
                         foreach { labs tbo} [ array get uniaxlabels] {
                            set bob [ans_getvalue $key,$matid,EXIS,,,,$tbo]
                            if {$bob == 1} {
                               lappend stuff $labs UNIA$tbo
                            }
                         }
                     } elseif {$key == "PRONY"} {
                         # Set prony array
                         array set pronylabels {
                         "Prony: Shear Response" SHEAR
                         "Prony: Volumetric Response" BULK
                         }
                         foreach { labs tbo} [ array get pronylabels] {
                            set bob [ans_getvalue $key,$matid,EXIS,,,,$tbo]
                            if {$bob == 1} {
                               lappend stuff $labs PRONY$tbo
                            }
                         }
                     } elseif {$key == "SHIFT"} {
                         # Set shift array
                         array set shiftlabels {
                         "Shift Function: WLF"  1
                         "Shift Function: TN"   2
                         "Shift Function: USER" 100 
                         }
                         set tbopt [ans_getvalue SHIFT,$matid,TBOP]
                         foreach { labs tbo} [ array get shiftlabels] {
                            if {$tbopt == $tbo} { 
                               lappend stuff $labs SHIFT
                            }
                         }
                     } elseif {$key == "JOINT"} {
                         # Set prony array
                         array set jointlabels {
                         "Joint: Linear Stiffness" STIF
                         "Joint: Linear Damping" DAMP
                         "Joint: Linear Friction" FRIC
                         "Joint: Nonlinear Stiffness ALL" JNSA
                         "Joint: Nonlinear Stiffness ROTX" JNS4
                         "Joint: Nonlinear Stiffness ROTZ" JNS6
                         "Joint: Nonlinear Damping ALL" JNDA
                         "Joint: Nonlinear Damping ROTX" JND4
                         "Joint: Nonlinear Damping ROTZ" JND6
                         "Joint: Nonlinear Friction ALL" JNFA
                         "Joint: Nonlinear Friction ROTX" JNF4
                         "Joint: Nonlinear Friction ROTZ" JNF6
                         }
                         foreach { labs tbo} [ array get jointlabels] {
                            set bob [ans_getvalue $key,$matid,EXIS,,,,$tbo]
                            if {$bob == 1} {
                               lappend stuff $labs JOINT$tbo
                            }
                         }
                     } else {
                         lappend stuff $labels $key 
                     }
                   }
                }
                return $stuff

        }

        proc getDYNAstuff { matid} {

        set tiny [expr pow(2,-100)]
        set stuff ""
        set isotkey 0
        set orthkey 0
        set tbkey 0
        set mpEX [ans_getvalue EX,$matid,EXIS]
        set mpEY [ans_getvalue EY,$matid,EXIS]
        set mpEZ [ans_getvalue EZ,$matid,EXIS]
        set mpNUXY [ans_getvalue NUXY,$matid,EXIS]
        set mpNUYZ [ans_getvalue NUYZ,$matid,EXIS]
        set mpNUXZ [ans_getvalue NUXZ,$matid,EXIS]
        set mpGXY [ans_getvalue GXY,$matid,EXIS]
        set mpGYZ [ans_getvalue GYZ,$matid,EXIS]
        set mpGXZ [ans_getvalue GXZ,$matid,EXIS]
        set mpDENS [ans_getvalue DENS,$matid,EXIS]
        set mpMU [ans_getvalue MU,$matid,EXIS]
        set mpCABL [ans_getvalue CABL,$matid,EXIS]
        set mpFLUI [ans_getvalue FLUI,$matid,EXIS]
        set mpRIGI [ans_getvalue RIGI,$matid,EXIS]
        set mpORTH [ans_getvalue ORTHO,$matid,EXIS]

         # Find out what materials have been defined 
         if {[expr $mpEX != 0]} {
             set isotkey 1
         }
         if {[expr $mpEY != 0]} {
             set orthkey 1
         }
         if {[expr $mpEZ != 0]} {
             set orthkey 1
         }

         set listDYNA {ANEL MOON EVIS BISO BKIN PLAW\
                       COMP CONCR GCAP FOAM HONE EOS\
                       ANIS DISC CABL RIGI FLUI}
         
         foreach lab $listDYNA {
            set tb [ans_getvalue $lab,$matid,EXIS]
               if {$tb == 1} {
                  set tbchk  [ans_getvalue $lab,$matid,TBOP]
                  switch -exact -- $lab {
                     CABL {
                        lappend stuff "Cable" CABLdyn
                        set isotkey 0
                     }                                            
                     RIGI {
                        lappend stuff "Rigid" RIGIdyn
                        set isotkey 0
                     }                                            
                     FLUI {
                        lappend stuff "Fluid" FLUIdyn
                        set isotkey 0
                     }                                            
                     ANEL {
                        lappend stuff "Anisotropic Elastic" ANELdyn
                        set tbkey 1
                     }                                            
                     MOON {
                        if {$tbchk == 2} {
                           lappend stuff "Mooney Rivlin" MOONdyn
                        } else {
                           lappend stuff "Mooney Rivlin" MOON1dyn
                        }
                        set tbkey 1
                     }                                            
                     EVIS {
                        lappend stuff "Viscoelastic" EVISC
                        set tbkey 1
                     }                                            
                     BISO {
                        set tbkey 1

                        # See if there is more than one temperature defined
                        set ntemp [expr int([ans_getvalue EX,$matid,NTEMP])]

                        if {$ntemp > 1} {
                           lappend stuff "Temp Dependent BISO" BISOtmp
                        } else {
                           lappend stuff "Bilinear Isotropic" BISOdyn
                        }
                     }                                            
                     PLAW {
                        set tbkey 1
                        if {$tbchk == 7} {
                           lappend stuff "Transverse Anisotropic" ANISdyn
                        } elseif {$tbchk == 10} {
                           lappend stuff "Transverse Aniso FLD" ANISfld
                        } elseif {$tbchk == 1} {
                           lappend stuff "Plastic Kinematic" KINEdyn
                        } elseif {$tbchk == 3} {
                           lappend stuff "Barlat 3 Parm Anisotropic" BAR3dyn
                        } elseif {$tbchk == 6} {
                           lappend stuff "Barlat Anisotropic" BARLdyn
                        } elseif {$tbchk == 4} {
                           lappend stuff "Rate Sensitive" SENSdyn
                        } elseif {$tbchk == 5} {
                           lappend stuff "Rate Dependent" DEPdyn
                        } elseif {$tbchk == 2} {
                           lappend stuff "Power Law" PLAWdyn
                        } elseif {$tbchk == 8} {
                           lappend stuff "Standard Piecewise Linr" LINRdyn
                        } elseif {$tbchk == 9} {
                           lappend stuff "Hydrodynamic" HYDRdyn
                        } elseif {$tbchk == 11} {
                           lappend stuff "Modified Piecewise Linr" LINR1dyn
                        } elseif {$tbchk == 12} {
                           lappend stuff "Elastic Visco Thermal"   THERMdyn
                        }
                     }                                            
                     BKIN {
                        set tbkey 1
                        lappend stuff "Bilinear Kinematic" BKINdyn
                     }                                            
                     COMP {
                        set tbkey 1
                        lappend stuff "Composite Damage" COMPdyn
                     }                                            
                     CONCR {
                        set tbkey 1
                        lappend stuff "Concrete Damage" CONCdyn
                     }                                            
                     GCAP {
                        set tbkey 1
                        lappend stuff "Geological Cap" GEOdyn
                     }                                            
                     FOAM {
                        set tbkey 1
                        if {$tbchk == 1} {
                           lappend stuff "Closed Cell" CELLdyn
                        } elseif {$tbchk == 3} {
                           lappend stuff "Viscous" VISCdyn
                        } elseif {$tbchk == 2} {
                           lappend stuff "Low Density" DENSdyn
                        } elseif {$tbchk == 4} {
                           lappend stuff "Crushable" CRSHdyn
                        } 
                     }                                            
                     HONE {
                        set tbkey 1
                        lappend stuff "Honeycomb" HONEdyn
                     }                                            
                     EOS {
                        set tbkey 1
                        set eosopt [expr $tbchk%1000]
                        set check [expr floor($tbchk/1000)]
                        if {$check == 1} {
                           if {$eosopt == 1} {
                              lappend stuff "Johnson-Cook Linear Poly." JOHN1dyn
                           } elseif {$eosopt == 2} {
                              lappend stuff "Johnson-Cook Gruneisem" JOHN2dyn
                           } elseif {$eosopt == 3} {
                              lappend stuff "Johnson-Cook Tabulated" JOHN3dyn
                           }
                        } elseif {$check == 2} {
                           if {$eosopt == 1} {
                              lappend stuff "Null Linear Poly." NULL1dyn
                           } elseif {$eosopt == 2} {
                              lappend stuff "Null Gruneisem" NULL2dyn
                           } elseif {$eosopt == 3} {
                              lappend stuff "Null Tabulated" NULL3dyn
                           }
                        } elseif {$check == 3} {
                           if {$eosopt == 1} {
                              lappend stuff "Zerilli-Armstrong Linear Poly." ZERI1dyn
                           } elseif {$eosopt == 2} {
                              lappend stuff "Zerilli-Armstrong Gruneisem" ZERI2dyn
                           } elseif {$eosopt == 3} {
                              lappend stuff "Zerilli-Armstrong Tabulated" ZERI3dyn
                           }
                        } elseif {$check == 5} {
                           if {$eosopt == 1} {
                              lappend stuff "Steinberg Linear Poly." STEN1dyn
                           } elseif {$eosopt == 2} {
                              lappend stuff "Steinberg Gruneisem" STEN2dyn
                           } elseif {$eosopt == 3} {
                              lappend stuff "Steinberg Tabulated" STEN3dyn
                           }
                        } elseif {$check == 4} {
                           lappend stuff "Bamman" BAMMdyn
                        }
                    }                                            
                    DISC {
                        set tbkey 1
                        if {$tbchk == 0} {
                        lappend stuff "Lin Elas Spring" SPNGdyn
                        } elseif {$tbchk == 5} {
                        lappend stuff "General NL Spring" NLSPdyn
                        } elseif {$tbchk == 2} {
                        lappend stuff "Elastoplast Spring" ELSPdyn
                        } elseif {$tbchk == 3} {
                        lappend stuff "NL Elastic  Spring" NLESdyn
                        } elseif {$tbchk == 6} {
                        lappend stuff "Maxwell Visc Sprng" MAXSdyn
                        } elseif {$tbchk == 7} {
                        lappend stuff "Inelastic Spring" INSPdyn
                        } elseif {$tbchk == 1} {
                        lappend stuff "Linear Viscosity" LNVIdyn
                        } elseif {$tbchk == 4} {
                        lappend stuff "Nonlinear Visco" NLVIdyn
                        }
                    }                                            
                }
             }
         }

          # Check for the materials that have no TB and no EDMP values 
           if {$tbkey != 1} {
                if {[expr $mpGXY > 0]} {
                      if {$isotkey != 1 && $orthkey != 1} {
                         lappend stuff "Blatz-KO Rubber"         BLAT
                      }
                }
                if {$isotkey == 1} {
                   if {$orthkey != 1} {
                      lappend stuff "Linear Isotropic"           ISOTdyn
                   }
                }
                if {$orthkey == 1} {
                      lappend stuff "Linear Orthotropic"         ORTHdyn
                }
           }

         return $stuff

   }

   proc select_Modelnode { node args } {
              variable matid
              update idletasks
              set matmodel(root) [list Structural Thermal]
                 switch -glob -- $node {
                        1n1_1_1 {
                        table_choice ISOT $matid 0
                        }
                        1n1_1_2 {
                        table_choice ORTH $matid 0
                        }
                        1n1_1_3 {
                        table_choice ANEL $matid 0
                        }
                        1n2_1_2 {
                        table_choice MELA $matid 0
                        }
                        EVIS {
                        table_choice EVIS  $matid 0
                        }
                        1n2_3_2_1 {
                        table_choice PRONYSHEAR $matid 0
                        }                                            
                        1n2_3_2_2 {
                        table_choice PRONYBULK $matid 0
                        }                                            
                        1n2_3_2_3 {
                        table_choice SHIFT $matid 0
                        }                                            
                        1n2_1_1_1_1 {
                        table_choice HYPEmo2 $matid 0
                        }
                        1n2_1_1_1_2 {
                        table_choice HYPEmo3 $matid 0
                        }
                        1n2_1_1_1_3 {
                        table_choice HYPEmo5 $matid 0
                        }
                        1n2_1_1_1_4 {
                        table_choice HYPEmo9 $matid 0
                        }
                        1n2_1_1_2_1 {
                        table_choice HYPEog1 $matid 0
                        }
                        1n2_1_1_2_2 {
                        table_choice HYPEog2 $matid 0
                        }
                        1n2_1_1_2_3 {
                        table_choice HYPEog3 $matid 0
                        }
                        1n2_1_1_2_4 {
                        table_choice HYPEog4 $matid 0
                        }
                        1n2_1_1_2_5 {
                        table_choice HYPEog5 $matid 0
                        }
                        1n2_1_1_2_6 {
                        table_choice HYPEogG $matid 0
                        }
                        1n2_1_1_3 {
                        table_choice HYPE5 $matid 0
                        }
                        1n2_1_1_4_1 {
                        table_choice HYPEpo1 $matid 0
                        }
                        1n2_1_1_4_2 {
                        table_choice HYPEpo2 $matid 0
                        }
                        1n2_1_1_4_3 {
                        table_choice HYPEpo3 $matid 0
                        }
                        1n2_1_1_4_4 {
                        table_choice HYPEpo4 $matid 0
                        }
                        1n2_1_1_4_5 {
                        table_choice HYPEpo5 $matid 0
                        }
                        1n2_1_1_4_6 {
                        table_choice HYPEpoG $matid 0
                        }
                        1n2_1_1_5 {
                        table_choice HYPE8 $matid 0
                        }
                        1n2_1_1_6 {
                        table_choice HYPE4 $matid 0
                        }
                        #1n2_1_1_7 {
                        #table_choice HYPE3 $matid 0
                        #}
                        1n2_1_1_7_1 {
                        table_choice HYPEye1 $matid 0
                        }
                        1n2_1_1_7_2 {
                        table_choice HYPEye2 $matid 0
                        }
                        1n2_1_1_7_3 {
                        table_choice HYPEye3 $matid 0
                        }
                        1n2_1_1_7_4 {
                        table_choice HYPEye4 $matid 0
                        }
                        1n2_1_1_7_5 {
                        table_choice HYPEye5 $matid 0
                        }
                        1n2_1_1_7_6 {
                        table_choice HYPEyeG $matid 0
                        }
                        1n2_1_1_8 {
                        table_choice HYPE10 $matid 0
                        }
                        #1n2_1_1_9 {
                        #table_choice HYPE11 $matid 0
                        #}
                        1n2_1_1_9_1 {
                        table_choice HYPEfo1 $matid 0
                        }
                        1n2_1_1_9_2 {
                        table_choice HYPEfo2 $matid 0
                        }
                        1n2_1_1_9_3 {
                        table_choice HYPEfo3 $matid 0
                        }
                        1n2_1_1_9_4 {
                        table_choice HYPEfo4 $matid 0
                        }
                        1n2_1_1_9_5 {
                        table_choice HYPEfo5 $matid 0
                        }
                        1n2_1_1_9_6 {
                        table_choice HYPEfoG $matid 0
                        }
                        1n2_1_1_10 {
                        table_choice MOON $matid 0
                        }
                        Hyper_Fit {
                        ::euidl::material::CurveFit::createwithid $matid Hyper
                        }
                        Visco_Fit {
                        ::euidl::material::CurveFit::createwithid $matid Visco
                        }
                        Creep_Fit {
                        ::euidl::material::CurveFit::createwithid $matid Creep
                        }
                        Plas_Fit {
                        ::euidl::material::CurveFit::createwithid $matid Plast
                        }
                        1n2_2_1_1_1_1 {
                        table_choice COMB_ISOT_BISO $matid 0
                        }
                        1n2_2_1_1_1_2 {
                        table_choice COMB_ISOT_MISO $matid 0
                        }
                        1n2_2_1_1_1_3 {
                        table_choice COMB_ISOT_NLIS $matid 0
                        }
                        1n2_2_1_1_2_1 {
                        table_choice COMB_ORTH_BISO_HILL $matid 0
                        }
                        1n2_2_1_1_2_2 {
                        table_choice COMB_ORTH_MISO_HILL $matid 0
                        }
                        1n2_2_1_1_2_3 {
                        table_choice COMB_ORTH_NLIS_HILL $matid 0
                        }
                        1n2_2_1_2 {
                        table_choice COMB_ORTH_ANIS  $matid 0
                        } 
                        1n2_2_1_3_1_1 {
                        table_choice COMB_ISOT_BKIN $matid 0
                        }
                        1n2_2_1_3_1_2 {
                        table_choice COMB_ISOT_MKIN $matid 0
                        }
                        1n2_2_1_3_1_3 {
                        table_choice COMB_ISOT_KINH $matid 0
                        }
                        1n2_2_1_3_1_4 {
                        table_choice COMB_ISOT_CHAB $matid 0
                        }
                        1n2_2_1_3_2_1 {
                        table_choice COMB_ORTH_BKIN_HILL $matid 0
                        }
                        1n2_2_1_3_2_2 {
                        table_choice COMB_ORTH_MKIN_HILL $matid 0
                        }
                        1n2_2_1_3_2_3 {
                        table_choice COMB_ORTH_KINH_HILL $matid 0
                        }
                        1n2_2_1_3_2_4 {
                        table_choice COMB_ORTH_CHAB_HILL $matid 0
                        }
                        1n2_2_1_4_1_1 {
                        table_choice COMB_ISOT_CHAB_BISO $matid 0
                        }
                        1n2_2_1_4_1_2 {
                        table_choice COMB_ISOT_CHAB_MISO  $matid 0
                        }
                        1n2_2_1_4_1_3 {
                        table_choice COMB_ISOT_CHAB_NLIS  $matid 0
                        }
                        1n2_2_1_4_2_1 {
                        table_choice COMB_ORTH_CHAB_BISO_HILL $matid 0
                        }
                        1n2_2_1_4_2_2 {
                        table_choice COMB_ORTH_CHAB_MISO_HILL $matid 0
                        }
                        1n2_2_1_4_2_3 {
                        table_choice COMB_ORTH_CHAB_NLIS_HILL $matid 0
                        }
                        1n2_2_2_1_1_1_1 {
                        table_choice COMB_ISOT_RATE_BISO  $matid 0
                        }
                        1n2_2_2_1_1_1_2  {
                        table_choice COMB_ISOT_RATE_MISO  $matid 0
                        }
                        1n2_2_2_1_1_1_3 {
                        table_choice COMB_ISOT_RATE_NLIS  $matid 0
                        }
                        1n2_2_2_1_1_2_1 {
                        table_choice COMB_ORTH_RATE_BISO_HILL  $matid 0
                        }
                        1n2_2_2_1_1_2_2  {
                        table_choice COMB_ORTH_RATE_MISO_HILL  $matid 0
                        }
                        1n2_2_2_1_1_2_3 {
                        table_choice COMB_ORTH_RATE_NLIS_HILL  $matid 0
                        }                     
                        1n2_2_2_2_1_1_1 {
                        table_choice COMB_ISOT_CREE $matid 0
                        }
                        1n2_2_2_2_1_1_2_* {
                          foreach num {1 2 3 4 5 6 7 8 9 10 11 12 13 } {
                            if {$node == "1n2_2_2_2_1_1_2_$num"} {
                               set tbopt $num
                               break
                            }
                          }
                        table_choice COMB_ISOT_CREE$tbopt $matid 0
                        } 
                        1n2_2_2_2_1_2_1_* {
                          foreach num {1 2 3 4 5 6 7 8 9 10 11 12 13 } {
                            if {$node == "1n2_2_2_2_1_2_1_$num"} {
                               set tbopt $num
                               break
                            }
                          }
                        table_choice COMB_ORTH_HILL_CREE$tbopt $matid 0
                        }
                        1n2_2_2_2_2_1_1_1 {
                        table_choice COMB_ISOT_CREE_BISO $matid 0
                        } 
                        1n2_2_2_2_2_1_1_2_* {
                          foreach num {1 2 3 4 5 6 7 8 9 10 11 12 13 } {
                            if {$node == "1n2_2_2_2_2_1_1_2_$num"} {
                               set tbopt $num
                               break
                            }
                          } 
                        set ext _BISO
                        table_choice COMB_ISOT_CREE$tbopt$ext $matid 0
                        }
                        1n2_2_2_2_2_1_2_1 {
                        table_choice COMB_ISOT_CREE_MISO $matid 0
                        } 
                        1n2_2_2_2_2_1_2_2_* {
                          foreach num {1 2 3 4 5 6 7 8 9 10 11 12 13 } {
                            if {$node == "1n2_2_2_2_2_1_2_2_$num"} {
                               set tbopt $num
                               break
                            }
                          } 
                        set ext _MISO
                        table_choice COMB_ISOT_CREE$tbopt$ext $matid 0
                        }
                        1n2_2_2_2_2_1_3_1 {
                        table_choice COMB_ISOT_CREE_NLIS $matid 0
                        } 
                        1n2_2_2_2_2_1_3_2_* {
                          foreach num {1 2 3 4 5 6 7 8 9 10 11 12 13 } {
                            if {$node == "1n2_2_2_2_2_1_3_2_$num"} {
                               set tbopt $num
                               break
                            }
                          } 
                        set ext _NLIS
                        table_choice COMB_ISOT_CREE$tbopt$ext $matid 0
                        }
                        1n2_2_2_2_2_2_1_1_* {
                          foreach num {1 2 3 4 5 6 7 8 9 10 11 12 13 } {
                            if {$node == "1n2_2_2_2_2_2_1_1_$num"} {
                               set tbopt $num
                               break
                            }
                          } 
                        set ext _BISO
                        set hil _HILL
                        table_choice COMB_ORTH_CREE$tbopt$ext$hil $matid 0
                        }
                        1n2_2_2_2_2_2_2_1_* {
                          foreach num {1 2 3 4 5 6 7 8 9 10 11 12 13 } {
                            if {$node == "1n2_2_2_2_2_2_2_1_$num"} {
                               set tbopt $num
                               break
                            }
                          } 
                        set ext _MISO
                        set hil _HILL
                        table_choice COMB_ORTH_CREE$tbopt$ext$hil $matid 0
                        }
                        1n2_2_2_2_2_2_3_1_* {
                          foreach num {1 2 3 4 5 6 7 8 9 10 11 12 13 } {
                            if {$node == "1n2_2_2_2_2_2_3_1_$num"} {
                               set tbopt $num
                               break
                            }
                          } 
                        set ext _NLIS
                        set hil _HILL
                        table_choice COMB_ORTH_CREE$tbopt$ext$hil $matid 0
                        }
                        1n2_2_2_2_3_1_1_1_* {
                          foreach num {1 2 3 4 5 6 7 8 9 10 11 12 13 } {
                            if {$node == "1n2_2_2_2_3_1_1_1_$num"} {
                               set tbopt $num
                               break
                            }
                          } 
                        set ext _BKIN
                        table_choice COMB_ISOT_CREE$tbopt$ext $matid 0
                        }
                        1n2_2_2_2_3_1_2_1_* {
                          foreach num {1 2 3 4 5 6 7 8 9 10 11 12 13 } {
                            if {$node == "1n2_2_2_2_3_1_2_1_$num"} {
                               set tbopt $num
                               break
                            }
                          } 
                        set ext _BKIN
                        set hil _HILL
                        table_choice COMB_ORTH_CREE$tbopt$ext$hil $matid 0
                        }
                        1n2_2_2_2_4_1 {
                        table_choice COMB_ISOT_CREE_SWEL $matid 0
                        }
                        1n2_2_3_1 {
                        table_choice COMB_ISOT_CONC $matid 0
                        }
                        1n2_2_3_2 {
                        table_choice COMB_ISOT_DP1 $matid 0
                        }
                        1n2_2_3_3 {
                        table_choice COMB_ISOT_DP2 $matid 0
                        }
                        1n2_2_3_4 {
                        table_choice FAIL $matid 0
                        }
                        1n2_2_5_1 {
                        table_choice COMB_ISOT_CAST1 $matid 0
                        }
                        1n2_2_5_2 {
                        table_choice UNIACOMP $matid 0
                        }
                        1n2_2_5_3 {
                        table_choice UNIATENS $matid 0
                        }
                        1n2_2_6 {
                        table_choice COMB_ISOT_SMA $matid 0
                        }
                        1n3 {
                        table_choice DENS $matid 0
                        }
                        1n4_1 {
                        table_choice ALPD $matid 0
                        }
                        1n4_2 {
                        table_choice BETD $matid 0
                        }
                        1n4_3 {
                        table_choice DMPR $matid 0
                        }
                        1n5 {
                        table_choice MU $matid 0
                        }
                        1n6_1_1 {
                        table_choice ALPI $matid 0
                        }
                        1n6_1_2 {
                        table_choice ALPO $matid 0
                        }
                        1n6_2_1 {
                        table_choice CTEI $matid 0
                        }
                        1n6_2_2 {
                        table_choice CTEO $matid 0
                        }
                        1n6_3_1 {
                        table_choice THSI $matid 0
                        }
                        1n6_3_2 {
                        table_choice THSO $matid 0
                        }
                        1n7_1_1 {
                        table_choice GASKPARA $matid 0
                        }
                        1n7_1_2 {
                        table_choice GASKCOMP $matid 0
                        }
                        1n7_1_3 {
                        table_choice COMB_GASKCOMP_GASKLUNL $matid 0
                        }
                        1n7_1_4 {
                        table_choice COMB_GASKCOMP_GASKNUNL $matid 0
                        }
                        1n7_1_5 {
                        table_choice GASKTSS $matid 0
                        }
                        1n7_3_1_1 {
                        table_choice JOINTSTIF $matid 0
                        }
                        1n7_3_1_2 {
                        table_choice JOINTDAMP $matid 0
                        }
                        1n7_3_1_3 {
                        table_choice JOINTFRIC $matid 0
                        }
                        1n7_3_2_s0 {
                        table_choice JOINTJNSA $matid 0
                        }
                        1n7_3_2_s4 {
                        table_choice JOINTJNS4 $matid 0
                        }
                        1n7_3_2_s6 {
                        table_choice JOINTJNS6 $matid 0
                        }
                        1n7_3_2_d0 {
                        table_choice JOINTJNDA $matid 0
                        }
                        1n7_3_2_d4 {
                        table_choice JOINTJND4 $matid 0
                        }
                        1n7_3_2_d6 {
                        table_choice JOINTJND6 $matid 0
                        }
                        1n7_3_2_f0 {
                        table_choice JOINTJNFA $matid 0
                        }
                        1n7_3_2_f4 {
                        table_choice JOINTJNF4 $matid 0
                        }
                        1n7_3_2_f6 {
                        table_choice JOINTJNF6 $matid 0
                        }
                        1n7_6_1 {
                        table_choice USER $matid 0
                        }
                        1n7_6_2 {
                        table_choice STAT $matid 0
                        }
                        1n7_6_3 {
                        table_choice CREE100 $matid 0
                        }
                        1n7_6_4 {
                        table_choice COMB_CREE100_STAT $matid 0
                        }
                        1n7_6_5 {
                        table_choice HYPE100 $matid 0
                        }
                        1n8_1_1 {
                        table_choice ELAS2 $matid 0
                        }
                        1n8_1_2 {
                        table_choice ELAS9 $matid 0
                        }
                        1n8_1_3 {
                        table_choice ELAS21 $matid 0
                        }
                        1n8_2 {
                        table_choice SDAM $matid 0
                        }
                        3n1_1 {
                        table_choice KXX $matid 0
                        }
                        3n1_2 {
                        table_choice KORT $matid 0
                        }
                        3n2 {
                        table_choice C $matid 0
                        }
                        3n3 {
                        table_choice DENS $matid 0
                        }
                        3n4 {
                        table_choice ENTH $matid 0
                        }
                        3n5 {
                        table_choice EMIS $matid 0
                        }
                        3n6 {
                        table_choice HF $matid 0
                        }
                        3n7 {
                        table_choice QRAT $matid 0
                        }
                        3n8 {
                        table_choice VISC $matid 0
                        }
                        4n1_1 {
                        table_choice MURX $matid 0
                        }
                        4n1_2 {
                        table_choice MURO $matid 0
                        }
                        4n2 {
                        table_choice BH $matid 0
                        }
                        4n3_1 {
                        table_choice MGXX $matid 0
                        }
                        4n3_2 {
                        table_choice MGOR $matid 0
                        }
                        4n4_1 {
                        table_choice PERX $matid 0
                        }
                        4n4_2 {
                        table_choice PERO $matid 0
                        }
                        4n4_3 {
                        table_choice DPER $matid 0
                        }
                        4n5_1 {
                        table_choice RSVX $matid 0
                        }
                        4n5_2 {
                        table_choice RSVO $matid 0
                        }
                        4n6 {
                        table_choice LSST $matid 0
                        }
                        5n1 {
                        table_choice DENS $matid 0
                        }
                        5n2 {
                        table_choice SONC $matid 0
                        }
                        5n3 {
                        table_choice MUAC $matid 0 
                        }
                        6n1 {
                        table_choice VISC $matid 0
                        }
                        6n2 {
                        table_choice WATE $matid 0
                        }
                        6n3_1 {
                        table_choice HFLM $matid 0
                        }
                        6n3_2 {
                        table_choice FCON $matid 0
                        }
                        7n1 {
                        table_choice PIEZ $matid 0
                        }                                            
                        9n1 {
                        table_choice PZRS $matid 0
                        }                                            
                        10n1 {
                        table_choice SBKX $matid 0
                        }                                            
                        10n2 {
                        table_choice SBKO $matid 0
                        }                                            
                        8n1_1_1 {
                        table_choice ISOTdyn $matid 0
                        }                                            
                        8n1_1_2 {
                        table_choice ORTHdyn $matid 0
                        }                                            
                        8n1_1_3 {
                        table_choice ANELdyn $matid 0
                        }                                            
                        8n1_1_4 {
                        table_choice FLUIdyn $matid 0
                        }                                            
                        8n2_1_1_1 {
                        table_choice BLAT $matid 0
                        }                                            
                        8n2_1_1_2_1 {
                        table_choice MOON1dyn $matid 0
                        }                                            
                        8n2_1_1_2_2 {
                        table_choice MOONdyn $matid 0
                        }                                            
                        8n2_1_2 {
                        table_choice EVISC $matid 0
                        }                                            
                        8n2_2_1_1 {
                        table_choice BISOdyn $matid 0
                        }                                            
                        8n2_2_1_2 {
                        table_choice BISOtmp $matid 0
                        }                                            
                        8n2_2_2_1 {
                        table_choice ANISdyn $matid 0
                        }                                            
                        8n2_2_2_2 {
                        table_choice ANISfld $matid 0
                        }                                            
                        8n2_2_3_1 {
                        table_choice BKINdyn $matid 0
                        }                                            
                        8n2_2_3_2 {
                        table_choice KINEdyn $matid 0
                        }                                            
                        8n2_2_4_1 {
                        table_choice BAR3dyn $matid 0
                        }
                        8n2_2_4_2 {
                        table_choice BARLdyn $matid 0
                        }
                        8n2_2_5_1 {
                        table_choice SENSdyn $matid 0
                        }
                        8n2_2_5_2 {
                        table_choice DEPdyn $matid 0
                        }
                        8n2_2_5_3_1 {
                        table_choice LINRdyn $matid 0
                        }
                        8n2_2_5_3_2 {
                        table_choice LINR1dyn $matid 0
                        }
                        8n2_2_6_1 {
                        table_choice COMPdyn $matid 0
                        }
                        8n2_2_6_2 {
                        table_choice CONCdyn $matid 0
                        }
                        8n2_2_8 {
                        table_choice PLAWdyn $matid 0
                        }
                        8n2_2_9_1 {
                        table_choice HYDRdyn $matid 0
                        }
                        8n2_2_9_2 {
                        table_choice GEOdyn $matid 0
                        }
                        8n2_2_10 {
                        table_choice THERMdyn $matid 0
                        }
                        8n2_3_1 {
                        table_choice CELLdyn $matid 0
                        }
                        8n2_3_2 {
                        table_choice VISCdyn $matid 0
                        }
                        8n2_3_3 {
                        table_choice DENSdyn $matid 0
                        }
                        8n2_3_4 {
                        table_choice CRSHdyn $matid 0
                        }
                        8n2_3_5 {
                        table_choice HONEdyn $matid 0
                        }
                        8n3_1_1 {
                        table_choice JOHN1dyn $matid 0
                        }
                        8n3_1_2 {
                        table_choice NULL1dyn $matid 0
                        }
                        8n3_1_3 {
                        table_choice ZERI1dyn $matid 0
                        }
                        8n3_1_4 {
                        table_choice STEN1dyn $matid 0
                        }
                        8n3_2_1 {
                        table_choice JOHN2dyn $matid 0
                        }
                        8n3_2_2 {
                        table_choice NULL2dyn $matid 0
                        }
                        8n3_2_3 {
                        table_choice ZERI2dyn $matid 0
                        }
                        8n3_2_4 {
                        table_choice STEN2dyn $matid 0
                        }
                        8n3_3_1 {
                        table_choice JOHN3dyn $matid 0
                        }
                        8n3_3_2 {
                        table_choice NULL3dyn $matid 0
                        }
                        8n3_3_3 {
                        table_choice ZERI3dyn $matid 0
                        }
                        8n3_3_4 {
                        table_choice STEN3dyn $matid 0
                        }
                        8n3_4 {
                        table_choice BAMMdyn $matid 0
                        }
                        8n4_1_1 {
                        table_choice SPNGdyn $matid 0
                        }
                        8n4_1_2 {
                        table_choice NLSPdyn $matid 0
                        }
                        8n4_1_3 {
                        table_choice NLESdyn $matid 0
                        }
                        8n4_1_4 {
                        table_choice ELSPdyn $matid 0
                        }
                        8n4_1_5 {
                        table_choice INSPdyn $matid 0
                        }
                        8n4_1_6 {
                        table_choice MAXSdyn $matid 0
                        }
                        8n4_2_1 {
                        table_choice LNVIdyn $matid 0
                        }
                        8n4_2_2 {
                        table_choice NLVIdyn $matid 0
                        }
                        8n4_3 {
                        table_choice CABLdyn $matid 0
                        }
                        8n5 {
                        table_choice RIGIdyn $matid 0
                        }
                        11n1_1 {
                        table_choice DXX $matid 0
                        }
                        11n1_2 {
                        table_choice DORT $matid 0
                        }
                        11n2_1 {
                        table_choice BETI $matid 0
                        }
                        11n2_2 {
                        table_choice BETO $matid 0
                        }
                        11n3 {
                        table_choice CSAT $matid 0
                        }
                        fav* {
                           set list [split $node _]
                           set label [lindex $list 1]
                           table_choice $label $matid 0
                        }
                 }
    }

   proc table_choice { matlabel matuse next} {
          variable matid
          variable curvenum
          variable treeChildsite
          variable npts
          variable parent

          set matid $matuse
                 switch -glob -- $matlabel {
                        ISOTdyn {
                        euidl::material::mat2::TABLE2 ISOTdyn $matid $next
                        }
                        ORTHdyn {
                        euidl::material::mat2::TABLE2 ORTHdyn $matid $next
                        }
                        ANELdyn {
                        euidl::material::mat2::TABLE2 ANELdyn $matid $next
                        }
                        FLUIdyn {
                        euidl::material::mat2::TABLE2 FLUIdyn $matid $next
                        }
                        BLAT {
                        euidl::material::mat2::TABLE2 BLAT $matid $next
                        }
                        MOONdyn {
                        euidl::material::mat2::TABLE2 MOONdyn $matid $next
                        }
                        MOON1dyn {
                        euidl::material::mat2::TABLE2 MOON1dyn $matid $next
                        }
                        EVISC {
                        euidl::material::mat2::TABLE2 EVISC $matid $next
                        }
                        BISOdyn {
                        euidl::material::mat2::TABLE2 BISOdyn $matid $next
                        }
                        BISOtmp {
                        euidl::material::mat2::TABLE2 BISOtmp $matid $next
                        }
                        ANISdyn {
                        euidl::material::mat2::TABLE2 ANISdyn $matid $next
                        }
                        ANISfld {
                        euidl::material::mat2::TABLE2 ANISfld $matid $next
                        }
                        BKINdyn {
                        euidl::material::mat2::TABLE2 BKINdyn $matid $next
                        }
                        KINEdyn {
                        euidl::material::mat2::TABLE2 KINEdyn $matid $next
                        }
                        BAR3dyn {
                        euidl::material::mat2::TABLE2 BAR3dyn $matid $next
                        }
                        BARLdyn {
                        euidl::material::mat2::TABLE2 BARLdyn $matid $next
                        }
                        SENSdyn {
                        euidl::material::mat2::TABLE2 SENSdyn $matid $next
                        }
                        DEPdyn {
                        euidl::material::mat2::TABLE2 DEPdyn $matid $next
                        }
                        COMPdyn {
                        euidl::material::mat2::TABLE2 COMPdyn $matid $next
                        }
                        CONCdyn {
                        euidl::material::mat2::TABLE2 CONCdyn $matid $next
                        }
                        LINRdyn {
                        euidl::material::mat2::TABLE2 LINRdyn $matid $next
                        }
                        LINR1dyn {
                        euidl::material::mat2::TABLE2 LINR1dyn $matid $next
                        }
                        PLAWdyn {
                        euidl::material::mat2::TABLE2 PLAWdyn $matid $next
                        }
                        HYDRdyn {
                        euidl::material::mat2::TABLE2 HYDRdyn $matid $next
                        }
                        GEOdyn {
                        euidl::material::mat2::TABLE2 GEOdyn $matid $next
                        }
                        THERMdyn {
                        euidl::material::mat2::TABLE2 THERMdyn $matid $next
                        }
                        CELLdyn {
                        euidl::material::mat2::TABLE2 CELLdyn $matid $next
                        }
                        VISCdyn {
                        euidl::material::mat2::TABLE2 VISCdyn $matid $next
                        }
                        DENSdyn {
                        euidl::material::mat2::TABLE2 DENSdyn $matid $next
                        }
                        CRSHdyn {
                        euidl::material::mat2::TABLE2 CRSHdyn $matid $next
                        }
                        HONEdyn {
                        euidl::material::mat2::TABLE2 HONEdyn $matid $next
                        }
                        JOHN1dyn {
                        euidl::material::mat2::TABLE2 JOHN1dyn $matid $next
                        }
                        NULL1dyn {
                        euidl::material::mat2::TABLE2 NULL1dyn $matid $next
                        }
                        ZERI1dyn {
                        euidl::material::mat2::TABLE2 ZERI1dyn $matid $next
                        }
                        STEN1dyn {
                        euidl::material::mat2::TABLE2 STEN1dyn $matid $next
                        }
                        JOHN2dyn {
                        euidl::material::mat2::TABLE2 JOHN2dyn $matid $next
                        }
                        NULL2dyn {
                        euidl::material::mat2::TABLE2 NULL2dyn $matid $next
                        }
                        ZERI2dyn {
                        euidl::material::mat2::TABLE2 ZERI2dyn $matid $next
                        }
                        STEN2dyn {
                        euidl::material::mat2::TABLE2 STEN2dyn $matid $next
                        }
                        JOHN3dyn {
                        euidl::material::mat2::TABLE2 JOHN3dyn $matid $next
                        }
                        NULL3dyn {
                        euidl::material::mat2::TABLE2 NULL3dyn $matid $next
                        }
                        ZERI3dyn {
                        euidl::material::mat2::TABLE2 ZERI3dyn $matid $next
                        }
                        STEN3dyn {
                        euidl::material::mat2::TABLE2 STEN3dyn $matid $next
                        }
                        BAMMdyn {
                        euidl::material::mat2::TABLE2 BAMMdyn $matid $next
                        }
                        SPNGdyn {
                        euidl::material::mat2::TABLE2 SPNGdyn $matid $next
                        }
                        NLSPdyn {
                        euidl::material::mat2::TABLE2 NLSPdyn $matid $next
                        }
                        NLESdyn {
                        euidl::material::mat2::TABLE2 NLESdyn $matid $next
                        }
                        ELSPdyn {
                        euidl::material::mat2::TABLE2 ELSPdyn $matid $next
                        }
                        INSPdyn {
                        euidl::material::mat2::TABLE2 INSPdyn $matid $next
                        }
                        MAXSdyn {
                        euidl::material::mat2::TABLE2 MAXSdyn $matid $next
                        }
                        LNVIdyn {
                        euidl::material::mat2::TABLE2 LNVIdyn $matid $next
                        }
                        CABLdyn {
                        euidl::material::mat2::TABLE2 CABLdyn $matid $next
                        }
                        RIGIdyn {
                        euidl::material::mat2::TABLE2 RIGIdyn $matid $next
                        }
                        NLVIdyn {
                        euidl::material::mat2::TABLE2 NLVIdyn $matid $next
                        }
                        CHAB {
                        euidl::material::mat1::TABLE1 CHAB $matid $next
                        }
                        ANEL {
                        euidl::material::mat1::TABLE1 ANEL $matid $next
                        }
                        JOIN* {
                           set linearjoint 0
                           foreach opt {STIF DAMP FRIC} {
                              if {$matlabel == "JOINT$opt"} {
                                 set tbopt $opt
                                 set linearjoint 1
                                 break
                              }
                           }
                           if {$linearjoint == 0} {
                              foreach opt {JNSA JNS4 JNS6 JNDA JND4 JND6 JNFA JNF4 JNF6} {
                                 if {$matlabel == "JOINT$opt"} {
                                    set tbopt $opt
                                    break
                                 }
                              }
                           }
                           if {$linearjoint == 1} {
                              euidl::material::mat1::TABLE1 JOINT$tbopt $matid $next
                           } else {
                              euidl::material::mat3::TABLE3 JOINT$tbopt $matid $next
                           }
                        }
                        MELA {
                        euidl::material::mat3::TABLE3 MELA $matid $next
                        }
                        EVIS {
                        euidl::material::mat4::TABLE4 EVIS $matid $next
                        }
                        BISO {
                        euidl::material::mat1::TABLE1 BISO $matid $next
                        }
                        MISO {
                        euidl::material::mat3::TABLE3 MISO $matid $next
                        }
                        PLAS1 {
                        euidl::material::mat3::TABLE3 PLAS1 $matid $next
                        }
                        PLAS4 {
                        euidl::material::mat3::TABLE3 PLAS4 $matid $next
                        }
                        NLIS {
                        euidl::material::mat1::TABLE1 NLIS $matid $next
                        }
                        ANIS {
                        euidl::material::mat4::TABLE4 ANIS $matid $next
                        }
                        BKIN { 
                        euidl::material::mat1::TABLE1 BKIN $matid $next
                        } 
                        MKIN {
                        euidl::material::mat4::TABLE4 MKIN $matid $next
                        }
                        KINH {
                        euidl::material::mat3::TABLE3 KINH $matid $next
                        }
                        DP* {
                          if {$matlabel == "DPER"} {
                             euidl::material::mat4::TABLE4 DPER $matid $next  
                          } else {
                             foreach num {1 2} {
                               if {$matlabel == "DP$num"} {
                                  set tbopt $num
                                  break
                               }
                             }
                             euidl::material::mat4::TABLE4 DP$tbopt $matid $next  
                          }
                        }
                        CREE {
                        euidl::material::mat4::TABLE4 CREE $matid $next
                        }
                        CREE* {
                          foreach num {1 2 3 4 5 6 7 8 9 10 11 12 13 100 } {
                            if {$matlabel == "CREE$num"} {
                               set tbopt $num
                               break
                            }
                          }
                        euidl::material::mat1::TABLE1 CREE$tbopt $matid $next  
                        }
                        GASK* {
                          foreach opt {PARA COMP LUNL NUNL TSS} {
                            if {$matlabel == "GASK$opt"} {
                               set tbopt $opt
                               break
                            }
                          }
                          if {$tbopt == "PARA"} {
                            euidl::material::mat1::TABLE1 GASK$tbopt $matid $next  
                          } elseif {$tbopt == "TSS"} {
                            euidl::material::mat1::TABLE1 GASK$tbopt $matid $next  
                          } elseif {$tbopt == "NUNL"} {
                            euidl::material::mat6::TABLE6 GASK$tbopt $matid $next  
                          } else {
                            euidl::material::mat3::TABLE3 GASK$tbopt $matid $next  
                          }
                        }
                        CAST* {
                          foreach opt {1 2} {
                            if {$matlabel == "CAST$opt"} {
                               set tbopt $opt
                               break
                            }
                          }
                          euidl::material::mat1::TABLE1 CAST$tbopt $matid $next
                        }
                        UNIA* {
                          foreach opt {COMP TENS} {
                            if {$matlabel == "UNIA$opt"} {
                               set tbopt $opt
                               break
                            }
                          }
                          euidl::material::mat3::TABLE3 UNIA$tbopt $matid $next
                        }
                        PRONY* {
                          foreach opt {SHEAR BULK} {
                            if {$matlabel == "PRONY$opt"} {
                               set tbopt $opt
                               break
                            }
                          }
                          euidl::material::mat1::TABLE1 PRONY$tbopt $matid $next
                        }
                        SHIFT {
                        euidl::material::mat1::TABLE1 SHIFT $matid $next
                        }
                        ANAN {
                        euidl::material::mat4::TABLE4 ANAN $matid $next
                        }
                        ISOT {
                        euidl::material::mat5::TABLE5 ISOT $matid $next
                        }
                        ISLS {
                        euidl::material::mat5::TABLE5 ISLS $matid $next
                        }
                        ORTH {
                        euidl::material::mat5::TABLE5 ORTH $matid $next
                        }
                        DENS {
                        euidl::material::mat5::TABLE5 DENS $matid $next
                        }
                        DELD {
                        euidl::material::mat5::TABLE5 DELD $matid $next
                        }
                        DAMP {
                        euidl::material::mat5::TABLE5 DAMP $matid $next
                        }
                        ALPD {
                        euidl::material::mat5::TABLE5 ALPD $matid $next
                        }
                        BETD {
                        euidl::material::mat5::TABLE5 BETD $matid $next
                        }
                        DMPR {
                        euidl::material::mat5::TABLE5 DMPR $matid $next
                        }
                        MU {
                        euidl::material::mat5::TABLE5 MU $matid $next
                        }
                        MUAC {
                        euidl::material::mat5::TABLE5 MUAC $matid $next
                        }
                        ALPI {
                        euidl::material::mat5::TABLE5 ALPI $matid $next
                        }
                        ALPL {
                        euidl::material::mat5::TABLE5 ALPL $matid $next
                        }
                        ALPO {
                        euidl::material::mat5::TABLE5 ALPO $matid $next
                        }
                        CTEI {
                        euidl::material::mat5::TABLE5 CTEI $matid $next
                        }
                        CTEO {
                        euidl::material::mat5::TABLE5 CTEO $matid $next
                        }
                        THSI {
                        euidl::material::mat5::TABLE5 THSI $matid $next
                        }
                        THSO {
                        euidl::material::mat5::TABLE5 THSO $matid $next
                        }
                        HILL {
                        euidl::material::mat1::TABLE1 HILL $matid $next
                        }
                        exp* {
                           if {$curvenum != ""} {
                             ::euidl::material::CurveFit::createwithcurveid $matid $curvenum
                           }
                        }
                        func* {
                           if {$curvenum != ""} {
                             ::euidl::material::CurveFit::createwithfunctionid $matid $curvenum
                           }
                        }
                        HYPEmo2 {
                        euidl::material::mat1::TABLE1 HYPEmo2 $matid $next
                        }
                        HYPEmo3 {
                        euidl::material::mat1::TABLE1 HYPEmo3 $matid $next
                        }
                        HYPEmo5 {
                        euidl::material::mat1::TABLE1 HYPEmo5 $matid $next
                        }
                        HYPEmo9 {
                        euidl::material::mat1::TABLE1 HYPEmo9 $matid $next
                        }
                        HYPEog1 {
                        euidl::material::mat1::TABLE1 HYPEog1 $matid $next
                        }
                        HYPEog2 {
                        euidl::material::mat1::TABLE1 HYPEog2 $matid $next
                        }
                        HYPEog3 {
                        euidl::material::mat1::TABLE1 HYPEog3 $matid $next
                        }
                        HYPEog4 {
                        euidl::material::mat1::TABLE1 HYPEog4 $matid $next
                        }
                        HYPEog5 {
                        euidl::material::mat1::TABLE1 HYPEog5 $matid $next
                        } 
                        HYPEogG {
                        euidl::material::mat1::TABLE1 HYPEogG $matid $next
                        }   
                        #HYPE3 {
                        #euidl::material::mat1::TABLE1 HYPE3 $matid $next
                        #}
                        HYPEye1 {
                        euidl::material::mat1::TABLE1 HYPEye1 $matid $next
                        }
                        HYPEye2 {
                        euidl::material::mat1::TABLE1 HYPEye2 $matid $next
                        }
                        HYPEye3 {
                        euidl::material::mat1::TABLE1 HYPEye3 $matid $next
                        }
                        HYPEye4 {
                        euidl::material::mat1::TABLE1 HYPEye4 $matid $next
                        }
                        HYPEye5 {
                        euidl::material::mat1::TABLE1 HYPEye5 $matid $next
                        }
                        HYPEyeG {
                        euidl::material::mat1::TABLE1 HYPEyeG $matid $next
                        }
                        HYPE4 {
                        euidl::material::mat1::TABLE1 HYPE4 $matid $next
                        }
                        HYPE5 {
                        euidl::material::mat1::TABLE1 HYPE5 $matid $next
                        }
                        HYPEpo1 {
                        euidl::material::mat1::TABLE1 HYPEpo1 $matid $next
                        }
                        HYPEpo2 {
                        euidl::material::mat1::TABLE1 HYPEpo2 $matid $next
                        }
                        HYPEpo3 {
                        euidl::material::mat1::TABLE1 HYPEpo3 $matid $next
                        }
                        HYPEpo4 {
                        euidl::material::mat1::TABLE1 HYPEpo4 $matid $next
                        }
                        HYPEpo5 {
                        euidl::material::mat1::TABLE1 HYPEpo5 $matid $next
                        } 
                        HYPEpoG {
                        euidl::material::mat1::TABLE1 HYPEpoG $matid $next
                        }
                        HYPE8 {
                        euidl::material::mat1::TABLE1 HYPE8 $matid $next
                        }
                        HYPE10 {
                        euidl::material::mat1::TABLE1 HYPE10 $matid $next
                        }
                        HYPE11 {
                        euidl::material::mat1::TABLE1 HYPE11 $matid $next
                        }
                        HYPEfo1 {
                        euidl::material::mat1::TABLE1 HYPEfo1 $matid $next
                        }
                        HYPEfo2 {
                        euidl::material::mat1::TABLE1 HYPEfo2 $matid $next
                        }
                        HYPEfo3 {
                        euidl::material::mat1::TABLE1 HYPEfo3 $matid $next
                        }
                        HYPEfo4 {
                        euidl::material::mat1::TABLE1 HYPEfo4 $matid $next
                        }
                        HYPEfo5 {
                        euidl::material::mat1::TABLE1 HYPEfo5 $matid $next
                        }
                        HYPEfoG {
                        euidl::material::mat1::TABLE1 HYPEfoG $matid $next
                        }

                        HYPE100 {
                        euidl::material::mat1::TABLE1 HYPE100 $matid $next
                        }
                        MOON {
                        euidl::material::mat1::TABLE1 MOON $matid $next
                        }
                        USER {
                        euidl::material::mat1::TABLE1 USER $matid $next
                        }
                        STAT {
                        euidl::material::mat1::TABLE1 STAT $matid $next
                        }
                        RATE  {
                        euidl::material::mat1::TABLE1 RATE $matid $next
                        }
                        CONC  {
                        euidl::material::mat1::TABLE1 CONC $matid $next
                        }
                        SMA  {
                        euidl::material::mat1::TABLE1 SMA $matid $next
                        }
                        SWEL  {
                        euidl::material::mat4::TABLE4 SWEL $matid $next
                        }
                        FAIL  {
                        euidl::material::mat4::TABLE4 FAIL $matid $next
                        }
                        KXX {
                        euidl::material::mat5::TABLE5 KXX $matid $next
                        }
                        KORT {
                        euidl::material::mat5::TABLE5 KORT $matid $next
                        }
                        DXX {
                        euidl::material::mat5::TABLE5 DXX $matid $next
                        }
                        DORT {
                        euidl::material::mat5::TABLE5 DORT $matid $next
                        }
                        BETI {
                        euidl::material::mat5::TABLE5 BETI $matid $next
                        }
                        BETO {
                        euidl::material::mat5::TABLE5 BETO $matid $next
                        }
                        CSAT {
                        euidl::material::mat5::TABLE5 CSAT $matid $next
                        }
                        C {
                        euidl::material::mat5::TABLE5 C $matid $next
                        }
                        ENTH {
                        euidl::material::mat5::TABLE5 ENTH $matid $next
                        }
                        EMIS {
                        euidl::material::mat5::TABLE5 EMIS $matid $next
                        }
                        HF {
                        euidl::material::mat5::TABLE5 HF $matid $next
                        }
                        QRAT {
                        euidl::material::mat5::TABLE5 QRAT $matid $next
                        }
                        MURX {
                        euidl::material::mat5::TABLE5 MURX $matid $next
                        }
                        MURO {
                        euidl::material::mat5::TABLE5 MURO $matid $next
                        }
                        BH {
                        euidl::material::mat3::TABLE3 BH $matid $next
                        }
                        MGXX {
                        euidl::material::mat5::TABLE5 MGXX $matid $next
                        }
                        MGOR {
                        euidl::material::mat5::TABLE5 MGOR $matid $next
                        }
                        PERX {
                        euidl::material::mat5::TABLE5 PERX $matid $next
                        }
                        PERO {
                        euidl::material::mat5::TABLE5 PERO $matid $next
                        }
                        RSVX {
                        euidl::material::mat5::TABLE5 RSVX $matid $next
                        }
                        RSVO {
                        euidl::material::mat5::TABLE5 RSVO $matid $next
                        }
                        SONC {
                        euidl::material::mat5::TABLE5 SONC $matid $next
                        }
                        VISC {
                        euidl::material::mat5::TABLE5 VISC $matid $next
                        }
                        PIEZ {
                        euidl::material::mat4::TABLE4 PIEZ $matid $next
                        }
                        PZRS {
                        euidl::material::mat4::TABLE4 PZRS $matid $next
                        }
                        WATE {
                        euidl::material::mat4::TABLE4 WATE $matid $next
                        }
                        FCON {
                        euidl::material::mat3::TABLE3 FCON $matid $next
                        }
                        HFLM {
                        euidl::material::mat3::TABLE3 HFLM $matid $next
                        }
                        LSST {
                        euidl::material::mat5::TABLE5 LSST $matid $next
                        }
                        SBKX {
                        euidl::material::mat5::TABLE5 SBKX $matid $next
                        }
                        SBKO {
                        euidl::material::mat5::TABLE5 SBKO $matid $next
                        }
                        ELAS* {
                          foreach pts {2 9 21} {
                            if {$matlabel == "ELAS$pts"} {
                               set npts $pts
                               break
                            }
                          }
                          euidl::material::mat7::TABLE7 ELAS$npts $matid $next
                        }
                        SDAM {
                        euidl::material::mat7::TABLE7 SDAM $matid $next
                        }
                        COMB* {
                        set list [split $matlabel _]
                        set label [lindex $list 1]
                       
                        set ix [lsearch -exact $list $label]
                        # remove current label from list
                       
                       
                        set list [lreplace $list $ix $ix]
                         

                       # get next variable
                      
                        
                       set length [llength $list]
                       set dynaflag [lindex $list [expr $length-1]]
                      
                       if {$length == 1} {
                         set next 0
                       } else {
                         set next COMB
                         for {set i 1} {$i <=[expr $length -1]} {incr i 1} {
                            set matlab [lindex $list $i]
                            set undersc _
                            set matlab $undersc$matlab
                            set next $next$matlab
                         }
                       }
                       if {$label == "ISOT" && $dynaflag != 999} {
                            set mpEX [ans_getvalue EX,$matid,EXIS]
                            set mpPRXY [ans_getvalue PRXY,$matid,EXIS]
                            set mpNUXY [ans_getvalue NUXY,$matid,EXIS]
                            set PoiXY 0
                            if {$mpPRXY == 1 || $mpNUXY == 1} {set PoiXY 1}
                            if {$mpEX == 1} {
                               #Elastic prop are already defined : skip it, go to next label!
                               table_choice $next $matid 0
                            } else {
                               tk_messageBox -icon warning \
                                -title [msgcat::mc "Note"] \
                                -parent $parent \
                                 -type ok \
                                -message [msgcat::mc " For this material model you\
                                      have to specify elastic properties first."]
                                table_choice $label $matid $next
                            }
                       } elseif {$label == "ORTH" && $dynaflag != 999} {
                            set mpEX [ans_getvalue EX,$matid,EXIS]
                            set mpEY [ans_getvalue EY,$matid,EXIS]
                            set mpEZ [ans_getvalue EZ,$matid,EXIS]
                            set mpPRXY [ans_getvalue PRXY,$matid,EXIS]
                            set mpPRYZ [ans_getvalue PRYZ,$matid,EXIS]
                            set mpPRXZ [ans_getvalue PRXZ,$matid,EXIS]
                            set mpNUXY [ans_getvalue NUXY,$matid,EXIS]
                            set mpNUYZ [ans_getvalue NUYZ,$matid,EXIS]
                            set mpNUXZ [ans_getvalue NUXZ,$matid,EXIS]
                            set PoiXY 0
                            set PoiYZ 0
                            set PoiXZ 0
                            if {$mpPRXY == 1 || $mpNUXY == 1} {set PoiXY 1}
                            if {$mpPRYZ == 1 || $mpNUYZ == 1} {set PoiYZ 1}
                            if {$mpPRXZ == 1 || $mpNUXZ == 1} {set PoiXZ 1} 
                            if {$mpEX == 1} {
                               #Elastic prop are already defined : skip it, go to next label!
                               table_choice $next $matid 0
                            } else {
                               tk_messageBox -icon warning \
                                -title [msgcat::mc "Note"] \
                                -parent $parent \
                                -type ok \
                                -message [msgcat::mc " For this material model you\
                                      have to specify elastic properties first."]
                                table_choice $label $matid $next
                            }
                       } elseif {$label == "GASKCOMP" && $dynaflag != 999} {
                            set bob [ans_getvalue GASK,$matid,EXIS,,,,COMP]
                            if {$bob == 1} {
                               #Gasket compression curve is already defined : 
                               # skip it, go to next label!
                               table_choice $next $matid 0
                            } else {
                               tk_messageBox -icon warning \
                                -title [msgcat::mc "Note"] \
                                -parent $parent \
                                 -type ok \
                                -message [msgcat::mc " For this gasket unloading model you\
                                      have to specify compression curve first."
]
                                table_choice $label $matid $next
                            }
  
                       } else {
                            table_choice $label $matid $next
                       }


                     }
                 }         
    }

   proc matTable_State { tablestate } {

      variable treeMaterialParent
      variable treeModelParent
      variable modControlMenu
      variable menuItems

      if { [info exists tablestate] } {
         if { $tablestate == 1 } {
            foreach m $menuItems {
               $modControlMenu entryconfigure [msgcat::mc "$m"] -state normal
            }
            $treeMaterialParent configure -state normal
#            set fgcolor [$treeMaterialParent cget -activeforeground]
#            $treeMaterialParent configure -foreground $fgcolor
            $treeModelParent configure -state normal
#            set fgcolor [$treeModelParent cget -activeforeground]
#            $treeModelParent configure -foreground $fgcolor

            #call ModelControl.eui to  the left side
            refreshL
         } else {

            foreach m $menuItems {
               $modControlMenu entryconfigure [msgcat::mc "$m"] -state disabled
            }
            $treeMaterialParent configure -state disabled
            $treeModelParent configure -state disabled

            #call ModelControl.eui to refresh the left side
            #refreshL
         }
      }
   }

     proc getModelNodes { node } {
        variable mylist
        variable favoritesList
        variable numFavorites

# preference filtering begin

       set pr_struc [ans_getvalue active,,keyw,,pr_struc]
       set pr_therm [ans_getvalue active,,keyw,,pr_therm]
       set pr_fluid [ans_getvalue active,,keyw,,pr_fluid]
       set pr_elmag [ans_getvalue active,,keyw,,pr_elmag]
       set pmethod [ans_getvalue active,,keyw,,pmethod]
       set pr_set [ans_getvalue active,,keyw,,pr_set]
       set lsdyna [ans_getvalue active,,keyw,,lsdyna]


       set mylist(root) [ list ]
       set mylist(0root) [ list ]

       # This part defines favorites
       # Linear static is always a favorite
       lappend mylist(root)  {0root "Favorites"}
       lappend mylist(0root) {fav0  "Linear Static"}
       set mylist(fav0)   [list {fav_DENS_0 "Density"} \
                                {fav_ISOT_0 "Linear Isotropic"} \
                                {fav_ALPI_0 "Thermal Expansion (secant-iso)"} ]

       set numFavorites [::euidl::material::favorites::getNumberOfFavorites]

       if {$numFavorites > 0} {
           set favIncr 1
           while {$favIncr <= $numFavorites} {

              set thisFavoriteLabel [::euidl::material::favorites::getFavoriteLabel $favIncr]
              lappend mylist(0root) [list fav$favIncr $thisFavoriteLabel]

              set thisFavorite [::euidl::material::favorites::getFavorite $favIncr]
              set mylist(fav$favIncr) [ list ]
              foreach {tag stuff} $thisFavorite {
                 lappend mylist(fav$favIncr) [list fav_${tag}_$favIncr $stuff]
              }
              incr favIncr
           }
       }

       if {$pr_set == 0 || $pr_struc == 1} {
          if {$lsdyna == 0} {
             lappend mylist(root) {1root "Structural"}
          }
       }
       if {$pr_set == 0 || $pr_therm == 1 || $pr_fluid == 1} {
          if {$lsdyna == 0} {
             lappend mylist(root) {3root "Thermal"}
          }
       }
       if {$pr_set == 0} {
          if {$lsdyna == 0} {
             lappend mylist(root) {4root "Electromagnetics"}
          }
       } elseif {$pr_elmag == 1 && $pmethod == 0} {
          if {$lsdyna == 0} {
             lappend mylist(root) {4root "Electromagnetics"}
          }
       }
       if {$pr_set == 0 || $pr_fluid == 1} {
          if {$lsdyna == 0} {
             lappend mylist(root) {5root "Acoustics"}
          }
       }
       if {$pr_set == 0 || $pr_fluid == 1} {
          if {$lsdyna == 0} {
             lappend mylist(root) {6root "Fluids"}
          }
       }
       if {$pr_elmag == 1 && $pr_struc == 1} {
          if {$lsdyna == 0} {
             lappend mylist(root) {7root "Piezoelectrics"}
             lappend mylist(root) {9root "Piezoresistivity"}
          }
       } elseif {$pr_set == 0} {
          if {$lsdyna == 0} {
             lappend mylist(root) {7root "Piezoelectrics"}
             lappend mylist(root) {9root "Piezoresistivity"}
          }
       }

       if {$pr_elmag == 1 && $pr_therm == 1} {
          if {$lsdyna == 0} {
             lappend mylist(root) {10root "Thermoelectricity"}
          }
       } elseif {$pr_set == 0} {
          if {$lsdyna == 0} {
             lappend mylist(root) {10root "Thermoelectricity"}
          }
       }
       if {$pr_set == 0} {
          if {$lsdyna == 0} {
             lappend mylist(root) {11root "Diffusion"}
          }
       }
       if {$lsdyna == 1} {
          lappend mylist(root) {8root "LS-DYNA"}
       }
# preference filtering end

        set betaKey [ans_getvalue active,,keyw,,beta]
        set noStarGetFor1n8 0
        if {$noStarGetFor1n8 == 1} {
           set mylist(1root) [list {1n1 "Linear"} \
                                   {1n2 "Nonlinear"}\
                                   {1n3 "Density"}\
                                   {1n6 "Thermal Expansion"}\
                                   {1n4 "Damping"}\
                                   {1n5 "Friction Coefficient"}\
                                   {1n8 "Frequency Dependent"}\
                                   {1n7 "Specialized Materials"}]
        } else {
           set mylist(1root) [list {1n1 "Linear"} \
                                   {1n2 "Nonlinear"}\
                                   {1n3 "Density"}\
                                   {1n6 "Thermal Expansion"}\
                                   {1n4 "Damping"}\
                                   {1n5 "Friction Coefficient"}\
                                   {1n7 "Specialized Materials"}]
        }

        set mylist(1n1)   [list {1n1_1 "Elastic"}]

        set mylist(1n1_1) [list {1n1_1_1 "Isotropic"} \
                                {1n1_1_2 "Orthotropic"}\
                                {1n1_1_3 "Anisotropic"}]

        set mylist(1n2) [list {1n2_1 "Elastic"} \
                              {1n2_2 "Inelastic"} \
                              {1n2_3 "Viscoelastic"}]
 
        set mylist(1n6) [list {1n6_1 "Secant Coefficient"} \
                              {1n6_2 "Instantaneous Coefficient"} \
                              {1n6_3 "Thermal Strain"}]

        set mylist(1n6_1) [list {1n6_1_1 "Isotropic"} \
                                {1n6_1_2 "Orthotropic"}]

        set mylist(1n6_2) [list {1n6_2_1 "Isotropic"} \
                                {1n6_2_2 "Orthotropic"}]

        set mylist(1n6_3) [list {1n6_3_1 "Isotropic"} \
                                {1n6_3_2 "Orthotropic"}]

        set mylist(1n7) [list {1n7_1 "Gasket"}\
                              {1n7_3 "Joint Elastic"}\
                              {1n7_6 "User Material Options"}]

        set mylist(1n7_1) [list {1n7_1_1 "General Parameters"} \
                                {1n7_1_2 "Compression"}\
                                {1n7_1_3 "Linear Unloading"}\
                                {1n7_1_4 "Nonlinear Unloading"}\
                                {1n7_1_5 "Transverse Shear"}]

        set mylist(1n7_3) [list \
                                {1n7_3_1 "Linear"} \
                                {1n7_3_2 "Nonlinear"} \
                          ]

        set mylist(1n7_3_1) [list \
                                  {1n7_3_1_1 "Stiffness"} \
                                  {1n7_3_1_2 "Damping"} \
                                  {1n7_3_1_3 "Friction"} \
                            ]

        set mylist(1n7_3_2) [list \
                                  {1n7_3_2_s0 "Stiffness ALL"} \
                                  {1n7_3_2_s4 "Stiffness ROTX"} \
                                  {1n7_3_2_s6 "Stiffness ROTZ"} \
                                  {1n7_3_2_d0 "Damping ALL"} \
                                  {1n7_3_2_d4 "Damping ROTX"} \
                                  {1n7_3_2_d6 "Damping ROTZ"} \
                                  {1n7_3_2_f0 "Friction ALL"} \
                                  {1n7_3_2_f4 "Friction ROTX"} \
                                  {1n7_3_2_f6 "Friction ROTZ"} \
                            ]

        set mylist(1n7_6) [list {1n7_6_1 "User Constants"} \
                                {1n7_6_2 "State Variables"}\
                                {1n7_6_3 "Creep"}\
                                {1n7_6_4 "Creep and State Variables"}\
                                {1n7_6_5 "Hyperelastic"}]

        set mylist(1n8) [list {1n8_1 "Elasticity"}\
                              {1n8_2 "Damping"}]

        set mylist(1n8_1) [list {1n8_1_1 "Isotropic"} \
                                {1n8_1_2 "Orthotropic"}\
                                {1n8_1_3 "Anisotropic"}]

        set mylist(1n2_1) [list {1n2_1_1 "Hyperelastic"} \
                                {1n2_1_2 "Multilinear Elastic"}]

        set mylist(1n2_1_1) [list \
                                  {Hyper_Fit "HyperElastic Curve Fitting"} \
                                  {1n2_1_1_1 "Mooney-Rivlin"} \
                                  {1n2_1_1_2 "Ogden"} \
                                  {1n2_1_1_3 "Neo-Hookean"} \
                                  {1n2_1_1_4 "Polynomial Form"} \
                                  {1n2_1_1_5 "Arruda-Boyce"} \
                                  {1n2_1_1_6 "Gent"} \
                                  {1n2_1_1_7 "Yeoh"} \
                                  {1n2_1_1_8 "Blatz-Ko (Foam)"} \
                                  {1n2_1_1_9 "Ogden    (Foam)"} \
                                  {1n2_1_1_10 "Mooney-Rivlin (TB,MOON)"} \
                            ]

        set mylist(1n2_1_1_1) [list {1n2_1_1_1_1 "2 parameters"} \
                            {1n2_1_1_1_2 "3 parameters"} \
                            {1n2_1_1_1_3 "5 parameters"} \
                            {1n2_1_1_1_4 "9 parameters"} ] 
              
        set mylist(1n2_1_1_2) [list {1n2_1_1_2_1 "1 term"} \
                            {1n2_1_1_2_2 "2 terms"} \
                            {1n2_1_1_2_3 "3 terms"} \
                            {1n2_1_1_2_4 "4 terms"} \
                            {1n2_1_1_2_5 "5 terms"} \
                            {1n2_1_1_2_6 "General"} ]
       
        set mylist(1n2_1_1_4) [list {1n2_1_1_4_1 "1 term"} \
                            {1n2_1_1_4_2 "2 terms"} \
                            {1n2_1_1_4_3 "3 terms"} \
                            {1n2_1_1_4_4 "4 terms"} \
                            {1n2_1_1_4_5 "5 terms"} \
                            {1n2_1_1_4_6 "General"} ]

        set mylist(1n2_1_1_7) [list {1n2_1_1_7_1 "1st order"} \
                            {1n2_1_1_7_2 "2nd order"} \
                            {1n2_1_1_7_3 "3rd order"} \
                            {1n2_1_1_7_4 "4th order"} \
                            {1n2_1_1_7_5 "5th order"} \
                            {1n2_1_1_7_6 "General"} ]
       
        set mylist(1n2_1_1_9) [list {1n2_1_1_9_1 "1st order"} \
                            {1n2_1_1_9_2 "2nd order"} \
                            {1n2_1_1_9_3 "3rd order"} \
                            {1n2_1_1_9_4 "4th order"} \
                            {1n2_1_1_9_5 "5th order"} \
                            {1n2_1_1_9_6 "General"} ]
       
        set mylist(1n2_2) [list {Plas_Fit "Plasticity Curve Fitting"} \
                                {1n2_2_1 "Rate Independent"} \
                                {1n2_2_2 "Rate Dependent"} \
                                {1n2_2_3 "Non-metal Plasticity"} \
                                {1n2_2_5 "Cast-Iron"} \
                                {1n2_2_6 "Shape Memory Alloy"}]
   
        set mylist(1n2_2_2) [list {1n2_2_2_1 "Visco-Plasticity"} \
                                {1n2_2_2_2 "Creep"}]

        set mylist(1n2_2_1) [list {1n2_2_1_1 "Isotropic Hardening Plasticity"} \
                                {1n2_2_1_2 "Generalized Anisotropic Hill Potential"} \
                                {1n2_2_1_3 "Kinematic Hardening Plasticity"} \
                                {1n2_2_1_4 "Combined Kinematic and Isotropic Hardening Plasticity"}]
   
        set mylist(1n2_2_1_1) [list {1n2_2_1_1_1 "Mises Plasticity"} \
                                 {1n2_2_1_1_2 "Hill Plasticity"}] 

        set mylist(1n2_2_1_1_1) [list {1n2_2_1_1_1_1 "Bilinear"} \
                            {1n2_2_1_1_1_2 "Multilinear"} \
                            {1n2_2_1_1_1_3 "Nonlinear"}]

        set mylist(1n2_2_1_1_2) [list {1n2_2_1_1_2_1 "Bilinear"} \
                            {1n2_2_1_1_2_2 "Multilinear"} \
                            {1n2_2_1_1_2_3 "Nonlinear"}]

        set mylist(1n2_2_1_3) [list {1n2_2_1_3_1 "Mises Plasticity"} \
                                 {1n2_2_1_3_2 "Hill Plasticity"}]

        set mylist(1n2_2_1_3_1) [list {1n2_2_1_3_1_1 "Bilinear"} \
                               {1n2_2_1_3_1_2 "Multilinear (Fixed table)"} \
                               {1n2_2_1_3_1_3 "Multilinear (General)"} \
                               {1n2_2_1_3_1_4 "Chaboche"}]

        set mylist(1n2_2_1_3_2) [list {1n2_2_1_3_2_1 "Bilinear"} \
                               {1n2_2_1_3_2_2 "Multilinear (Fixed table)"} \
                               {1n2_2_1_3_2_3 "Multilinear (General)"} \
                               {1n2_2_1_3_2_4 "Chaboche"}]

        set mylist(1n2_2_1_4) [list {1n2_2_1_4_1 "Mises Plasticity"} \
                                 {1n2_2_1_4_2 "Hill Plasticity"}]

        set mylist(1n2_2_1_4_1) [list {1n2_2_1_4_1_1 "Chaboche and Bilinear Isotropic"} \
                                  {1n2_2_1_4_1_2 "Chaboche and Multilinear Isotropic"}\
                                  {1n2_2_1_4_1_3 "Chaboche and Nonlinear Isotropic"}]

        set mylist(1n2_2_1_4_2) [list {1n2_2_1_4_2_1 "Chaboche and Bilinear Isotropic"} \
                                  {1n2_2_1_4_2_2 "Chaboche and Multilinear Isotropic"}\
                                  {1n2_2_1_4_2_3 "Chaboche and Nonlinear Isotropic"}]

        set mylist(1n2_2_2_1) [list {1n2_2_2_1_1 "Isotropic Hardening Plasticity"}]

        set mylist(1n2_2_2_1_1) [list {1n2_2_2_1_1_1 "Mises Plasticity"} \
                                 {1n2_2_2_1_1_2 "Hill Plasticity"}]

        set mylist(1n2_2_2_1_1_1) [list {1n2_2_2_1_1_1_1 "Bilinear"} \
                            {1n2_2_2_1_1_1_2 "Multilinear"} \
                            {1n2_2_2_1_1_1_3 "Nonlinear"}]

        set mylist(1n2_2_2_1_1_2) [list {1n2_2_2_1_1_2_1 "Bilinear"} \
                            {1n2_2_2_1_1_2_2 "Multilinear"} \
                            {1n2_2_2_1_1_2_3 "Nonlinear"}]

        set mylist(1n2_2_2_2) [list {Creep_Fit "Creep Curve Fitting"} \
                                    {1n2_2_2_2_1 "Creep only"} \
                                  {1n2_2_2_2_2 "With Isotropic Hardening Plasticity"} \
                                  {1n2_2_2_2_3 "With Kinematic Hardening Plasticity"} \
                                  {1n2_2_2_2_4 "With Swelling"} ]

        set mylist(1n2_2_2_2_1) [list {1n2_2_2_2_1_1 "Mises Potential"} \
                                 {1n2_2_2_2_1_2 "Hill Potential"}]

        set mylist(1n2_2_2_2_1_1) [list {1n2_2_2_2_1_1_1 "Explicit"} \
                                    {1n2_2_2_2_1_1_2 "Implicit"}]
        
        set mylist(1n2_2_2_2_1_2) [list {1n2_2_2_2_1_2_1 "Implicit"}]

        set mylist(1n2_2_2_2_2) [list {1n2_2_2_2_2_1 "With Mises Plasticity"} \
                                 {1n2_2_2_2_2_2 "With Hill Plasticity"}]

        set mylist(1n2_2_2_2_2_1) [list {1n2_2_2_2_2_1_1 "Bilinear"} \
                            {1n2_2_2_2_2_1_2 "Multilinear"} \
                            {1n2_2_2_2_2_1_3 "Nonlinear"}]
        
        set mylist(1n2_2_2_2_2_1_1) [list {1n2_2_2_2_2_1_1_1 "Explicit"} \
                                    {1n2_2_2_2_2_1_1_2 "Implicit"}]
        
        set mylist(1n2_2_2_2_2_1_2) [list {1n2_2_2_2_2_1_2_1 "Explicit"} \
                                    {1n2_2_2_2_2_1_2_2 "Implicit"}]

        set mylist(1n2_2_2_2_2_1_3) [list {1n2_2_2_2_2_1_3_1 "Explicit"} \
                                    {1n2_2_2_2_2_1_3_2 "Implicit"}]

        set mylist(1n2_2_2_2_2_2) [list {1n2_2_2_2_2_2_1 "Bilinear"} \
                            {1n2_2_2_2_2_2_2 "Multilinear"} \
                            {1n2_2_2_2_2_2_3 "Nonlinear"}]

        set mylist(1n2_2_2_2_2_2_1) [list {1n2_2_2_2_2_2_1_1 "Implicit"}]
  
        set mylist(1n2_2_2_2_2_2_2) [list {1n2_2_2_2_2_2_2_1 "Implicit"}]

        set mylist(1n2_2_2_2_2_2_3) [list {1n2_2_2_2_2_2_3_1 "Implicit"}]
        
        set mylist(1n2_2_2_2_3) [list {1n2_2_2_2_3_1 "With Mises Plasticity"} \
                                 {1n2_2_2_2_3_2 "With Hill Plasticity"}]
 
        set mylist(1n2_2_2_2_3_1) [list {1n2_2_2_2_3_1_1 "Bilinear"}]

        set mylist(1n2_2_2_2_3_2) [list {1n2_2_2_2_3_1_2 "Bilinear"}]
  
        set mylist(1n2_2_2_2_3_1_1) [list {1n2_2_2_2_3_1_1_1 "Implicit"}]

        set mylist(1n2_2_2_2_3_1_2) [list {1n2_2_2_2_3_1_2_1 "Implicit"}]
        
        set mylist(1n2_2_2_2_4) [list {1n2_2_2_2_4_1 "Explicit"}]

        set impnodlis {_1_1_2 _1_2_1 _2_1_1_2 _2_1_2_2 _2_1_3_2 _2_2_1_1 \
                      _2_2_2_1 _2_2_3_1 _3_1_1_1 _3_1_2_1}
        for {set i 1} {$i<=13} {incr i 1} {
           set t$i "_$i"
        }
        foreach nada $impnodlis {

          set elt1 [list "1n2_2_2_2$nada$t1" "1:Strain Hardening (Primary)"]
          set elt2 [list "1n2_2_2_2$nada$t2" "2:Time Hardening (Primary)"]
          set elt3 [list "1n2_2_2_2$nada$t3" "3:Generalized Exponential (Primary)"]  
          set elt4 [list "1n2_2_2_2$nada$t4" "4:Generalized Graham (Primary)"]
          set elt5 [list "1n2_2_2_2$nada$t5" "5:Generalized Blackburn (Primary)"]
          set elt6 [list "1n2_2_2_2$nada$t6" "6:Modified Time Hardening (Primary)"]
          set elt7 [list "1n2_2_2_2$nada$t7" "7:Modified Strain Hardening (Primary)"]
          set elt8 [list "1n2_2_2_2$nada$t8" "8:Generalized Garofalo (Secondary)"]
          set elt9 [list "1n2_2_2_2$nada$t9" "9:Exponential Form (Secondary)"]
          set elt10 [list "1n2_2_2_2$nada$t10" "10:Norton (Secondary)"]
          set elt11 [list "1n2_2_2_2$nada$t11" "11:Time Hardening (Primary+Secondary)"]
          set elt12 [list "1n2_2_2_2$nada$t12" "12:Rational polynomial (Primary+Secondary)"]
          set elt13 [list "1n2_2_2_2$nada$t13" "13:Generalized Time Hardening"]
          set mylist(1n2_2_2_2$nada) \
             [list $elt1 $elt2 $elt3 $elt4 $elt5 $elt6 $elt7 $elt8 $elt9 $elt10 $elt11 $elt12 $elt13] 
        }

        # BETA keyword for Cap model and Gasket Transverse Shear
        set betaKey [ans_getvalue active,,keyw,,beta]
        if {$betaKey == 1} {
           set mylist(1n2_2_3) [list {1n2_2_3_1 "Concrete"} \
                                     {1n2_2_3_2 "Drucker-Prager"}\
                                     {1n2_2_3_3 "Drucker-Prager (Cap)"}\
                                     {1n2_2_3_4 "Failure Criteria"}]
        } else {
           set mylist(1n2_2_3) [list {1n2_2_3_1 "Concrete"}\
                                     {1n2_2_3_2 "Drucker-Prager"}\
                                     {1n2_2_3_4 "Failure Criteria"}]
        }

        set mylist(1n2_2_5) [list {1n2_2_5_1 "Plastic Poisson's Ratio"} \
                                  {1n2_2_5_2 "Uniaxial Compression"}\
                                  {1n2_2_5_3 "Uniaxial Tension"}]

        set mylist(1n2_3) [list {Visco_Fit "Prony Curve Fitting"} \
                                {EVIS  "Maxwell"}\
                                {1n2_3_2  "Prony"}]

        set mylist(1n2_3_2) [list {1n2_3_2_1 "Shear Response"} \
                                  {1n2_3_2_2 "Volumetric Response"}\
                                  {1n2_3_2_3 "Shift Function"}]

        set mylist(1n4) [list {1n4_1 "Mass Multiplier"} \
                              {1n4_2 "Stiffness Multiplier"} \
                              {1n4_3 "Frequency Independent"}]

        set mylist(3root) [list {3n1 "Conductivity"} \
                                {3n2 "Specific Heat"}\
                                {3n3 "Density"}\
                                {3n4 "Enthalpy"}\
                                {3n5 "Emissivity"}\
                                {3n6 "Convection or Film Coef."}\
                                {3n7 "Heat Generation Rate"}]

        set mylist(3n1) [list {3n1_1 "Isotropic"} \
                              {3n1_2 "Orthotropic"}]
        
        set mylist(4root) [list {4n1 "Relative Permeability"} \
                                {4n2 "BH Curve"}\
                                {4n3 "Coercive Force"}\
                                {4n4 "Relative Permittivity"}\
                                {4n5 "Resistivity"}\
                                {4n6 "Loss Tangent"} ]

        set mylist(4n1) [list {4n1_1 "Constant"} \
                              {4n1_2 "Orthotropic"}]

        set mylist(4n3) [list {4n3_1 "Constant"} \
                              {4n3_2 "Orthotropic"}]
     
        set mylist(4n4) [list {4n4_1 "Constant"} \
                              {4n4_2 "Orthotropic"}\
                              {4n4_3 "Anisotropic"}]
     
        set mylist(4n5) [list {4n5_1 "Constant"} \
                              {4n5_2 "Orthotropic"}]
     
        set mylist(5root) [list {5n1 "Density"} \
                                {5n2 "Sonic Velocity"}\
                                {5n3 "Boundary Admittance"}]

        set mylist(6root) [list {6n1 "Viscosity"} \
                                {6n2 "Water Table"}\
                                {6n3 "Pipe Flow Data"}]

        set mylist(6n3) [list {6n3_1 "Film Coefficient"} \
                              {6n3_2 "Fluid Conductance"}]

        set mylist(7root) [list {7n1 "Piezoelectric matrix"} ]

        set mylist(9root) [list {9n1 "Piezoresistive matrix"} ]

        set mylist(10root) [list {10n1 "Isotropic"} \
                                 {10n2 "Orthotropic"}]

        set mylist(11root) [list {11n1 "Diffusivity"} \
                                 {11n2 "Diffusion Expansion"}\
                                 {11n3 "Saturated Concentration"}]

        set mylist(11n1) [list {11n1_1 "Isotropic"} \
                               {11n1_2 "Orthotropic"}]
        
        set mylist(11n2) [list {11n2_1 "Isotropic"} \
                               {11n2_2 "Orthotropic"}]
        
        set mylist(8root) [list {8n1  "Linear"}\
                                {8n2  "Nonlinear"}\
                                {8n3  "Equation of State"}\
                                {8n4  "Discrete Element Properties"}\
                                {8n5  "Rigid Material"}]

        set mylist(8n1) [list {8n1_1  "Elastic"}]

        set mylist(8n1_1) [list {8n1_1_1  "Isotropic"}\
                              {8n1_1_2  "Orthotropic"}\
                              {8n1_1_3  "Anisotropic"}\
                              {8n1_1_4  "Fluid"}]
                            
        set mylist(8n2) [list {8n2_1  "Elastic"}\
                              {8n2_2  "Inelastic"}\
                              {8n2_3  "Foam Material Models"}]

        set mylist(8n2_1) [list {8n2_1_1  "Hyperelasticity"}\
                                {8n2_1_2  "Viscoelastic"}]

        set mylist(8n2_1_1) [list {8n2_1_1_1  "BLATZ-KO Rubber"}\
                              {8n2_1_1_2  "Mooney-Rivlin"}]

        set mylist(8n2_1_1_2) [list {8n2_1_1_2_1  "Direct Input"}\
                                    {8n2_1_1_2_2  "Test data calcs"}]

        set mylist(8n2_2) [list {8n2_2_1  "Isotropic Hardening"}\
                                {8n2_2_2  "Anisotropic Hardening"}\
                                {8n2_2_3  "Kinematic Hardening"}\
                                {8n2_2_4  "Barlat"}\
                                {8n2_2_5  "Rate Dependent Plasticity"}\
                                {8n2_2_6  "Damage"}\
                                {8n2_2_8  "Power Law"}\
                                {8n2_2_9  "Pressure Dependent"}\
                                {8n2_2_10 "Elastic Viscoplastic Thermal"}]

        set mylist(8n2_2_1) [list {8n2_2_1_1  "Bilinear Isotropic"}\
                                {8n2_2_1_2  "Temperature Dependent BISO"}]

        set mylist(8n2_2_2) [list {8n2_2_2_1  "Transverse Anisotropic"}\
                                {8n2_2_2_2  "Transverse Anisotropic FLD"}]

        set mylist(8n2_2_3) [list {8n2_2_3_1  "Bilinear Kinematic"}\
                                {8n2_2_3_2  "Plastic Kinematic"}]

        set mylist(8n2_2_4) [list {8n2_2_4_1  "3 Parameter Barlat"}\
                                {8n2_2_4_2  "Barlat Anisotropic"}]

        set mylist(8n2_2_5) [list {8n2_2_5_1  "Rate Sensitive"}\
                                {8n2_2_5_2  "Rate Dependent"}\
                                {8n2_2_5_3  "Piecewise Linear"}]

        set mylist(8n2_2_5_3) [list {8n2_2_5_3_1  "Standard"}\
                                {8n2_2_5_3_2  "Modified"}]

        set mylist(8n2_2_6) [list {8n2_2_6_1  "Composite"}\
                                {8n2_2_6_2  "Concrete"}]

        set mylist(8n2_2_9) [list {8n2_2_9_1  "Hydrodynamic"}\
                                {8n2_2_9_2  "Geological Cap"}]

        set mylist(8n2_3) [list {8n2_3_1  "Closed Cell"}\
                                {8n2_3_2  "Viscous"}\
                                {8n2_3_3  "Low Density"}\
                                {8n2_3_4  "Crushable"}\
                                {8n2_3_5  "Honeycomb"}]

        set mylist(8n3) [list {8n3_1  "Linear Polynomial"}\
                                {8n3_2  "Gruneisen"}\
                                {8n3_3  "Tabulated"}\
                                {8n3_4  "Bamman"}]

        set mylist(8n3_1) [list {8n3_1_1  "Johnson-Cook"}\
                                {8n3_1_2  "Null"}\
                                {8n3_1_3  "Zerilli-Armstrong"}\
                                {8n3_1_4  "Steinberg"}]

        set mylist(8n3_2) [list {8n3_2_1  "Johnson-Cook"}\
                                {8n3_2_2  "Null"}\
                                {8n3_2_3  "Zerilli-Armstrong"}\
                                {8n3_2_4  "Steinberg"}]

        set mylist(8n3_3) [list {8n3_3_1  "Johnson-Cook"}\
                                {8n3_3_2  "Null"}\
                                {8n3_3_3  "Zerilli-Armstrong"}\
                                {8n3_3_4  "Steinberg"}]

        set mylist(8n4) [list {8n4_1  "Spring"}\
                              {8n4_2  "Damper"}\
                              {8n4_3  "Cable"}]

        set mylist(8n4_1) [list {8n4_1_1  "Linear Elastic"}\
                                {8n4_1_2  "General Nonlinear"}\
                                {8n4_1_3  "Nonlinear Elastic"}\
                                {8n4_1_4  "Elastoplastic"}\
                                {8n4_1_5  "Inelastic"}\
                                {8n4_1_6  "Maxwell Viscosity"}]

        set mylist(8n4_2) [list {8n4_2_1  "Linear Viscosity"}\
                                {8n4_2_2  "Nonlinear Viscosity"}]

                            

        if {$node == "" } {
           set node root
        }
        if {[string match {} [array names mylist $node]]} {
           return ""
        }

        return $mylist($node)
     }
  
     proc favorites {} {

        variable favoritesList
        variable numFavorites

        if {![info exists numFavorites]} {
           set numFavorites 0
        }

        set numFavorites [expr $numFavorites + 1]

        if {![info exists favoritesList]} {
           set favoritesList(root) [ list ]
        }

        lappend favoritesList(root) {fav$numFavorites "sdfasdf"}

     }

}

# ============================================================================
# File Name:     table1.eui
# Description:   TB Dialog box for the following labels
#                NLIS,CHAB,USER,BISO,CREE(1-12 & 100),CONC,HILL,BKIN,RATE,ANEL,STAT,JOINT
#                All these tables are temperature dependent
#                Some of them (CHAB,USER,STAT) can also have a non-fixed number
#                 of rows (dim =2)
# ============================================================================

namespace eval ::euidl::material::mat1 {
   
   proc TABLE1 {label matid next} {

      variable ::euidl::material::ModelControl::matModelArr

      # For labels CHAB & USER the maximum of CELLS = 1000  
      variable CHABUSER 1000
      
      variable numcol
      variable numrow
      variable tbdata
      variable labelin
      variable tbopt
      variable colmax
      variable rowmax

      # colmax need a default
      set colmax 1000
      set rowmax 1000 
 
      set labelin $label

      set tboptcmd "    "
     
      variable parent1
      variable childsite
      variable tableName
      variable mat
      variable treeChildsite
      variable dim
      variable confirm
 
      set mat $matid
      set tbopt " "

      euidl::material::ModelControl::matTable_State 0

      if [winfo exists .dlgMatOpts] {
         # Set the display correctly
         $parent1 activate
         return
      }

      set parent1 [euidl::dialog .dlgMatOpts -class EUIDL \
            -master $matModelArr(parent) \
            ]

      set childsite [$parent1 component childsite]

      #SET WINDOW#

      wm minsize $parent1 650 350
    
  

      set tableName [euidl::table $childsite.tbl1 \
            -variable [scope tbdata] \
            -rowseparator \n \
            -colseparator \t \
            -validate focusout \
            -validatedata ansreal \
            
         ]

         
      
     

       # BUTTONS ADD & DELETE & GRAPH# 
   
      
      euidl::button $childsite.addaftc -text [msgcat::mc "Add Temperature"] \
            -command [code addcolumn ] 
      grid $childsite.addaftc -column 0 -row 3

      bind $childsite.addaftc <ButtonRelease-1> \
                  [code ::euidl::material::error::check %W]


      euidl::button $childsite.delcolumn -text [msgcat::mc "Delete Temperature"] \
            -command [code colselect ]
      grid $childsite.delcolumn -column 1 -row 3

      bind $childsite.delcolumn <ButtonRelease-1> \
                  [code ::euidl::material::error::check %W]

      euidl::button $childsite.addaftr -text [msgcat::mc "Add Row"] \
            -command [code addrow ]
      grid $childsite.addaftr -column 3 -row 3

      bind $childsite.addaftr <ButtonRelease-1> \
                  [code ::euidl::material::error::check %W]

      euidl::button $childsite.delrow -text [msgcat::mc "Delete Row"] \
            -command [code rowselect ]
      grid $childsite.delrow -column 4 -row 3

      bind $childsite.delrow <ButtonRelease-1> \
                  [code ::euidl::material::error::check %W]

      euidl::button $childsite.graph -text [msgcat::mc "Graph"] \
            -command [code graph]
      grid $childsite.graph -sticky e -column 6 -row 3

      bind $childsite.graph <ButtonRelease-1> \
                  [code ::euidl::material::error::check %W]

      grid columnconfigure $childsite 2 -minsize 50
      grid columnconfigure $childsite 5 -minsize 50
      grid columnconfigure $childsite 6 -weight 1

      $parent1 configure \
            -okcommand [code matOpts_Ok 0 $mat $next] \
            -cancelcommand [code matOpts_Cancel] \
            -helpcommand [list ans_loadhelp Hlp_UI_mat_dat]
      

      #COMMAND DESCRIPTION-HAVE TO CHANGE THE MESSAGE DEPENDING ON THE LABEL
      #1-set initial number of cols and rows as well as 
      #  colmax & rowmax depending on the label 
      #2-set dim =1 or 2 (dim = 1 : You can only add temperatures)
      #  (dim =2 : You can add temps & rows)
      #3-BKIN & RATE & ANEL & SHIFT  also have a combobox to define their TBOP
      #4- for CREEP the label passed in is CREE$tbop
      #  N-B CREE is treated in table5.eui

      switch -glob -- $labelin {
         NLIS {
             euidl::label $childsite.lbl$labelin -height 3 \
                  -anchor w \
                  -text [msgcat::mc "Nonlinear Isotropic Hardening \
                        for Material Number $mat"]
             wm title $parent1 [msgcat::mc "Nonlinear Isotropic\
                  Hardening for Material Number $mat"]
             set numcol 1
             set numrow 4
             set dim 1
             set tbdata(1,-1) "Sigy0"
             set tbdata(2,-1) "R0"
             set tbdata(3,-1) "Rinf"
             set tbdata(4,-1) "b"
             wm minsize $parent1 650 270
             $childsite.graph configure -state disabled

             $tableName config -colmax 20
             set colmax 20
             $childsite.addaftr configure -state disabled     
             $childsite.delrow configure  -state disabled
             $parent1 configure  -helpcommand [list ans_loadhelp Hlp_E_CH2nlis]
         }
         CHAB {
             euidl::label $childsite.lbl$labelin -height 3 \
                  -anchor w \
                  -text [msgcat::mc "Chaboche Kinematic Hardening \
                        for Material Number $mat"]
             wm title $parent1 [msgcat::mc "Chaboche Kinematic\
                  Hardening for Material Number $mat"]
             set numcol 1
             set numrow 3
             set dim 2
             set tbdata(1,-1) "C1"
             set tbdata(2,-1) "C2"
             set tbdata(3,-1) "C3"
             $childsite.graph configure  -state disabled
             $tableName config -rowmax 12
             set rowmax 11
             $parent1 configure  -helpcommand [list ans_loadhelp Hlp_E_CH2chab]
             
         }
         USER {
             euidl::label $childsite.lbl$labelin -height 3 \
                  -anchor w \
                  -text [msgcat::mc "User-Defined Table \
                        for Material Number $mat"]
             wm title $parent1 [msgcat::mc "User-Defined Table\
               for Material Number $mat"]
             set numcol 1
             set numrow 1
             set dim 2
             set tbdata(1,-1) "C1"
             $childsite.graph configure  -state disabled
             $parent1 configure  -helpcommand [list ans_loadhelp Hlp_E_CH2user]
         }
         STAT {
             euidl::label $childsite.lbl$labelin -height 3 \
                  -anchor w \
                  -text [msgcat::mc "State Variable Table \
                        for Material Number $mat"]
             wm title $parent1 [msgcat::mc "State Variable Table\
               for Material Number $mat"]
             set numcol 1
             set numrow 1
             set dim 2
             set tbdata(1,-1) "C1"
             $childsite.graph configure  -state disabled
             $parent1 configure  -helpcommand [list ans_loadhelp Hlp_E_CH2user]
         }
         BISO {
            euidl::label $childsite.lbl$labelin -height 3 \
                 -anchor w\
                 -text [msgcat::mc " Bilinear Isotropic Hardening\
                       for Material Number $mat"]
            wm title $parent1 [msgcat::mc " Bilinear Isotropic Hardening\
                       for Material Number $mat"]
            set tbdata(1,-1) "Yield Stss"
            set tbdata(2,-1) "Tang Mod"
            wm minsize $parent1 650 250
            set numcol 1
            set numrow 2
            set dim 1
            $tableName config -colmax 6
            set colmax 6
           
            $tableName config -rowmax 3

            $childsite.addaftr configure -state disabled     
            $childsite.delrow configure  -state disabled
            $parent1 configure  -helpcommand [list ans_loadhelp Hlp_E_CH2biso]
         }
         
         CREE* {
            #Depending on the value of TBOP, the CREEP table is different
            foreach num {1 2 3 4 5 6 7 8 9 10 11 12 13 100 } {
                if {$labelin == "CREE$num"} {
                     set tbopt $num
                     break
                }
            }                    
            set labelin CREE 
            switch -exact -- $tbopt {
                     1 {set numrow 4
                        set text "Strain Hardening (Primary)" }
                     2 {set numrow 4
                        set text "Time Hardening (Primary)"}
                     3 {set numrow 5
                        set text "Generalized Exponential (Primary)"}
                     4 {set numrow 8
                        set text "Generalized Graham (Primary)" }
                     5 {set numrow 7
                        set text "Generalized Blackburn (Primary)"}
                     6 {set numrow 4
                        set text "Modified Time Hardening (Primary)"}
                     7 {set numrow 4
                        set text "Modified Strain Hardening (Primary)"}
                     8 {set numrow 4
                        set text "Generalized Garofalo (Secondary)"}
                     9 {set numrow 3
                        set text "Exponential Form (Secondary)"}
                     10 {set numrow 3
                        set text "Norton (Secondary)"}
                     11 {set numrow 7
                        set text "Time Hardening (Primary+Secondary)"}
                     12 {set numrow 12
                        set text "Rational polynomial (Primary+Secondary)"}
                     13 {set numrow 6
                        set text "Generalized Time Hardening (Primary)"}
                     100 {set numrow 1
                        set text "User defined"}                           
            }
            euidl::label $childsite.lbl$labelin -height 3 \
                 -anchor w\
                 -text [msgcat::mc "CREEP Table for Material Number $mat - $text"]
            wm title $parent1 [msgcat::mc "Creep Table"]
            for {set i 1} {$i<=$numrow} {incr i 1} {
               set tbdata($i,-1) "C$i"
            }
            set numcol 1
            set dim 1
            $tableName config -rowmax [expr $numrow +1]

            $childsite.addaftr configure -state disabled     
            $childsite.delrow configure  -state disabled

            if {$tbopt == 100} {
                 set dim 2
                 $tableName config -rowmax 1000
                 $childsite.addaftr configure -state normal     
                 $childsite.delrow configure  -state normal
            } 
            $childsite.graph configure -state disabled
            $parent1 configure  -helpcommand [list ans_loadhelp Hlp_E_CH2crei]
         }
         GASK* {
            #Depending on the value of TBOP, the GASK table is different
            foreach num { PARA TSS } {
                if {$labelin == "GASK$num"} {
                     set tbopt $num
                     set tboptcmd $tbopt
                     break
                }
            }                    
            set labelin GASK 
            switch -exact -- $tbopt {
                     PARA {set numrow 3
                           set text "General Parameters"
                           set tbdata(1,-1) "Initial Gap"
                           set tbdata(2,-1) "Stable Stiff"
                           set tbdata(3,-1) "Stress Cap" }
                     TSS  {set numrow 2
                           set text "Transverse Shear"
                           set tbdata(1,-1) "TSS XY"
                           set tbdata(2,-1) "TSS XZ" }
            }
            euidl::label $childsite.lbl$labelin -height 3 \
                 -anchor w\
                 -text [msgcat::mc "GASKET Table for Material Number $mat - $text"]
            wm title $parent1 [msgcat::mc "Gasket Table"]
           set numcol 1
            set dim 1
            $tableName config -rowmax [expr $numrow +1]

            $childsite.addaftr configure -state disabled     
            $childsite.delrow configure  -state disabled

            $childsite.graph configure -state disabled
            $parent1 configure  -helpcommand [list ans_loadhelp Hlp_gask]
         }
         CAST* {
            #Depending on the value of TBOP, the CAST table is different
            foreach num { 1 2 } {
                if {$labelin == "CAST$num"} {
                     set tbopt $num
                     break
                }
            }                    
            set labelin CAST 
            switch -exact -- $tbopt {
                     1 {set numrow 1
                        set text "Cast-Iron with Isotropic Hardening" }
                     2 {set numrow 1
                        set text "Cast-Iron with Kinematic Hardening" }
            }
            euidl::label $childsite.lbl$labelin -height 3 \
                 -anchor w\
                 -text [msgcat::mc "CAST Table for Material Number $mat - $text"]
            wm title $parent1 [msgcat::mc "Cast-Iron Table"]
            for {set i 1} {$i<=$numrow} {incr i 1} {
               set tbdata($i,-1) "NUPL in Tension"
            }
            set numcol 1
            set dim 1
            $tableName config -rowmax [expr $numrow +1]

            $childsite.addaftr configure -state disabled     
            $childsite.delrow configure  -state disabled

            $childsite.graph configure -state disabled
            $parent1 configure  -helpcommand [list ans_loadhelp Hlp_cast]
         }
         PRONY* {
            #Depending on the value of TBOP, the PRONY table is different
            foreach num { SHEAR BULK } {
                if {$labelin == "PRONY$num"} {
                     set tbopt $num
                     set tboptcmd $tbopt
                     break
                }
            }
            set labelin PRONY
            switch -exact -- $tbopt {
                     SHEAR {set numrow 2
                        set text "Prony Viscoelastic Shear Response" }
                     BULK {set numrow 2
                        set text "Prony Viscoelastic Volumetric Response" }
            }
            euidl::label $childsite.lbl$labelin -height 3 \
                 -anchor w\
                 -text [msgcat::mc "PRONY Table for Material Number $mat - $text"]
            wm title $parent1 [msgcat::mc "Prony Table"]

            set tbdata(1,-1) "a1"
            set tbdata(2,-1) "t1"

            set numcol 1
            set dim 1
            $tableName config -rowmax 101
            $tableName config -colmax 100
            set rowmax 100

            $childsite.graph configure -state disabled
            $parent1 configure  -helpcommand [list ans_loadhelp Hlp_evis]
         }
         SHIFT {

            euidl::label $childsite.lbl$labelin -height 3 \
                 -anchor w\
                 -text [msgcat::mc "SHIFT Table for Material Number $mat"]
            wm title $parent1 [msgcat::mc "Shift Function"]
            euidl::label $childsite.lblopt$labelin -height 3 -anchor nw \
                    -text [msgcat::mc "Shift Function Options"]
            euidl::combobox  $childsite.cmb$labelin -width 20  \
                 -command [code shift_options] \
                 -variable [scope tbopt]
            $childsite.cmb$labelin insert list end\
                 [list {William-Landel,Ferry} 1\
                       {Tool-Narayanaswamy  } 2\
                       {User-defined} 100\
                 ]
            set tbopt 1      
            wm minsize $parent1 650 300
            set dim 1
            set numcol 1
            set numrow 3
            $tableName config -colmax 6
            set colmax 6
            $tableName config -rowmax 3

            set tbdata(1,-1) "Tref"
            set tbdata(2,-1) "C1"
            set tbdata(3,-1) "C2"

            set numcol 1
            set dim 1
            $tableName config -rowmax [expr $numrow +1]

            $childsite.addaftc configure -state disabled
            $childsite.delcolumn configure  -state disabled

            $childsite.addaftr configure -state disabled
            $childsite.delrow configure  -state disabled

            $childsite.graph configure -state disabled
            $parent1 configure  -helpcommand [list ans_loadhelp Hlp_evis]
         }
         HYPE* {
            
            #Depending on the value of TBOP, the HYPER table is different
            foreach num {mo2 mo3 mo5 mo9 og1 og2 og3 og4 og5 ogG \
                         po1 po2 po3 po4 po5 poG \
                         ye1 ye2 ye3 ye4 ye5 yeG \
                         fo1 fo2 fo3 fo4 fo5 foG \
                         3 4 5 6 7 8 9 10 11 100} {
                if {$labelin == "HYPE$num"} {
                     set tbopt $num
                     break
                }
            }                     
            set labelin HYPE 
            wm title $parent1 [msgcat::mc "Hyper-Elastic Table"]
            set listlab {C10 C01 C20 C11 C02 C30 C21 C12 C03 \
                      C40 C31 C22 C13 C04 C50 C41 C32 C23 C14 C05 }
            set i 0
            foreach lab $listlab {
               set i [expr $i +1]
               set arraylab($i) $lab
            }
            switch -glob -- $tbopt {
                     mo* {#MOONEY
                        foreach num {2 3 5 9} {
                           if {$tbopt == "mo$num"} {
                              set npts $num
                           }
                        }
                        euidl::label $childsite.lbl$labelin -height 3 \
                             -anchor w\
                             -text [msgcat::mc "Mooney-Rivlin Hyperelastic table\
                                       ($npts parameters) for Material Number $mat"]
                        set numrow [expr $npts +1]
                        for {set i 1} {$i <= $npts} {incr i 1} {
                            set tbdata($i,-1) $arraylab($i)
                        }
                        # Set the third entry of 3-parm Mooney to correct label.
                        # Other labels stay as they are. (lao  qt-6483)
                        if {$npts == 3} {
                           set tbdata(3,-1) "C11"
                        }
                        set tbdata($numrow,-1) "d"
                        
                        wm minsize $parent1 650 380
                        set tbopt "MOON"                 
                        set numcol 1
                        set dim 1
                        $tableName config -colmax 6
                        set colmax 6 
                        $tableName config -rowmax [expr $numrow +1]

                        $childsite.addaftr configure -state disabled     
                        $childsite.delrow configure  -state disabled
                        $parent1 configure  -helpcommand [list ans_loadhelp Hlp_E_CH2moon]                    
                     }
                    og* {#OGDEN
                        foreach num {1 2 3 4 5 G} {
                           if {$tbopt == "og$num"} {
                              set npts $num
                           }
                        }
                        if {$npts == "G"} {
                           euidl::label $childsite.lbl$labelin -height 3 \
                             -anchor w\
                             -text [msgcat::mc "Ogden Hyperelastic table\
                                       for Material Number $mat"]
                           set numrow 3
                           for {set i 1} {$i<=$numrow} {incr i 1} {
                              set tbdata($i,-1) "C$i"
                           }
                           wm minsize $parent1 650 300
                           set tbopt "OGDE"                 
                           set numcol 1
                           set dim 2
                           $tableName config -colmax 6
                           set colmax 6
                           $tableName config -rowmax 31
                           set rowmax 30
                        } else {
                           euidl::label $childsite.lbl$labelin -height 3 \
                             -anchor w\
                             -text [msgcat::mc "Ogden Hyperelastic table\
                                       ($npts terms) for Material Number $mat"]
                           set numrow [expr $npts *3]
                           for {set i 1} {$i <= $npts} {incr i 1} {
                              set j [expr $i *2]
                              set tbdata([expr $j -1],-1) "mu_$i"
                              set tbdata($j,-1) "a_$i"
                              set tbdata([expr $npts*2 + $i],-1) "d_$i"
                           }
                          
                           wm minsize $parent1 650 380
                           set tbopt "OGDE"                 
                           set numcol 1
                           set dim 1
                           $tableName config -colmax 6
                           set colmax 6 
                           $tableName config -rowmax [expr $numrow +1]

                           $childsite.addaftr configure -state disabled     
                           $childsite.delrow configure  -state disabled
                        }
                        $parent1 configure  -helpcommand [list ans_loadhelp Hlp_E_CH2ogde]
                        
                     }
                     ye* {#YEOH
                        foreach num {1 2 3 4 5 G} {
                           if {$tbopt == "ye$num"} {
                              set npts $num
                           }
                        }
                        if {$npts == "G"} {
                           euidl::label $childsite.lbl$labelin -height 3 \
                                -anchor w\
                                -text [msgcat::mc "Yeoh Hyperelastic table\
                                          for Material Number $mat"]
                           set numrow 2
                           for {set i 1} {$i<=$numrow} {incr i 1} {
                               set tbdata($i,-1) "C$i"
                           }
                           set tbopt "YEOH"                 
                           set numcol 1
                           set dim 2
                           $tableName config -colmax 6
                           set colmax 6
                           $tableName config -rowmax 21
                           set rowmax 20
                        } else {
                           euidl::label $childsite.lbl$labelin -height 3 \
                             -anchor w\
                             -text [msgcat::mc "Yeoh Hyperelastic table\
                                       (Order $npts) for Material Number $mat"]
                           set numrow [expr $npts *2]
                           for {set i 1} {$i <= $npts} {incr i 1} {
                              set tbdata($i,-1) "c_${i}0"
                              set tbdata([expr $npts + $i],-1) "d_$i"
                           }

                           wm minsize $parent1 650 380
                           set tbopt "YEOH"
                           set numcol 1
                           set dim 1
                           $tableName config -colmax 6
                           set colmax 6
                           $tableName config -rowmax [expr $numrow +1]

                           $childsite.addaftr configure -state disabled
                           $childsite.delrow configure  -state disabled
                        }
                        $parent1 configure  -helpcommand [list ans_loadhelp Hlp_yeoh]
                       
                     }
                     4 {#GENT
                        euidl::label $childsite.lbl$labelin -height 3 \
                             -anchor w\
                             -text [msgcat::mc "Gent Hyperelastic table\
                                       for Material Number $mat"]
                        set numrow 3
                        #for {set i 1} {$i<=$numrow} {incr i 1} {
                        #    set tbdata($i,-1) "C$i"
                        #}
                        set tbdata(1,-1) "mu"
                        set tbdata(2,-1) "Jm"
                        set tbdata(3,-1) "d"

                        set tbopt "GENT"                 
                        set numcol 1
                        set dim 1
                        $tableName config -colmax 6
                        set colmax 6
                        $childsite.addaftr configure -state disabled     
                        $childsite.delrow configure  -state disabled
                        $parent1 configure  -helpcommand [list ans_loadhelp Hlp_gent]
                        
                     }
                     5 {#NEO
                        euidl::label $childsite.lbl$labelin -height 3 \
                             -anchor w\
                             -text [msgcat::mc "Neo-Hookean Hyperelastic table\
                                       for Material Number $mat"]
                        set numrow 2
                        #$tableName width -1 20
                        wm minsize $parent1 650 300
                        set tbdata(1,-1) "mu"
                        set tbdata(2,-1) "d"
                        set tbopt "NEO"
                        set numcol 1
                        set dim 1
                        $tableName config -colmax 6
                        set colmax 6
                        $childsite.addaftr configure -state disabled     
                        $childsite.delrow configure  -state disabled
                        $parent1 configure  -helpcommand [list ans_loadhelp Hlp_E_CH2neo]
                        
                     }
                     po* {#POLY
                        foreach num {1 2 3 4 5 G} {
                           if {$tbopt == "po$num"} {
                              set npts $num
                           }
                        }
                        if {$npts == "G"} {
                           euidl::label $childsite.lbl$labelin -height 3 \
                             -anchor w\
                             -text [msgcat::mc "Polynomial form Hyperelastic table\
                                       for Material Number $mat"]
                           set numrow 3
                           for {set i 1} {$i<=$numrow} {incr i 1} {
                              set tbdata($i,-1) "C$i"
                           }
                           wm minsize $parent1 650 300
                           set tbopt "POLY"                 
                           set numcol 1
                           set dim 2
                        } else {
                           euidl::label $childsite.lbl$labelin -height 3 \
                             -anchor w\
                             -text [msgcat::mc "Polynomial form Hyperelastic table\
                                       ($npts terms) for Material Number $mat"]
                           set toto [expr (($npts+1)*($npts+2))/2 -1]
                           set numrow [expr $toto + $npts ]
                           for {set i 1} {$i <= $toto} {incr i 1} {
                              set tbdata($i,-1) $arraylab($i)
                           }
                           for {set i 1} {$i <= $npts} {incr i 1} {
                              set tbdata([expr $toto +$i],-1) "d_$i"
                           }                          
                           wm minsize $parent1 650 380
                           set tbopt "POLY"                 
                           set numcol 1
                           set dim 1

                           $childsite.addaftr configure -state disabled     
                           $childsite.delrow configure  -state disabled
                        }
                        $parent1 configure  -helpcommand [list ans_loadhelp Hlp_E_CH2poly]
                        
                     }
                     7 {}
                     8 {#BOYCE 
                        euidl::label $childsite.lbl$labelin -height 3 \
                             -anchor w\
                             -text [msgcat::mc "Arruda-Boyce Hyperelastic table\
                                       for Material Number $mat"]
                        set numrow 3
                        set tbdata(1,-1) "mu"
                        set tbdata(2,-1) "lambda L"
                        set tbdata(3,-1) "d"
                        wm minsize $parent1 650 300
                        set tbopt "BOYC"
                        set numcol 1
                        set dim 1
                        $tableName config -colmax 6
                        set colmax 6
                        $childsite.addaftr configure -state disabled     
                        $childsite.delrow configure  -state disabled
                        $parent1 configure  -helpcommand [list ans_loadhelp Hlp_E_CH2boyc]
                       
                     }
                     9 {}
                     10 {#BLAT 
                         euidl::label $childsite.lbl$labelin -height 3 \
                             -anchor w\
                             -text [msgcat::mc "Blatz-Ko Hyperelastic table\
                                       for Material Number $mat"]
                        set numrow 1
                        #for {set i 1} {$i<=$numrow} {incr i 1} {
                        #    set tbdata($i,-1) "C$i"
                        #}
                        set tbdata(1,-1) "mu"
                        set tbopt "BLAT"
                        set numcol 1
                        set dim 1
                        $tableName config -colmax 6
                        set colmax 6
                        $childsite.addaftr configure -state disabled     
                        $childsite.delrow configure  -state disabled
                        $parent1 configure  -helpcommand [list ans_loadhelp Hlp_blat]
                        
                     }
                     fo* {#FOAM
                        foreach num {1 2 3 4 5 G} {
                           if {$tbopt == "fo$num"} {
                              set npts $num
                           }
                        }
                        if {$npts == "G"} {
                           euidl::label $childsite.lbl$labelin -height 3 \
                                -anchor w\
                                -text [msgcat::mc "Hyper-Foam Table \
                                          for Material Number $mat"]
                           set numrow 3
                           for {set i 1} {$i<=$numrow} {incr i 1} {
                               set tbdata($i,-1) "C$i"
                           }
                           set tbopt "FOAM"                 
                           set numcol 1
                           set dim 2
                           $tableName config -colmax 6
                           set colmax 6
                           $tableName config -rowmax 21
                           set rowmax 20
                        } else {
                           euidl::label $childsite.lbl$labelin -height 3 \
                             -anchor w\
                             -text [msgcat::mc "Hyper-Foam table\
                                       ($npts terms) for Material Number $mat"]
                           set numrow [expr $npts *3]
                           for {set i 1} {$i <= $npts} {incr i 1} {
                              set j [expr $i *2]
                              set tbdata([expr $j -1],-1) "mu_$i"
                              set tbdata($j,-1) "a_$i"
                              set tbdata([expr $npts*2 + $i],-1) "b_$i"
                           }

                           wm minsize $parent1 650 380
                           set tbopt "FOAM"
                           set numcol 1
                           set dim 1
                           $tableName config -colmax 6
                           set colmax 6
                           $tableName config -rowmax [expr $numrow +1]

                           $childsite.addaftr configure -state disabled
                           $childsite.delrow configure  -state disabled
                        }
                        $parent1 configure  -helpcommand [list ans_loadhelp Hlp_ogfo]
                        
                     }
                     100 {#USER 
                        euidl::label $childsite.lbl$labelin -height 3 \
                             -anchor w\
                             -text [msgcat::mc "User Hyperelastic table\
                                       for Material Number $mat"]
                        set numrow 1
                        for {set i 1} {$i<=$numrow} {incr i 1} {
                            set tbdata($i,-1) "C$i"
                        }
                        set tbopt "USER"                 
                        set numcol 1
                        set dim 2
                        $parent1 configure  -helpcommand [list ans_loadhelp Hlp_E_CH2useh]
                       
                     }                           
            }
                      
            $childsite.graph configure -state disabled
         }
         MOON {
            euidl::label $childsite.lbl$labelin -height 3 \
                 -anchor w\
                 -text [msgcat::mc "Mooney-Rivlin Hyper-Elastic table\
                       for Material Number $mat"]
            wm title $parent1 [msgcat::mc "Mooney-Rivlin Hyper-Elastic table\
                       for Material Number $mat"]
            set tbdata(1,-1) "C1"
            set tbdata(2,-1) "C2"
            set tbdata(3,-1) "C3"
            set tbdata(4,-1) "C4"
            set tbdata(5,-1) "C5"
            set tbdata(6,-1) "C6"
            set tbdata(7,-1) "C7"
            set tbdata(8,-1) "C8"
            set tbdata(9,-1) "C9"
            wm minsize $parent1 650 370
            set numcol 1
            set numrow 9
            set dim 1
            $tableName config -colmax 6
            set colmax 6
            $tableName config -rowmax 10
            $childsite.graph configure -state disabled
            $childsite.addaftr configure -state disabled     
            $childsite.delrow configure  -state disabled
            $parent1 configure  -helpcommand [list ans_loadhelp Hlp_E_CH2moonhy]
         }
         CONC {
            euidl::label $childsite.lbl$labelin -height 3 \
                 -anchor w\
                 -text [msgcat::mc "Concrete \
                       for Material Number $mat"]
            wm title $parent1 [msgcat::mc " Concrete \
                       for Material Number $mat"]
            set tbdata(1,-1) "Open Shear Transfer Coef"
            set tbdata(2,-1) "Closed Shear Transfer Coef"
            set tbdata(3,-1) "Uniaxial Cracking Stress"
            set tbdata(4,-1) "Uniaxial Crushing Stress"
            set tbdata(5,-1) "Biaxial Crushing Stress"
            set tbdata(6,-1) "Hydrostatic Pressure"
            set tbdata(7,-1) "Hydro Biax Crush Stress"
            set tbdata(8,-1) "Hydro Uniax Crush Stress"
            set tbdata(9,-1) "Tensile Crack Factor"
            wm minsize $parent1 650 370
            set numcol 1
            set numrow 9
            set dim 1
            $tableName config -colmax 6
            set colmax 6
            $tableName config -rowmax 10
            $tableName width -1 26
            $childsite.graph configure -state disabled
            $childsite.addaftr configure -state disabled     
            $childsite.delrow configure  -state disabled
            $parent1 configure  -helpcommand [list ans_loadhelp Hlp_E_65conc]

         }
         HILL {
            euidl::label $childsite.lbl$labelin -height 3 \
                 -anchor w\
                 -text [msgcat::mc "Hill's Table \
                       for Material Number $mat"]
            wm title $parent1 [msgcat::mc "  Hill's Table \
                       for Material Number $mat"]
            set tbdata(1,-1) "rxx"
            set tbdata(2,-1) "ryy"
            set tbdata(3,-1) "rzz"
            set tbdata(4,-1) "rxy"
            set tbdata(5,-1) "ryz"
            set tbdata(6,-1) "rxz"
           
            wm minsize $parent1 650 320
            set numcol 1
            set numrow 6
            set dim 1
            $tableName config -colmax 40 
            set colmax 40 
            $tableName config -rowmax 7
            $childsite.graph configure -state disabled
            $childsite.addaftr configure -state disabled     
            $childsite.delrow configure  -state disabled
            $parent1 configure  -helpcommand [list ans_loadhelp Hlp_E_CH2hill]
         }
         BKIN {
            
            euidl::label $childsite.lbl$labelin -height 3 -anchor w\
                   -text [msgcat::mc "Bilinear Kinematic Hardening\
                      for Material Number $mat"]

            wm title $parent1 [msgcat::mc " Bilinear Kinematic Hardening\
                          for Material Number $mat"]
            euidl::label $childsite.lblopt$labelin -height 3 -anchor nw \
                    -text [msgcat::mc "Stress-Strain Options"]
            euidl::combobox  $childsite.cmb$labelin -width 20  \
                 -variable [scope tbopt]
            $childsite.cmb$labelin insert list end\
                 [list {Rice's Hard. Rule} 1\
                       {No stress relaxation} 0\
                 ]
            set tbopt 1      
            set tbdata(1,-1) "Yield Stss"
            set tbdata(2,-1) "Tang Mods"
            wm minsize $parent1 650 300
            set dim 1
            set numcol 1
            set numrow 2
            $tableName config -colmax 6
            set colmax 6
            $tableName config -rowmax 3

            $childsite.addaftr configure  -state disabled     
            $childsite.delrow configure -state disabled
            $parent1 configure  -helpcommand [list ans_loadhelp Hlp_E_CH2bkin]
         }
         RATE {
            
            euidl::label $childsite.lbl$labelin -height 3 -anchor w\
                   -text [msgcat::mc "Rate-dependent visco-plasticity \
                      for Material Number $mat"]

            wm title $parent1 [msgcat::mc "  Rate-dependent visco-plasticity \
                          for Material Number $mat"]
            euidl::label $childsite.lblopt$labelin -height 3 -anchor nw \
                    -text [msgcat::mc "Visco-Plasticity Options"]
            euidl::combobox  $childsite.cmb$labelin -width 20  \
                 -command [code rate_options] \
                 -variable [scope tbopt]
            $childsite.cmb$labelin insert list end\
                 [list {Perzyna Model} 1\
                       {Peirce Model} 2\
                       {Chaboche Model} 5\
                       {Anand Model} 9\
                 ]
            set tbopt 1      
            set tbdata(1,-1) "m"
            set tbdata(2,-1) "Gamma"
            set tbdata(3,-1) "C3"
            set tbdata(4,-1) "C4"
            set tbdata(5,-1) "C5"
            set tbdata(6,-1) "C6"
            set tbdata(7,-1) "C7"
            set tbdata(8,-1) "C8"
            set tbdata(9,-1) "C9"
             wm minsize $parent1 650 300
            set dim 1
            set numcol 1
            set numrow 9
            $tableName config -colmax 6
            set colmax 6
            $tableName config -rowmax 10

            $childsite.addaftr configure  -state disabled     
            $childsite.delrow configure -state disabled
            $childsite.graph configure -state disabled 
            $parent1 configure  -helpcommand [list ans_loadhelp Hlp_E_CH2rate]
         }
         ANEL {
             euidl::label $childsite.lbl$labelin -height 3 -anchor w\
                      -text [msgcat::mc "Anisotropic Elasticity \
                           for Material Number $mat"]
             wm title $parent1 [msgcat::mc "  Anisotropic Elasticity \
                          for Material Number $mat"]
             euidl::label $childsite.lblopt$labelin -height 3 -anchor nw \
                    -text [msgcat::mc "Anisotropic Elastic Matrix Options"]
             euidl::combobox  $childsite.cmb$labelin -width 20  \
                 -variable [scope tbopt]
             $childsite.cmb$labelin insert list end\
                 [list {Stiffness form} 0\
                       {Flexibility form} 1\
                 ]
             set tbopt 0
             set n 0 
             set toto 0
             for {set i 1} {$i<=6} {incr i 1} {
                 set toto [expr $toto +1]
                 for {set j $toto} {$j<=6} {incr j 1} {
                     set n [expr $n +1]
                     set tbdata($n,-1) "D[expr $j + $i*10]"
                 }                     
             }
             set dim 1     
             set numcol 1
             set numrow 21
             $tableName config -colmax 6
             set colmax 6
             $tableName config -rowmax 22 

             $childsite.graph configure -state disabled 
             $childsite.addaftr configure  -state disabled     
             $childsite.delrow configure -state disabled
             $parent1 configure  -helpcommand [list ans_loadhelp Hlp_E_CH2anel]
         }
         JOIN* {
            #Depending on the value of TBOP, the JOINT table is different
            foreach num { STIF DAMP FRIC } {
                if {$labelin == "JOINT$num"} {
                     set tbopt $num
                     set tboptcmd $tbopt
                     break
                }
            }
            set labelin JOINT

            switch -exact -- $tbopt {
                 STIF {
                     euidl::label $childsite.lbl$labelin -height 3 -anchor w\
                              -text [msgcat::mc "Joint Linear Stiffness \
                                   for Material Number $mat"]
                     wm title $parent1 [msgcat::mc "  Joint Linear Stiffness \
                                  for Material Number $mat"]
                      }
                 DAMP {
                     euidl::label $childsite.lbl$labelin -height 3 -anchor w\
                              -text [msgcat::mc "Joint Linear Damping \
                                   for Material Number $mat"]
                     wm title $parent1 [msgcat::mc "  Joint Linear Damping \
                                  for Material Number $mat"]
                      }
                 FRIC {
                     euidl::label $childsite.lbl$labelin -height 3 -anchor w\
                              -text [msgcat::mc "Joint Friction Stick Stiffness \
                                   for Material Number $mat"]
                     wm title $parent1 [msgcat::mc "  Joint Friction Stick Stiffness \
                                  for Material Number $mat"]
                      }
            }
            set n 0
            set toto 0
            for {set i 1} {$i<=6} {incr i 1} {
                set toto [expr $toto +1]
                for {set j $toto} {$j<=6} {incr j 1} {
                    set n [expr $n +1]
                    set tbdata($n,-1) "D[expr $j + $i*10]"
                }
            }
            set dim 1
            set numcol 1
            set numrow 21
            $tableName config -colmax 6
            set colmax 6
            $tableName config -rowmax 22

            $childsite.graph configure -state disabled
            $childsite.addaftr configure  -state disabled
            $childsite.delrow configure -state disabled
            $parent1 configure -helpcommand [list ans_loadhelp Hlp_E_CH2jointma]
         }
         SMA {
            euidl::label $childsite.lbl$labelin -height 3 \
                 -anchor w\
                 -text [msgcat::mc "Shape Memory Alloy \
                       for Material Number $mat"]
            wm title $parent1 [msgcat::mc "  Shape Memory Alloy \
                       for Material Number $mat"]
            set tbdata(1,-1) "SIG-SAS"
            set tbdata(2,-1) "SIG-FAS"
            set tbdata(3,-1) "SIG-SSA"
            set tbdata(4,-1) "SIG-FSA"
            set tbdata(5,-1) "EPSILON"
            set tbdata(6,-1) "ALPHA"

            wm minsize $parent1 650 320
            set numcol 1
            set numrow 6
            $tableName config -rowmax 7
            # BETA keyword for ymrt option
            set betaKey [ans_getvalue active,,keyw,,beta]
            if {$betaKey == 1} {
               set tbdata(7,-1) "YMRT"
               set numrow 7
               $tableName config -rowmax 8
            }
            set dim 1
            $tableName config -colmax 40
            set colmax 40
            $childsite.graph configure -state disabled
            $childsite.addaftr configure -state disabled
            $childsite.delrow configure  -state disabled
            $parent1 configure  -helpcommand [list ans_loadhelp Hlp_E_CH2sma]
         }
      }

      grid $childsite.lbl$labelin -sticky new -column 0 -row 0 \
            -columnspan 7
      if {$labelin == "BKIN" || $labelin == "RATE" || $labelin == "ANEL" \
          || $labelin == "SHIFT"} {
          grid $childsite.lblopt$labelin -sticky nw -column 0 -row 1 \
            -columnspan 3
          grid $childsite.cmb$labelin -sticky nw -column 4  -row 1 \
            -columnspan 2
      }

     # FILL THE TABLE WITH EXISTING DATA IF TABLE EXISTS
      
      set tb 0
      set tb [ans_getvalue $labelin,$mat,EXIS,,,,$tboptcmd]
      if {$tb == 1} {

          #HYPER CASE - CHECK TBOPT#
          if {$labelin == "HYPE" } {
             set tbchk  [ans_getvalue $labelin,$mat,TBOP]
             if {$tbchk == 7} {set tbchk 8}
             array set hyplabs {
                              MOON      1
                              OGDE      2
                              YEOH      3
                              GENT      4
                              NEO       5
                              POLY      6
                              BOYC      8
                              BLAT      10
                              FOAM      11
                              USER      100
                         }
             foreach { lab tbo} [ array get hyplabs] {
                  if {$tbchk == $tbo} {
                      set tbchk $lab
                  }
             }               
             if {$tbchk == $tbopt} {
                 switch -exact -- $tbopt {
                       MOON {
                            set tvalue [ans_getvalue HYPE,$matid,TVAL,1]
                            set npar [expr int([ans_getvalue \
                                     HYPE,$matid,TEMP,$tvalue,NCON])]
                            set nro 3
                            if {$npar > 3 } {
                               set nro 4
                            } 
                            if {$npar > 4} {
                               set nro 6
                            } 
                            if {$npar > 7} { 
                               set nro 10 
                            } 
                            if {$nro == $numrow} {
                                filltable
                            } else {
                                initable
                                warning hyper
                            }
                       }
                       OGDE {
                            set tvalue [ans_getvalue HYPE,$matid,TVAL,1]
                            set npar [expr int([ans_getvalue \
                                     HYPE,$matid,TEMP,$tvalue,NCON])]
                            if {$npar <= 15 && $npar == $numrow} {
                                  filltable
                            } elseif {$npar > 15} {
                                  filltable
                            } else {
                                  initable
                                  warning hyper
                            }
                            
                       }
                       YEOH {
                            set tvalue [ans_getvalue HYPE,$matid,TVAL,1]
                            set npar [expr int([ans_getvalue \
                                     HYPE,$matid,TEMP,$tvalue,NCON])]
                            if {$npar <= 10 && $npar == $numrow} {
                                  filltable
                            } elseif {$npar > 10} {
                                  filltable
                            } else {
                                  initable
                                  warning hyper
                            }
                            
                       }
                       FOAM {
                            set tvalue [ans_getvalue HYPE,$matid,TVAL,1]
                            set npar [expr int([ans_getvalue \
                                     HYPE,$matid,TEMP,$tvalue,NCON])]
                            if {$npar <= 15 && $npar == $numrow} {
                                  filltable
                            } elseif {$npar > 15} {
                                  filltable
                            } else {
                                  initable
                                  warning hyper
                            }
                            
                       }
                       POLY {
                            set tvalue [ans_getvalue HYPE,$matid,TVAL,1]
                            set npar [expr int([ans_getvalue \
                                     HYPE,$matid,TEMP,$tvalue,NCON])]
                            if {$npar <= 25 && $npar == $numrow} {
                                  filltable
                            } elseif {$npar > 25} {
                                  filltable
                            } else {
                                  initable
                                  warning hyper 
                            }
                       }
                       default { filltable }
                }
             } else {
                  initable
                  warning hyper
             }
          } elseif {$labelin == "CREE"} {
             set tbchk  [ans_getvalue $labelin,$mat,TBOP]           
             if {$tbchk == $tbopt} { 
                   filltable 
             } else {
                 initable
                 warning creep
             }
          } else {
             filltable
          } 

      #if table does not exist, set the default
      } else {         
          initable 
      }
      if {$labelin == "RATE"} {
          rate_options
      }

      grid $tableName -sticky news -column 0 -row 2 -columnspan 8
      grid rowconfigure $childsite 2 -weight 1

      # Set the max view height for the table
      grid rowconfigure $childsite 2 -minsize 50

     #BINDINGS

#     bind Entry <Control-KeyPress-t> [code delcolumn  $high $entf $lblcolf \
#             $labelin %W]
#     bind Entry <Control-KeyPress-r> [code delrow  $high $entf $lblrowf \
#             $labelin %W]

#      $parent1 configure \
#            -okcommand [code matOpts_Ok 0 $mat $next] \
#            -cancelcommand [code matOpts_Cancel] \
#            -helpcommand [list ans_loadhelp Hlp_UI_mat_dat]

#      bind $parent1.buttonBox.ok <ButtonPress-1> "+focus %W"

#     $tableName config -maxwidth [expr [winfo width $tableName ] - 15]

      update idletasks
      wm minsize $parent1 [winfo reqwidth $parent1] \
                          [expr [winfo reqheight $parent1] + 60]
     
      grid propagate $childsite 0
      
      
      #$parent1 activate
    
      set treeChildsite $childsite
      
      $tableName selection set 1,0
      $tableName activate 1,0
      $tableName selection anchor 1,0
      $tableName see active
  
 #    bind $tableName <Return> { break }
 #    uidl::registerWindow $parent1 
   
      if [winfo exists .conf] {
         $confirm activate
         raise $confirm
      } else {
        $parent1 activate
      }
   }

   proc warning {which} {
      variable ::euidl::material::ModelControl::matModelArr
 
   
      variable confirm

       
      if {$which == "creep"} {
          set text "A Creep model has already been defined\n\
                   for this material model number.        \n\
                    Do you want to overwrite it?"
      } elseif {$which == "hyper"} {
           set text "An Hyperelastic model has already been defined\n\
                     for this material model number.             \n\
                      Do you want to overwrite it?"
      }
      


      set confirm [::euidl::dialog .conf -class EUIDL \
             -master $matModelArr(parent) \
             -okbutton 0 -helpbutton 0 -cancelbutton 0 ]

     
      set childsi [$confirm component childsite]
      wm title $confirm [msgcat::mc "Warning"]
  
      euidl::label $childsi.lbl -text [msgcat::mc $text] 
      grid $childsi.lbl -row 0 -column 0 -columnspan 2
      euidl::button $childsi.yes -height 1 -text [msgcat::mc "Yes"] \
                       -command [code updatechoice 1]
      grid $childsi.yes -row 1 -column 0 
      euidl::button $childsi.no -height 1 -text [msgcat::mc "No"] \
            -command [code updatechoice 0]
      grid $childsi.no -row 1 -column 1
     
    
      update idletasks
    
     

    
   }

   proc updatechoice {val} {
      
       variable confirm
       variable parent1
       
       
       if {$val == 1} {
           destroy $confirm
           $parent1 activate
       } elseif { $val == 0 } {
           destroy $confirm
           destroy $parent1
           euidl::material::ModelControl::matTable_State 1
       }
       
   }
      
   proc initable {} {

       variable tbdata
       variable tableName
       variable numcol
       variable numrow

       set tbdata(-1,0) T1
       set tbdata(0,-1) Temperature
       $tableName configure -rows [expr $numrow +2] -cols  [expr $numcol +1]
       $tableName tag cell disabledtitle 0,-1
       $tableName tag cell disabled 0,0
   }

   proc filltable {} {

          variable labelin
          variable mat
          variable tbdata
          variable tableName
          variable numcol
          variable numrow
          variable tbopt
          variable dim

          set tboptcmd "    "
          switch -glob -- $labelin {
             PRONY* {
                 set tboptcmd $tbopt
             }
             GASK* {
                 set tboptcmd $tbopt
             }
             JOINT* {
                 set tboptcmd $tbopt
             }
          }

          set tbdata(0,-1) Temperature
          set numcol [expr int([ans_getvalue $labelin,$mat,NTEMP,,,,$tboptcmd])]
          # Get the values of each temperature TVAL
          for {set i 1} {$i<=$numcol} {incr i 1} {
             set tbdata(-1,[expr $i - 1]) "T$i"
             set tbdata(0,[expr $i - 1]) [ans_getvalue $labelin,$mat,TVAL,$i,,,$tboptcmd]
          }

          #If more than one temp, check if some temp are identical 
          #That's what would happen if for example tb,bkin is issued
          if {$numcol >1} {
              #Create a list
              for {set i 0} {$i<$numcol} {incr i 1} {
                  lappend Templis $tbdata(0,$i)
              }
              set Tempsort [lsort -real -unique $Templis]
              set length [llength $Tempsort]
              if {$length < $numcol} {
                  set numcol $length
              }
          }

          # If the table is 2D, get the number of rows
          if {$dim == 2} {
             set numrow [expr int([ans_getvalue $labelin,$mat,TEMP,$tbdata(0,0),NCONST,,$tboptcmd])]
             for {set j 1} {$j<=$numrow} {incr j 1} {
                  set tbdata($j,-1) "C$j"
             }
          } elseif {$labelin == "PRONY"} {
             set numrow [expr int([ans_getvalue $labelin,$mat,TEMP,$tbdata(0,0),NCONST,,$tboptcmd])]
             set numpt [expr $numrow/2 + 1]

             for {set j 1} {$j<=$numpt} {incr j 1} {
                  set tbdata([expr 2*$j-1],-1) "a$j"
                  set tbdata([expr 2*$j],-1) "t$j"
             }
          } 

          # Get the value of TBOPT if necessary
          if {$labelin == "BKIN" || $labelin == "RATE"|| $labelin == "ANEL" || \
              $labelin == "SHIFT"} {
              set tbopt  [ans_getvalue $labelin,$mat,TBOP]
          }
          if {$labelin == "SHIFT" && $tbopt > 1} {
             set numrow 2
          }

          # Loop through data for each temperature
          for {set i 1} {$i<=$numcol} {incr i 1} {
              for {set j 1} {$j<=$numrow} {incr j 1} {
                 catch {set tbdata($j,[expr $i - 1]) \
                     [ans_getvalue $labelin,$mat,TEMP,$tbdata(0,[expr $i - 1]),CONST,$j,$tboptcmd] }
                     catch {set tbdata($j,[expr $i - 1]) \
                         [format "%-12.5G" $tbdata($j,[expr $i - 1])] }
                     catch {set tbdata($j,[expr $i - 1]) [string trimright $tbdata($j,[expr $i - 1])] }
              }
          }
          # now format temperature data
          for {set i 1} {$i<=$numcol} {incr i 1} {
             set tbdata(0,[expr $i - 1]) [format "%-12.5G" $tbdata(0,[expr $i - 1])]
             set tbdata(0,[expr $i - 1]) [string trimright $tbdata(0,[expr $i - 1])]
          }

          if {$labelin == "SHIFT"} {
             set numrow 3
          }
          # Configure the tktable and disable temp cells if only one defined
          $tableName configure -rows [expr int($numrow) + 2] -cols [expr int($numcol) + 1]
          if {$numcol > 1} {
            $tableName tag cell normaltitle 0,-1
            $tableName tag cell normal 0,0
          } else {
            $tableName tag cell disabledtitle 0,-1
            $tableName tag cell disabled 0,0
          }
          if {$labelin == "SHIFT"} {
             shift_options
          }
          if {$labelin == "RATE"} {
             rate_options
          }
  
   }

   #ADD A COLUMN TO THE TABLE# 
   proc addcolumn {} {
        
        variable tableName
        variable tbdata
        variable labelin
        variable numrow
        variable numcol
        variable tbopt
        variable CHABUSER
        variable treeChildsite
        variable colmax
        variable parent1
        
        if { $labelin == "CHAB" || $labelin == "USER" || \
             $labelin == "CREE" || $labelin == "STAT" || \
             $tbopt == "POLY"} {
            # The number of cells cannot exceed 1000
            if { [expr $numrow * ($numcol+1)] > $CHABUSER } {
               tk_messageBox -icon warning \
                  -title [msgcat::mc "Maximum Data Points"] \
                  -parent $parent1 \
                  -type ok \
                  -message [msgcat::mc " This table\
                        allows only 1000 data points."]
               return
            } 
        }

        if {$numcol >= $colmax} {
             tk_messageBox -icon warning \
                  -title [msgcat::mc "Maximum Number of columns"] \
                  -parent $parent1 \
                  -type ok \
                  -message [msgcat::mc " This table\
                        allows only $colmax temperatures."]
        } else {
        incr numcol

        $tableName tag cell normaltitle 0,-1
        $tableName tag cell normal 0,0

        
        # Insert a column after the currently selected one
        if {[catch {$tableName index active col} curColumn]} {
           set curColumn 0
        }
        $tableName insert col -keeptitles -- $curColumn 1

        # Move the view to see added column
        $tableName xview scroll 1 unit

        # Label this new column
        set tbdata(-1,[expr $numcol - 1]) "T$numcol"

        if {$labelin == "RATE"} {
           rate_options
        }
        update
        $tableName selection activate 1,[expr $curColumn +1]
        $tableName see active
        }
   }

  
   #ADD A ROW IN THE TABLE#
     
   proc addrow {} {
        
        variable parent1
        variable tableName
        variable tbdata
        variable labelin
        variable numrow
        variable numcol
        variable tbopt
        variable CHABUSER
        variable treeChildsite
        variable rowmax

         if { $labelin == "CHAB" || $labelin == "USER" || \
             $labelin == "CREE" || $labelin == "STAT" || \
             $tbopt == "POLY"} {
 
            # The number of cells cannot exceed 1000
            if { [expr $numrow * ($numcol+1)] > $CHABUSER } {
               tk_messageBox -icon warning \
                  -title [msgcat::mc "Maximum Data Points"] \
                  -parent $parent1 \
                  -type ok \
                  -message [msgcat::mc " This Table\
                        allows only 1000 data points."]
               return
            } 
        }

        if {$numrow >= $rowmax} {
             tk_messageBox -icon warning \
                  -title [msgcat::mc "Maximum Number of rows"] \
                  -parent $parent1 \
                  -type ok \
                  -message [msgcat::mc " This table\
                        allows only $rowmax rows."]
        } else {
           if { $labelin == "PRONY" } {
              # Insert a row after the currently selected one
              if {[catch {$tableName index active row} curRow]} {
                 set curRow 1
              }

              if {$curRow == 1 || $curRow == 3 || $curRow == 5 || $curRow == 7} {
                 set curRow [expr $curRow + 1]
              }
              set numpt [expr $numrow/2 + 1]
              incr numrow
              $tableName insert row -keeptitles -- $curRow 1
              set tbdata($numrow,-1) "a$numpt"

              incr numrow
              $tableName insert row -keeptitles -- $curRow 1
              set tbdata($numrow,-1) "t$numpt"

              # Move the view to see added row
              $tableName yview scroll 2 unit

              update
              $tableName selection activate [expr $curRow +2],0
              $tableName see active

           } else {
              incr numrow

              # Insert a row after the currently selected one
              if {[catch {$tableName index active row} curRow]} {
                 set curRow 1
              }
              $tableName insert row -keeptitles -- $curRow 1

              # Move the view to see added row
              $tableName yview scroll 1 unit

              # Label this new row
              set tbdata($numrow,-1) "C$numrow"

              update
              $tableName selection activate [expr $curRow +1],0
              $tableName see active
           }
        }
   }


   

    #Returns the rows and columns selected#
    #default to the last one created#

    proc rowselect {} {

        variable tableName

        #create a list of sorted selected cells format {0,0 0,1 ....}
        set listcell [$tableName curselection]
        set length [llength $listcell]

        #get the first cell and the last cell selected
        set first [lindex  $listcell 0]
        set lastind [expr $length -1]
        set last [lindex  $listcell $lastind]
        
        #get the first and the last row 
        set firstlis [split $first ,]
        set firstrow  [lindex  $firstlis 0]
       
       
        set lastlis [split $last ,]
        set lastrow  [lindex  $lastlis 0]
       
       
        if {$length == 0} {
            
             if {[catch {$tableName index active row} firstrow]} {
               set firstrow 2
             }
             set lastrow $firstrow
        }
       
        #Delete all the rows selected
        for {set i $firstrow} {$i <= $lastrow} {incr i 1} {
            delrow $firstrow
        }
        
   }


    proc colselect {} {

        variable tableName
        

        #create a list of sorted selected cells format {0,0 0,1 ....}
        set listcell [$tableName curselection]
        set length [llength $listcell]

        #get the first cell and the last cell selected
        set first [lindex  $listcell 0]
        set lastind [expr $length -1]
        set last [lindex  $listcell $lastind]
        
        #get the first and the last row 
        set firstlis [split $first ,]
        set firstcol [lindex  $firstlis 1]
       
        set lastlis [split $last ,]
        set lastcol  [lindex  $lastlis 1]
       
        if {$length == 0} {
             
             if {[catch {$tableName index active col} firstcol]} {
               set firstcol 2
             }
             set lastcol $firstcol
        }
       
        #Delete all the rows selected
        for {set i $firstcol} {$i <= $lastcol} {incr i 1} {
            delcolumn $firstcol
        }
        
   }

    #DELETE A COLUMN IN THE TABLE#

    proc delcolumn { curColumn } {

        variable parent1
        variable tableName
        variable labelin
        variable tbdata
        variable numcol
        variable treeChildsite
        
        if {$numcol >= 2} {
            # Delete the current column
            #if {[catch {$tableName index active col} curColumn]} {
            #   set curColumn 2
            #}
            $tableName delete cols -keeptitles -- $curColumn 1

          set numcol [expr $numcol - 1]
         
          if {$numcol < 2} {
               $tableName tag cell disabledtitle 0,-1
               $tableName tag cell disabled 0,0
          }

      } else {
         tk_messageBox -icon warning \
               -message [msgcat::mc "Cannot remove any more columns"]\
               -parent $parent1
      }
        
   }
   #DELETE A ROW IN THE TABLE#

    proc delrow { curRow } {

        variable parent1
        variable tableName
        variable labelin
        variable thiscol
        variable tbdata
        variable numrow
        variable treeChildsite
        
        
        if { $labelin != "PRONY" && $numrow > 1} {
            # Delete the current row
            #if {[catch {$tableName index active row} curRow]} {
            #   set curRow 2
            #}

              $tableName delete rows -keeptitles -- $curRow 1
              set numrow [expr $numrow - 1]

        } elseif { $labelin == "PRONY" && $numrow > 2 } {
            if {$curRow == 2 || $curRow == 4 || $curRow == 6 || $curRow == 8} {
               set curRow [expr $curRow - 1]
            }
           $tableName delete rows -keeptitles -- $curRow 1
           $tableName delete rows -keeptitles -- $curRow 1
           set numrow [expr $numrow - 2]
         
        } else {
           tk_messageBox -icon warning \
               -message [msgcat::mc "Cannot remove any more rows"]\
               -parent $parent1
        }
        
   }

    proc graph {} {

      variable ::euidl::material::ModelControl::matModelArr

      variable labelin
      variable mat
      variable grpher
      variable tbopt
 
      # Lower the windows so that the graph isn't obscurred in 3D
      lower $matModelArr(parent)
      update

      set tboptcmd "    "
      switch -glob -- $labelin {
         PRONY {
             set tboptcmd $tbopt
         }
         GASK {
             set tboptcmd $tbopt
         }
         JOINT {
             set tboptcmd $tbopt
         }
      }
     
      set grpher 0
     
      #set a dummy material ID
      set matgr [ans_evalexpr mpinqr(0,0,14)]
      set matgr [expr $matgr +1]
 
      # call matOpts_OK with flag on
    
      matOpts_Ok 777 $matgr 0


      set def [ans_evalexpr mpinqr($matgr,0,1)]
      if {$def == 0} {
          return
      }

      if {$labelin == "BISO" || $labelin == "BKIN"} {
      #BISO & BKIN also needs EX mat props
      
          # Get the number of temperatures
          set numt [expr int([ans_getvalue EX,$mat,NTEM])]
          
          # Get the value of each temperature
          for {set i 1} {$i<=$numt} {incr i 1} {            
             set mptemp($i) \
                [ans_getvalue EX,$mat,TVAL,$i]          
                set mptemp($i) [format "%-12.5G" $mptemp($i)]
                set mptemp($i) [string trimright $mptemp($i)] 
          }

          # Loop through data for each temperature 
          for {set i 1} {$i<=$numt} {incr i 1} {              
             set mpdat($i) [ans_getvalue EX,$mat,TEMP,$mptemp($i)]             
             set mpdat($i) [format "%-12.5G" $mpdat($i)]
             set mpdat($i) [string trimright $mpdat($i)]
          }
          #write MP,EX for matgr
          # issue MPTEMP
 
          ans_sendcommand )/NOPR
          for {set  i 1} {$i <= $numt} {incr i} {          
             catch {ans_sendcommand )MPTEMP,$i,$mptemp($i)}
          }
   
          #issue mpdata
          for {set  i 1} {$i <= $numt} {incr i} {          
             catch {ans_sendcommand )MPDATA,EX,$matgr,$i,$mpdat($i)}
          }

      }

      #plot and delete the table
      ans_sendcommand )/GO
      if {$grpher != 999} {
        if {[catch {ans_sendcommand \
              )TBPL,$labelin,$matgr,,,,,,,PREV}]} {
            ans_sendcommand )/NOPR
            catch {ans_sendcommand )TBDE,$labelin,$matgr,,,$tboptcmd}
            if {$labelin == "BISO" || $labelin == "BKIN"} {
                catch {ans_sendcommand )MPDE,EX,$matgr}
            }
            ans_sendcommand )/GO
            return
        }
      }
      ans_sendcommand )/NOPR
      catch {ans_sendcommand )TBDE,$labelin,$matgr,,,$tboptcmd}
      if {$labelin == "BISO" || $labelin == "BKIN"} {
          catch {ans_sendcommand )MPDE,EX,$matgr}
      }
      ans_sendcommand )/GO
      after 1000 [list raise $matModelArr(parent)]
   }

   proc shift_options { } {

      variable numrow
      variable tbopt
      variable actrow
      variable tableName

      if {[catch {$tableName index active row} curRow]} {
         set curRow 1
      }
      if {$tbopt == 1} {
         $tableName tag cell normaltitle 3,-1
         $tableName tag cell normal 3,0
      } else {
         if {$curRow == 3} {
            set curRow 2
         }
         $tableName tag cell disabledtitle 3,-1
         $tableName tag cell disabled 3,0
      }
      $tableName tag cell normaltitle 1,-1
      $tableName tag cell normaltitle 2,-1

      $tableName selection set $curRow,0
      $tableName activate $curRow,0
      $tableName selection anchor $curRow,0
      $tableName see active
      update idletasks
      update
   }

   proc rate_options { } {

      variable numrow
      variable numcol
      variable tbopt
      variable actrow
      variable tableName
      variable tbdata

      if {[catch {$tableName index active row} curRow]} {
         set curRow 1
      }
      if {$tbopt == 1} {
         set tbdata(1,-1) "m"
         set tbdata(2,-1) "Gamma"
         for {set  i 3} {$i <= 9} {incr i} {          
            $tableName tag cell disabledtitle $i,-1
            for {set  j 0} {$j < $numcol} {incr j} {          
               $tableName tag cell disabled $i,$j
            }
         }
         if {$curRow > 2} {
            set curRow 2
         }
         set numrow 2
      } elseif {$tbopt == 2} {
         set tbdata(1,-1) "m"
         set tbdata(2,-1) "Gamma"
         for {set  i 3} {$i <= 9} {incr i} {          
            $tableName tag cell disabledtitle $i,-1
            for {set  j 0} {$j < $numcol} {incr j} {          
               $tableName tag cell disabled $i,$j
            }
         }
         if {$curRow > 2} {
            set curRow 2
         }
         set numrow 2
      } elseif {$tbopt == 5} {
         for {set  i 1} {$i <= $tbopt} {incr i} {          
            set tbdata($i,-1) "C$i"
            $tableName tag cell normaltitle $i,-1
            for {set  j 0} {$j < $numcol} {incr j} {          
               $tableName tag cell normal $i,$j
            }
         }
         for {set i [expr $tbopt + 1]} {$i <= 9} {incr i} {          
            set tbdata($i,-1) "C$i"
            $tableName tag cell disabledtitle $i,-1
            for {set  j 0} {$j < $numcol} {incr j} {          
               $tableName tag cell disabled $i,$j
            }
         }
         if {$curRow > $tbopt} {
            set curRow $tbopt
         }
         set numrow 5
      } elseif {$tbopt == 9} {
         set tbdata(1,-1) "s0"
         set tbdata(2,-1) "Q/R"
         set tbdata(3,-1) "A"
         set tbdata(4,-1) "xi"
         set tbdata(5,-1) "m"
         set tbdata(6,-1) "h0"
         set tbdata(7,-1) "s (hat)"
         set tbdata(8,-1) "n"
         set tbdata(9,-1) "a"
         for {set  i 1} {$i <= $tbopt} {incr i} {          
            $tableName tag cell normaltitle $i,-1
            for {set  j 0} {$j < $numcol} {incr j} {          
               $tableName tag cell normal $i,$j
            }
         }
         set numrow 9
      } else {
         for {set  i 1} {$i <= 9} {incr i} {          
            set tbdata($i,-1) "C$i"
            $tableName tag cell normaltitle $i,-1
            for {set  j 0} {$j < $numcol} {incr j} {          
               $tableName tag cell normal $i,$j
            }
         }
         set numrow 9
      }
      $tableName tag cell normaltitle 1,-1
      $tableName tag cell normaltitle 2,-1

      $tableName selection set $curRow,0
      $tableName activate $curRow,0
      $tableName selection anchor $curRow,0
      $tableName see active
      update idletasks
      update
   }

   proc matOpts_Ok { flag mat next} {
   
      variable parent1
      variable labelin
      variable numcol
      variable numrow
      variable tbdata
      variable tbopt
      variable treeChildsite
      variable tableName 
      variable grpher
      
      # Indicate that a material has changed its values
      variable ::euidl::material::ModelControl::localMatlInfoArr
      if {[info exists localMatlInfoArr]} {
         set localMatlInfoArr(matl,$mat,chng) 1
      }
      
      set tboptcmd "    "
      switch -glob -- $labelin {
         PRONY {
             set tboptcmd $tbopt
         }
         GASK {
             set tboptcmd $tbopt
         }
         JOINT {
             set tboptcmd $tbopt
         }
      }
     
      #Reorder TEMPERATURE - Create a list 
      for {set i 0} {$i<$numcol} {incr i 1} { 
         if {[catch {lappend tempData $tbdata(0,$i)}]} {
                     set tbdata(0,$i) 0
                     lappend tempData $tbdata(0,$i)
         }
      }
      # Sort the temperatures into a list
     
      if {[catch {set tempSort [lsort -real -unique $tempData]}]} {
         catch {unset tempData2}
         foreach junktemp $tempData {
            regsub -all { } $junktemp {} junktemp
            if {[catch {ans_evalexpr $junktemp}]} {
               #set junktemp 0
                return
            } else {
               set junktemp [ans_evalexpr $junktemp]
            }
            lappend tempData2 $junktemp
         }
         set tempData $tempData2
         set tempSort [lsort -real -unique $tempData]
      }
      if {[llength $tempData] != [llength $tempSort]} {
         set tl {}
         set tempSort [lsort -real $tempData]
         set tl [lindex $tempSort 0]
         for {set i 1} {$i < [llength $tempSort]} {incr i} {
            if {[lindex $tempSort $i] == $tl} {
               tk_messageBox -icon error \
                     -parent $parent1 \
                     -message [::msgcat::mc "There are multiple temperatures\
                                 with value of $tl"]
               break
            }
            set tl [lindex $tempSort $i]
         }
         return
      }

      # We have a valid sorted temperature list tempSort
      ans_sendcommand )/NOPR
      #TB command
      set tb [ans_getvalue $labelin,$mat,EXIS,,,,$tboptcmd]
      if {$tb == 1} {
         catch {ans_sendcommand TBDE,$labelin,$mat,,,$tboptcmd}
      }
      if {$flag != 777} {
          ans_sendcommand )/GO
      }
      if {$labelin == "CHAB" } {
          # 2*N+1
         set int [expr int(($numrow - 1)/2)]                  
         set rest [expr fmod([expr $numrow - 1] ,2)]
        
         set npts [expr $int + $rest]
         if {[catch {ans_sendcommand \
                        TB,$labelin,$mat,$numcol,$npts,$tbopt}]} {
#               catch {ans_sendcommand TBDE,$labelin,$mat}
                return
         }
        
      } elseif {$labelin == "PRONY"} {

         set npts [expr int($numrow/2)]                  

         if {[catch {ans_sendcommand \
                        TB,$labelin,$mat,$numcol,$npts,$tbopt}]} {
                return
         }

      } elseif {$labelin == "HYPE"} {
         switch -exact -- $tbopt {

            
           MOON {
                # NPTS in tb command -> number of lines in the tktable
                # (2->3 ; 3->4 ; 5->7 ; 9->12)
                # ex : if 7 lines in the table goto npts = 10
               set npts 2
               if {$numrow > 3 } {
                    set npts 3
               } 
               if { $numrow > 4} {
                    set npts 5
               } 
               if { $numrow > 7} { 
                    set npts 9 
               } 
              
               if {[catch {ans_sendcommand \
                        TB,$labelin,$mat,$numcol,$npts,$tbopt}]} {
#                  catch {ans_sendcommand TBDE,$labelin,$mat}
                  return
               }                
               
              
           }   
           OGDE {
                # 3*N
               set npts [expr int($numrow/3)]
               set rest [expr fmod($numrow,3)]
               if {$rest != 0} {
                   set npts [expr $npts +1]
               }
               if {[catch {ans_sendcommand \
                        TB,$labelin,$mat,$numcol,$npts,$tbopt}]} {
#                  catch {ans_sendcommand TBDE,$labelin,$mat}
                  return
               }                
               
              
           }
           POLY {
               # (N+1)(N+2)/2 -1 + N
               set delta [expr sqrt(25 + 8 * $numrow)]
               set npts [expr int(-5 + $delta)/2]
               set rest [expr fmod([expr -5 + $delta],2)]
                if {$rest != 0} {
                   set npts [expr $npts +1]
               }
                if {[catch {ans_sendcommand \
                        TB,$labelin,$mat,$numcol,$npts,$tbopt}]} {
#                  catch {ans_sendcommand TBDE,$labelin,$mat}
                  return
               }                
                            
           }
           YEOH {
                # 2*N
               set npts [expr int($numrow/2)]
               set rest [expr fmod($numrow,2)]
               if {$rest != 0} {
                   set npts [expr $npts +1]
               }
               if {[catch {ans_sendcommand \
                        TB,$labelin,$mat,$numcol,$npts,$tbopt}]} {
                  return
               }                
           }
           FOAM {
                # 3*N
               set npts [expr int($numrow/3)]
               set rest [expr fmod($numrow,3)]
               if {$rest != 0} {
                   set npts [expr $npts +1]
               }
               if {[catch {ans_sendcommand \
                        TB,$labelin,$mat,$numcol,$npts,$tbopt}]} {
                  return
               }                
           }
           default { 
                  if {[catch {ans_sendcommand \
                        TB,$labelin,$mat,$numcol,$numrow,$tbopt}]} {
#                         catch {ans_sendcommand TBDE,$labelin,$mat}
                         return
                  }            
                 
              
           }
         }
         
      } else {
         if {$flag != 777} {
            if {[catch {ans_sendcommand \
                        TB,$labelin,$mat,$numcol,$numrow,$tbopt}]} {
#                catch {ans_sendcommand TBDE,$labelin,$mat}
                return
            }
         } else {
            if {[catch {ans_sendcommand \
                        )TB,$labelin,$mat,$numcol,$numrow,$tbopt}]} {
                       set grpher 999 
                       return
            }
         }
      }
      

      #TBTEMP-TBDATA Command -Loop through the table

      foreach temp $tempSort {
         set i [lsearch $tempData $temp]
         if {$flag != 777} {
             catch {ans_sendcommand TBTEMP,$temp}
         } else {
             catch {ans_sendcommand )TBTEMP,$temp}
         }
         for {set j 0} {$j < $numrow} {incr j 6} { 
            for {set k 1} {$k <= 6} {incr k} {
               #if {[catch {ans_evalexpr $tbdata([expr $j + $k],$i)}]} {
               #   set tbdata([expr $j + $k],$i) ""
               #}
               if {[catch {set c($k) $tbdata([expr $j + $k],$i)}]} {
                  set c($k) ""
               }
               regsub -all { } $c($k) {} c($k)
            }
            if {$flag != 777} {
               if {[catch {ans_sendcommand \
                    TBDATA,,$c(1),$c(2),$c(3),$c(4),$c(5),$c(6)}]} {
                        ans_sendcommand )/NOPR
                        catch {ans_sendcommand TBDE,$labelin,$mat}
                        ans_sendcommand )/GO
                        return
               }
            } else {
               if {[catch {ans_sendcommand \
                   )TBDATA,,$c(1),$c(2),$c(3),$c(4),$c(5),$c(6)}]} {
                   set grpher 999
                   ans_sendcommand )/GO
                   return
               }
            }
         }
      }
      ans_sendcommand )/GO

       #if flag = 777 you just want to graph and not exit the window

       if {$flag != 777} {
         # Unset the variables to make sure the table table is clean
         # on reentry.

         unset numcol
         unset numrow
         unset tbdata

         destroy $parent1
         unset parent1
        
         #call next table and don't restart for combined models
         if {$next != 999} {
           if {$next != 0} {
              euidl::material::ModelControl::table_choice $next $mat 0
              return
           } else {
              euidl::material::ModelControl::matTable_State 1
              return
           }
         }
       }
   }

   proc matOpts_Cancel {} {
      variable parent1
      variable numcol
      variable numrow
      variable tbdata

      unset tbdata
      unset numcol
      unset numrow
      destroy $parent1
      unset parent1
      
      euidl::material::ModelControl::matTable_State 1
   }

}

# ============================================================================
# File Name:     table2.eui
# Description:   Dialog box for all LSDYNA material models
# ============================================================================
namespace eval ::euidl::material::mat2 {

   
   proc TABLE2 {label matid next} {
      
      variable ::euidl::material::ModelControl::matModelArr
        

      variable numcol
      variable numrow
      variable tbdata
      variable labelin
      variable colmax
      set labelin $label

      # set defaults for maximum number of rows and columns
      set rowmax 100
      set colmax 100
     
      variable parent2
      variable childsite
      variable tableName
      variable treeChildsite
      variable listMP

      euidl::material::ModelControl::matTable_State 0

      if [winfo exists .dlgMatOpts] {
         # Set the display correctly
         $parent2 activate
         return
      }


      set parent2 [euidl::dialog .dlgMatOpts -class EUIDL \
            -master $matModelArr(parent) \
            ]
      set childsite [$parent2 component childsite]

      #SET WINDOW#

      #wm minsize $parent2 500 350
    
      set mat $matid
   
      # Buttons ADD & DELETE & GRAPH for temp dep BISO model 
   
      if {$labelin == "BISOtmp"} { 
         euidl::button $childsite.addaftc -text [msgcat::mc "Add Temperature"] \
            -command [code addcolumn ] 
         grid $childsite.addaftc -column 0 -row 3

         bind $childsite.addaftc <ButtonRelease-1> \
                  [code ::euidl::material::error::check %W]


         euidl::button $childsite.delcolumn -text [msgcat::mc "Delete Temperature"] \
            -command [code colselect ]
         grid $childsite.delcolumn -column 1 -row 3

         bind $childsite.delcolumn <ButtonRelease-1> \
                  [code ::euidl::material::error::check %W]

         #set the graph drop-down button
         menubutton  $childsite.mb1 -text [msgcat::mc "Graph"] \
            -menu $childsite.mb1.menu -borderwidth 2\
            -relief raised 
         bind $childsite.mb1 <ButtonPress-1> {focus %W}
         menu $childsite.mb1.menu -tearoff 0
         
         set ind 0
         foreach m [list EX NUXY ALPX BISO] {
              set ind [expr $ind + 1]
              set $m [menu $childsite.mb1.menu.m$m -tearoff 0]
              $childsite.mb1.menu add command \
                  -label [msgcat::mc "$m"] \
                  -command [code graph $m $ind]
         }
            
         grid $childsite.mb1 -sticky e -column 6 -row 3
         

         grid columnconfigure $childsite 2 -minsize 50
         grid columnconfigure $childsite 5 -minsize 50
         grid columnconfigure $childsite 6 -weight 1

      }



      set tableName [euidl::table $childsite.tbl1 \
            -variable [scope tbdata] \
            -rowseparator \n \
            -colseparator \t \
            -validate focusout \
            -validatedata ansreal \
         ]
     


      $tableName config -colwidth 18

      # Set up the dialog box depending on the model chosen 

      switch -exact -- $labelin {
         ISOTdyn {
             euidl::label $childsite.lbl$labelin -height 3 \
                  -anchor w \
                  -text [msgcat::mc " Linear Isotropic Material Properties\
                        for Material Number $mat"]
             wm title $parent2 [msgcat::mc "Linear Isotropic Properties\
                  for Material Number $mat"]
             $parent2 configure  -helpcommand [list ans_loadhelp Hlp_lise]

             set numcol 1
             set numrow 4
             
             set tbdata(0,-1) "DENS"
             set tbdata(1,-1) "EX"
             set ratiochk [ans_getvalue PRXY,$mat,EXIS]
             if {$ratiochk == 1} {
                set tbdata(2,-1) "PRXY"
                set listMP {DENS EX PRXY}
             } else {
                set tbdata(2,-1) "NUXY"
                set listMP {DENS EX NUXY}
             }

             set labeldac "ISOT"
             wm minsize $parent2 500 230
             
             $tableName config -colmax 1          
             $tableName config -rowmax 4
             
         }
         ORTHdyn {
             euidl::label $childsite.lbl$labelin -height 3 \
                  -anchor w \
                  -text [msgcat::mc "Linear Orthotropic Material Properties\
                        for Material Number $mat"]
             wm title $parent2 [msgcat::mc "Linear Orthotropic Properties\
                  for Material Number $mat"]
             $parent2 configure  -helpcommand [list ans_loadhelp Hlp_lore]
             
             wm minsize $parent2 500 430

             set numcol 1
             set numrow 12

             set tbdata(0,-1) "DENS"
             set tbdata(1,-1) "EX"
             set tbdata(2,-1) "EY"
             set tbdata(3,-1) "EZ"
             set tbdata(4,-1) "NUXY"
             set tbdata(5,-1) "NUYZ"
             set tbdata(6,-1) "NUXZ"
             set tbdata(7,-1) "GXY"
             set tbdata(8,-1) "GYZ"
             set tbdata(9,-1) "GXZ"
             set tbdata(10,-1) "Coord ID"
             
             set listMP {DENS EX EY EZ NUXY NUYZ NUXZ GXY\
                         GYZ GXZ}
             set labeldac "ORTH"
             wm minsize $parent2 500 230
             
             
             $tableName config -colmax 1          
             $tableName config -rowmax 12
         }
         ANELdyn {
             euidl::label $childsite.lbl$labelin -height 3 \
                  -anchor w \
                  -text [msgcat::mc " Anisotropic Elastic Material Properties\
                        for Material Number $mat"]
             wm title $parent2 [msgcat::mc "Anisotropic Elastic Properties\
                  for Material Number $mat"]
             $parent2 configure  -helpcommand [list ans_loadhelp Hlp_lanel]

             set numcol 1
             set numrow 24
             
             set tbdata(0,-1) "DENS"
             set tbdata(1,-1) "Coord System ID"
             set tbdata(2,-1) "C(1,1)"
             set tbdata(3,-1) "C(1,2)"
             set tbdata(4,-1) "C(2,2)"
             set tbdata(5,-1) "C(1,3)"
             set tbdata(6,-1) "C(2,3)"
             set tbdata(7,-1) "C(3,3)"
             set tbdata(8,-1) "C(1,4)"
             set tbdata(9,-1) "C(2,4)"
             set tbdata(10,-1) "C(3,4)"
             set tbdata(11,-1) "C(4,4)"
             set tbdata(12,-1) "C(1,5)"
             set tbdata(13,-1) "C(2,5)"
             set tbdata(14,-1) "C(3,5)"
             set tbdata(15,-1) "C(4,5)"
             set tbdata(16,-1) "C(5,5)"
             set tbdata(17,-1) "C(1,6)"
             set tbdata(18,-1) "C(2,6)"
             set tbdata(19,-1) "C(3,6)"
             set tbdata(20,-1) "C(4,6)"
             set tbdata(21,-1) "C(5,6)"
             set tbdata(22,-1) "C(6,6)"

             set listMP {DENS}
             set labeldac "ANEL"

             wm minsize $parent2 500 430

             $tableName config -colmax 1          
             $tableName config -rowmax 24
             
         }
         FLUIdyn {
             euidl::label $childsite.lbl$labelin -height 3 \
                  -anchor w \
                  -text [msgcat::mc " Elastic Fluid Material Properties\
                        for Material Number $mat"]
             wm title $parent2 [msgcat::mc "Elastic Fluid Properties\
                  for Material Number $mat"]
             $parent2 configure  -helpcommand [list ans_loadhelp Hlp_lelf]

             set numcol 1
             set numrow 5
             
             set tbdata(0,-1) "DENS"
             set tbdata(1,-1) "EX"
             set tbdata(2,-1) "NUXY"
             set tbdata(3,-1) "Bulk Modulus"

             set listMP {DENS EX NUXY}
             set labeldac "FLUI"

             wm minsize $parent2 500 230

             $tableName config -colmax 1          
             $tableName config -rowmax 4
        }
        EVISC {
             euidl::label $childsite.lbl$labelin -height 3 \
                  -anchor w \
                  -text [msgcat::mc " Viscoelastic Material Properties\
                        for Material Number $mat"]
             wm title $parent2 [msgcat::mc "Viscoelastic Properties\
                  for Material Number $mat"]
             $parent2 configure  -helpcommand [list ans_loadhelp Hlp_levi]

             set numcol 1
             set numrow 6
             
             set tbdata(0,-1) "DENS"
             set tbdata(1,-1) "Shear Mod - Origin"
             set tbdata(2,-1) "Shear Mod-Infinity"
             set tbdata(3,-1) "Bulk Modulus"
             set tbdata(4,-1) "Reciprocal of Beta"

             set listMP {DENS}
             set labeldac "EVIS"
             wm minsize $parent2 500 230

             $tableName config -colmax 1          
             $tableName config -rowmax 6
        }
        MOONdyn {
             euidl::label $childsite.lbl$labelin -height 3 \
                  -anchor w \
                  -text [msgcat::mc " Mooney Rivlin Material Properties\
                        for Material Number $mat"]
             wm title $parent2 [msgcat::mc "Mooney Rivlin Properties\
                  for Material Number $mat"]
             $parent2 configure  -helpcommand [list ans_loadhelp Hlp_lmoon]

             set numcol 1
             set numrow 9
             
             set tbdata(0,-1) "DENS"
             set tbdata(1,-1) "NUXY"
             set tbdata(4,-1) "Spec Gauge length"
             set tbdata(5,-1) "Spec Gauge width"
             set tbdata(6,-1) "Spec Gauge thickness"
             set tbdata(7,-1) "Load Curve ID LCID"

             set listMP {DENS NUXY}
             set labeldac "MOON"
             wm minsize $parent2 500 230

             $tableName height 2 0
             $tableName height 3 0
             $tableName tag configure disabledflat -relief flat \
                    -state disabled \
                    -background [$tableName cget -disabledbackground]\
                    -foreground [$tableName cget -disabledbackground]

             $tableName tag raise disabledflat title

             $tableName tag cell disabledflat 2,-1
             $tableName tag cell disabledflat 2,0
             $tableName tag cell disabledflat 3,-1
             $tableName tag cell disabledflat 3,0

             $tableName config -colmax 1          
             $tableName config -rowmax 9
             $tableName width -1 20
        }
        MOON1dyn {
             euidl::label $childsite.lbl$labelin -height 3 \
                  -anchor w \
                  -text [msgcat::mc " Mooney Rivlin Material Properties\
                        for Material Number $mat"]
             wm title $parent2 [msgcat::mc "Mooney Rivlin Properties\
                  for Material Number $mat"]
             $parent2 configure  -helpcommand [list ans_loadhelp Hlp_lmoon]

             set numcol 1
             set numrow 5
             
             set tbdata(0,-1) "DENS"
             set tbdata(1,-1) "NUXY"
             set tbdata(2,-1) "C(10)"
             set tbdata(3,-1) "C(01)"

             set listMP {DENS NUXY}
             set labeldac "MOON"
             wm minsize $parent2 500 230

             $tableName config -colmax 1          
             $tableName config -rowmax 5
        }
        BLAT {
             euidl::label $childsite.lbl$labelin -height 3 \
                  -anchor w \
                  -text [msgcat::mc " Blatz-KO Material Properties\
                        for Material Number $mat"]
             wm title $parent2 [msgcat::mc "Blatz-KO Properties\
                  for Material Number $mat"]
             $parent2 configure  -helpcommand [list ans_loadhelp Hlp_lblk]

             set numcol 1
             set numrow 3
             
             set tbdata(0,-1) "DENS"
             set tbdata(1,-1) "GXY"

             set listMP {DENS GXY}
             set labeldac "BLAT"
             wm minsize $parent2 500 230

             $tableName config -colmax 1          
             $tableName config -rowmax 3
       }
        BISOdyn {
             euidl::label $childsite.lbl$labelin -height 3 \
                  -anchor w \
                  -text [msgcat::mc " Bilinear Isotropic Material Properties\
                        for Material Number $mat"]
             wm title $parent2 [msgcat::mc "Bilinear Isotropic Properties\
                  for Material Number $mat"]
             $parent2 configure  -helpcommand [list ans_loadhelp Hlp_lbiso]

             set numcol 1
             set numrow 6
             
             set tbdata(0,-1) "DENS"
             set tbdata(1,-1) "EX"
             set tbdata(2,-1) "NUXY"
             set tbdata(3,-1) "Yield Stress"
             set tbdata(4,-1) "Tangent Modulus"

             set listMP {DENS EX NUXY}
             set labeldac "BISO"
             wm minsize $parent2 500 230

             $tableName config -colmax 1          
             $tableName config -rowmax 6
       }
        BISOtmp {
             euidl::label $childsite.lbl$labelin -height 3 \
                  -anchor w \
                  -text [msgcat::mc " Temperature Dependent BISO\
                        Material Properties for Material Number $mat"]
             wm title $parent2 [msgcat::mc "Temperature Dependent BISO\
                  Properties for Material Number $mat"]
             $parent2 configure  -helpcommand [list ans_loadhelp Hlp_lbist]

             set numcol 1
             set numrow 8
             set numt [expr int([ans_getvalue EX,$mat,NTEMP])]
             if {$numt > 1} {
                set numcol $numt
             }
             
             set tbdata(-1,0) "T1"
             set tbdata(0,-1) "Temperature"
             set tbdata(1,-1) "DENS"
             set tbdata(2,-1) "EX"
             set tbdata(3,-1) "NUXY"
             set tbdata(4,-1) "ALPX"
             set tbdata(5,-1) "Yield Stress"
             set tbdata(6,-1) "Tangent Mod."


             set listMP {DENS EX NUXY ALPX}

             for {set k 0} {$k < $numcol} {incr k 1} {
               
              #get temperature
              if {$numt > 0} {
                 set tbdata(0,$k) [ans_getvalue EX,$mat,TVAL,[expr $k+1]]
              }
              # get MP values
              set ii 1
              foreach lab $listMP {
                 set check [ans_getvalue $lab,$mat,EXIS]
                 if {$check > 0} {
                    set tbdata($ii,$k)  [ans_getvalue $lab,$mat,TEMP,$tbdata(0,$k)]
                    if {$lab == "DENS"} {
                       if {$k >= 1} {
                          set tbdata(1,$k) $tbdata(1,0)
                          #deactivate the cell if greater than one
                          #$tableName tag cell disabledtitle 1,$k
                          $tableName tag cell disabled 1,$k
                       }
                   }
                    set tbdata($ii,$k)  [format "%-10.5G" $tbdata($ii,$k)]
                    set tbdata($ii,$k) [string trimright $tbdata($ii,$k)]
                    set ii [expr $ii+1]
                 }
               }
               # get TB values
               set check [ans_getvalue BISO,$mat,EXIS]
               if {$check > 0} {
                       set tbdata(5,$k) [ans_getvalue BISO,$mat,TEMP,$tbdata(0,$k),CONST,1]
                       set tbdata(5,$k) [format "%-10.5G" $tbdata(5,$k)]
                       set tbdata(5,$k) [string trimright $tbdata(5,$k)]
                       set tbdata(6,$k) [ans_getvalue BISO,$mat,TEMP,$tbdata(0,$k),CONST,2]
                       set tbdata(6,$k) [format "%-10.5G" $tbdata(6,$k)]
                       set tbdata(6,$k) [string trimright $tbdata(6,$k)]
               }
               if {$numt > 0} {
                  set tbdata(0,$k) [format "%-10.5G" $tbdata(0,$k)]
                  set tbdata(0,$k) [string trimright $tbdata(0,$k)]
               }
             }

             wm minsize $parent2 650 350
             set colmax 6
             $tableName config -colmax 6          
             $tableName config -rowmax 8
             if {$numt < 2} {
                $tableName tag cell disabledtitle 0,-1
                $tableName tag cell disabled 0,0
             }
             $tableName config -colwidth 13
       }
        ANISdyn {
             euidl::label $childsite.lbl$labelin -height 3 \
                  -anchor w \
                  -text [msgcat::mc "Transverse Anisotropic\
                        Material Properties for Material Number $mat"]
             wm title $parent2 [msgcat::mc "Transverse Anisotropic Material\
                  Properties for Material Number $mat"]
             $parent2 configure  -helpcommand [list ans_loadhelp Hlp_lpl7]

             set numcol 1
             set numrow 8
             
             set tbdata(0,-1) "DENS"
             set tbdata(1,-1) "EX"
             set tbdata(2,-1) "NUXY"
             set tbdata(3,-1) "Yield Stress"
             set tbdata(4,-1) "Tangent Modulus"
             set tbdata(5,-1) "Hardening Parameter"
             set tbdata(6,-1) "Load Curve ID"

             set listMP {DENS EX NUXY}
             set labeldac "PLAW"
             wm minsize $parent2 500 230

             $tableName config -colmax 1          
             $tableName config -rowmax 8
             $tableName width -1 19
       }
        ANISfld {
             euidl::label $childsite.lbl$labelin -height 3 \
                  -anchor w \
                  -text [msgcat::mc "Transverse Anisotropic FLD\
                        Material Properties for Material Number $mat"]
             wm title $parent2 [msgcat::mc "Transverse Anisotropic FLD Material\
                  Properties for Material Number $mat"]
             $parent2 configure  -helpcommand [list ans_loadhelp Hlp_lpl10]

             set numcol 1
             set numrow 9
             
             set tbdata(0,-1) "DENS"
             set tbdata(1,-1) "EX"
             set tbdata(2,-1) "NUXY"
             set tbdata(3,-1) "Yield Stress"
             set tbdata(4,-1) "Tangent Modulus"
             set tbdata(5,-1) "Hardening Parameter"
             set tbdata(6,-1) "Load Curve-Effect Stress"
             set tbdata(7,-1) "Load Curve-FLD"

             set listMP {DENS EX NUXY}
             set labeldac "PLAW"
             wm minsize $parent2 500 230

             $tableName config -colmax 1          
             $tableName config -rowmax 9
             $tableName width -1 24
       }
        BKINdyn {
             euidl::label $childsite.lbl$labelin -height 3 \
                  -anchor w \
                  -text [msgcat::mc "Bilinear Kinematic\
                        Material Properties for Material Number $mat"]
             wm title $parent2 [msgcat::mc "Bilinear Kinematic\
                  Properties for Material Number $mat"]
             $parent2 configure  -helpcommand [list ans_loadhelp Hlp_lbkin]

             set numcol 1
             set numrow 6
             
             set tbdata(0,-1) "DENS"
             set tbdata(1,-1) "EX"
             set tbdata(2,-1) "NUXY"
             set tbdata(3,-1) "Yield Stress"
             set tbdata(4,-1) "Tangent Modulus"

             set listMP {DENS EX NUXY}
             set labeldac "BKIN"
             wm minsize $parent2 500 230

             $tableName config -colmax 1          
             $tableName config -rowmax 6
       }
        KINEdyn {
             euidl::label $childsite.lbl$labelin -height 3 \
                  -anchor w \
                  -text [msgcat::mc "Plastic Kinematic\
                        Material Properties for Material Number $mat"]
             wm title $parent2 [msgcat::mc "Plastic Kinematic\
                  Properties for Material Number $mat"]
             $parent2 configure  -helpcommand [list ans_loadhelp Hlp_lpl1]

             set numcol 1
             set numrow 10
             
             set tbdata(0,-1) "DENS"
             set tbdata(1,-1) "EX"
             set tbdata(2,-1) "NUXY"
             set tbdata(3,-1) "Yield Stress"
             set tbdata(4,-1) "Tangent Modulus"
             set tbdata(5,-1) "Hardening Parm"
             set tbdata(6,-1) "Strain Rate (c)"
             set tbdata(7,-1) "Strain Rate (P)"
             set tbdata(8,-1) "Failure Strain"

             set listMP {DENS EX NUXY}
             set labeldac "PLAW"
             wm minsize $parent2 500 230

             $tableName config -colmax 1          
             $tableName config -rowmax 10
       }
        BAR3dyn {
             euidl::label $childsite.lbl$labelin -height 3 \
                  -anchor w \
                  -text [msgcat::mc "3 Parameter Barlat\
                        Material Properties for Material Number $mat"]
             wm title $parent2 [msgcat::mc "3 Parameter Barlat\
                  Properties for Material Number $mat"]
             $parent2 configure  -helpcommand [list ans_loadhelp Hlp_lpl3]

             set numcol 1
             set numrow 12
             
             set tbdata(0,-1) "DENS"
             set tbdata(1,-1) "EX"
             set tbdata(2,-1) "NUXY"
             set tbdata(3,-1) "Hardening Rule"
             set tbdata(4,-1) "Tang Mod/Strn Coef"
             set tbdata(5,-1) "Yld Strs/Hard Coef"
             set tbdata(6,-1) "Barlat Expon (m)"
             set tbdata(7,-1) "Width ratio-orig"
             set tbdata(8,-1) "Width ratio-45 deg"
             set tbdata(9,-1) "Width ratio-90 deg"
             set tbdata(10,-1) "Ortho Axis (CSID)"

             set listMP {DENS EX NUXY}
             set labeldac "PLAW"
             wm minsize $parent2 500 230

             $tableName config -colmax 1          
             $tableName config -rowmax 12
       }
        BARLdyn {
             euidl::label $childsite.lbl$labelin -height 3 \
                  -anchor w \
                  -text [msgcat::mc "Barlat Anisotropic\
                        Material Properties for Material Number $mat"]
             wm title $parent2 [msgcat::mc "Barlat Anisotropic\
                  Properties for Material Number $mat"]
             $parent2 configure  -helpcommand [list ans_loadhelp Hlp_lpl6]

             set numcol 1
             set numrow 14
             
             set tbdata(0,-1) "DENS"
             set tbdata(1,-1) "EX"
             set tbdata(2,-1) "NUXY"
             set tbdata(3,-1) "Strength Coeff (k)"
             set tbdata(4,-1) "Init Strain (EPSO)"
             set tbdata(5,-1) "Hardening Coeff (n)"
             set tbdata(6,-1) "Flow Potent Exp (m)"
             set tbdata(7,-1) "Aniso Mat Const (a)"
             set tbdata(8,-1) "Aniso Mat Const (b)"
             set tbdata(9,-1) "Aniso Mat Const (c)"
             set tbdata(10,-1) "Aniso Mat Const (f)"
             set tbdata(11,-1) "Aniso Mat Const (g)"
             set tbdata(12,-1) "Aniso Mat Const (h)"

             set listMP {DENS EX NUXY}
             set labeldac "PLAW"
             wm minsize $parent2 500 230

             $tableName config -colmax 1          
             $tableName config -rowmax 14
             $tableName width -1 19
       }
        SENSdyn {
             euidl::label $childsite.lbl$labelin -height 3 \
                  -anchor w \
                  -text [msgcat::mc "Rate Sensitive\
                        Material Properties for Material Number $mat"]
             wm title $parent2 [msgcat::mc "Rate Sensitive\
                  Properties for Material Number $mat"]
             $parent2 configure  -helpcommand [list ans_loadhelp Hlp_lpl4]

             set numcol 1
             set numrow 8
             
             set tbdata(0,-1) "DENS"
             set tbdata(1,-1) "EX"
             set tbdata(2,-1) "NUXY"
             set tbdata(3,-1) "Material Const (k)"
             set tbdata(4,-1) "Hardening Coeff (m)"
             set tbdata(5,-1) "Strain Rate Parm(n)"
             set tbdata(6,-1) "Initial Strain Rate"

             set listMP {DENS EX NUXY}
             set labeldac "PLAW"
             wm minsize $parent2 500 230

             $tableName config -colmax 1          
             $tableName config -rowmax 8
             $tableName width -1 19
        }
        DEPdyn {
             euidl::label $childsite.lbl$labelin -height 3 \
                  -anchor w \
                  -text [msgcat::mc "Rate Dependent\
                        Material Properties for Material Number $mat"]
             wm title $parent2 [msgcat::mc "Rate Dependent\
                  Properties for Material Number $mat"]
             $parent2 configure  -helpcommand [list ans_loadhelp Hlp_lpl5]

             set numcol 1
             set numrow 10
             
             set tbdata(0,-1) "DENS"
             set tbdata(1,-1) "EX"
             set tbdata(2,-1) "NUXY"
             set tbdata(3,-1) "LCID 1"
             set tbdata(4,-1) "Hardening Modulus"
             set tbdata(5,-1) "LCID 2"
             set tbdata(6,-1) "LCID 3"
             set tbdata(7,-1) "LCID 4"
             set tbdata(8,-1) "Min Time Step Size"

             set listMP {DENS EX NUXY}
             set labeldac "PLAW"
             wm minsize $parent2 500 230

             $tableName config -colmax 1          
             $tableName config -rowmax 10
        }
        COMPdyn {
             euidl::label $childsite.lbl$labelin -height 3 \
                  -anchor w \
                  -text [msgcat::mc "Composite\
                        Material Properties for Material Number $mat"]
             wm title $parent2 [msgcat::mc "Composite\
                  Properties for Material Number $mat"]
             $parent2 configure  -helpcommand [list ans_loadhelp Hlp_lcom]

             set numcol 1
             set numrow 17
             
             set tbdata(0,-1) "DENS"
             set tbdata(1,-1) "EX"
             set tbdata(2,-1) "EY"
             set tbdata(3,-1) "EZ"
             set tbdata(4,-1) "GXY"
             set tbdata(5,-1) "GYZ"
             set tbdata(6,-1) "GXZ"
             set tbdata(7,-1) "NUXY"
             set tbdata(8,-1) "NUYZ"
             set tbdata(9,-1) "NUXZ"
             set tbdata(10,-1) "Bulk Modulus"
             set tbdata(11,-1) "Shear Strength"
             set tbdata(12,-1) "Longitudinal Stress"
             set tbdata(13,-1) "Trans Tens Strength"
             set tbdata(14,-1) "Trans Comp Strength"
             set tbdata(15,-1) "Nonlin Shear Stress"

             set listMP {DENS EX EY EZ GXY GYZ GXZ NUXY NUYZ NUXZ}
             set labeldac "COMP"
             wm minsize $parent2 500 230
            
             $tableName config -colmax 1          
             $tableName config -rowmax 17
             $tableName width -1 19
       }
        CONCdyn {
             euidl::label $childsite.lbl$labelin -height 3 \
                  -anchor w \
                  -text [msgcat::mc "Concrete\
                        Material Properties for Material Number $mat"]
             wm title $parent2 [msgcat::mc "Concrete\
                  Properties for Material Number $mat"]
             $parent2 configure  -helpcommand [list ans_loadhelp Hlp_lcon]
 
             set numcol 1
             set numrow 81
             
             set tbdata(0,-1) "DENS"
             set tbdata(1,-1) "NUXY"
             set tbdata(2,-1) "SigmaF"
             #set tbdata(3,-1) "F"
             set tbdata(3,-1) "A0"
             set tbdata(4,-1) "A1"
             set tbdata(5,-1) "A2"
             set tbdata(6,-1) "A0Y"
             set tbdata(7,-1) "A1Y"
             set tbdata(8,-1) "A2Y"
             set tbdata(9,-1) "A1F"
             set tbdata(10,-1) "A2F"
             set tbdata(11,-1) "B1"
             set tbdata(12,-1) "B2"
             set tbdata(13,-1) "B3"
             set tbdata(14,-1) "PER"
             set tbdata(15,-1) "Er"
             set tbdata(16,-1) "NUXYr"
             set tbdata(17,-1) "SigmaY"
             set tbdata(18,-1) "Etan"
             set tbdata(19,-1) "LCP"
             set tbdata(20,-1) "LCR"
             set tbdata(21,-1) "Lambda 1"
             set tbdata(22,-1) "Lambda 2"
             set tbdata(23,-1) "Lambda 3"
             set tbdata(24,-1) "Lambda 4"
             set tbdata(25,-1) "Lambda 5"
             set tbdata(26,-1) "Lambda 6"
             set tbdata(27,-1) "Lambda 7"
             set tbdata(28,-1) "Lambda 8"
             set tbdata(29,-1) "Lambda 9"
             set tbdata(30,-1) "Lambda 10"
             set tbdata(31,-1) "Lambda 11"
             set tbdata(32,-1) "Lambda 12"
             set tbdata(33,-1) "Lambda 13"
             set tbdata(34,-1) "Eta 1"
             set tbdata(35,-1) "Eta 2"
             set tbdata(36,-1) "Eta 3"
             set tbdata(37,-1) "Eta 4"
             set tbdata(38,-1) "Eta 5"
             set tbdata(39,-1) "Eta 6"
             set tbdata(40,-1) "Eta 7"
             set tbdata(41,-1) "Eta 8"
             set tbdata(42,-1) "Eta 9"
             set tbdata(43,-1) "Eta 10"
             set tbdata(44,-1) "Eta 11"
             set tbdata(45,-1) "Eta 12"
             set tbdata(46,-1) "Eta 13"
             set tbdata(47,-1) "gamma"
             set tbdata(48,-1) "E0"
             set tbdata(49,-1) "V0"
             set tbdata(50,-1) "epsilon: (v1)"
             set tbdata(51,-1) "epsilon: (v2)"
             set tbdata(52,-1) "epsilon: (v3)"
             set tbdata(53,-1) "epsilon: (v4)"
             set tbdata(54,-1) "epsilon: (v5)"
             set tbdata(55,-1) "epsilon: (v6)"
             set tbdata(56,-1) "epsilon: (v7)"
             set tbdata(57,-1) "epsilon: (v8)"
             set tbdata(58,-1) "epsilon: (v9)"
             set tbdata(59,-1) "epsilon: (v10)"
             set tbdata(60,-1) "C1"
             set tbdata(61,-1) "C2"
             set tbdata(62,-1) "C3"
             set tbdata(63,-1) "C4"
             set tbdata(64,-1) "C5"
             set tbdata(65,-1) "C6"
             set tbdata(66,-1) "C7"
             set tbdata(67,-1) "C8"
             set tbdata(68,-1) "C9"
             set tbdata(69,-1) "C10"
             set tbdata(70,-1) "T1"
             set tbdata(71,-1) "T2"
             set tbdata(72,-1) "T3"
             set tbdata(73,-1) "T4"
             set tbdata(74,-1) "T5"
             set tbdata(75,-1) "T6"
             set tbdata(76,-1) "T7"
             set tbdata(77,-1) "T8"
             set tbdata(78,-1) "T9"
             set tbdata(79,-1) "T10"

             set listMP {DENS NUXY}
             set labeldac "CONC"
             wm minsize $parent2 500 230

             $tableName config -colmax 1          
             $tableName config -rowmax 81
       }
        LINRdyn {
             euidl::label $childsite.lbl$labelin -height 3 \
                  -anchor w \
                  -text [msgcat::mc "Standard Piecewise Linear\
                        Material Properties for Material Number $mat"]
             wm title $parent2 [msgcat::mc "Standard Piecewise Linear\
                  Properties for Material Number $mat"]
             $parent2 configure  -helpcommand [list ans_loadhelp Hlp_lpl8]

             set numcol 1
             set numrow 31
             
             set tbdata(0,-1) "DENS"
             set tbdata(1,-1) "EX"
             set tbdata(2,-1) "NUXY"
             set tbdata(3,-1) "Yield Stress"
             set tbdata(4,-1) "Tangent Modulus"
             set tbdata(5,-1) "Effect Plast Strn"
             set tbdata(6,-1) "Strn Rate Parm (C)"
             set tbdata(7,-1) "Strn Rate Parm (P)"
             set tbdata(8,-1) "LCID  (1)"
             set tbdata(9,-1) "LCID  (2)"
             set tbdata(10,-1) "Rate1"
             set tbdata(11,-1) "LCID  (3)"
             set tbdata(12,-1) "Rate2"
             set tbdata(13,-1) "LCID  (4)"
             set tbdata(14,-1) "Rate3"
             set tbdata(15,-1) "LCID  (5)"
             set tbdata(16,-1) "Rate4"
             set tbdata(17,-1) "LCID  (6)"
             set tbdata(18,-1) "Rate5"
             set tbdata(19,-1) "LCID  (7)"
             set tbdata(20,-1) "Rate6"
             set tbdata(21,-1) "LCID  (8)"
             set tbdata(22,-1) "Rate7"
             set tbdata(23,-1) "LCID  (9)"
             set tbdata(24,-1) "Rate8"
             set tbdata(25,-1) "LCID  (10)"
             set tbdata(26,-1) "Rate9"
             set tbdata(27,-1) "LCID  (11)"
             set tbdata(28,-1) "Rate10"
             set tbdata(29,-1) "LCID  (12)"

             set listMP {DENS EX NUXY}
             set labeldac "PLAW"
             wm minsize $parent2 500 230

             $tableName config -colmax 1          
             $tableName config -rowmax 31
        }
        LINR1dyn {
             euidl::label $childsite.lbl$labelin -height 3 \
                  -anchor w \
                  -text [msgcat::mc "Modified Piecewise Linear\
                        Material Properties for Material Number $mat"]
             wm title $parent2 [msgcat::mc "Modified Piecewise Linear\
                  Properties for Material Number $mat"]
             $parent2 configure  -helpcommand [list ans_loadhelp Hlp_lpl11]

             set numcol 1
             set numrow 34
             
             set tbdata(0,-1) "DENS"
             set tbdata(1,-1) "EX"
             set tbdata(2,-1) "NUXY"
             set tbdata(3,-1) "Yield Stress"
             set tbdata(4,-1) "Tangent Modulus"
             set tbdata(5,-1) "Effect Plast Strn"
             set tbdata(6,-1) "Strn Rate Parm (C)"
             set tbdata(7,-1) "Strn Rate Parm (P)"
             set tbdata(8,-1) "LCID  (1)"
             set tbdata(9,-1) "LCID  (2)"
             set tbdata(10,-1) "Thin Plast Strain"
             set tbdata(11,-1) "Major in-plane Strn"
             set tbdata(12,-1) "NUMINT"
             set tbdata(13,-1) "Rate1"
             set tbdata(14,-1) "LCID  (3)"
             set tbdata(15,-1) "Rate2"
             set tbdata(16,-1) "LCID  (4)"
             set tbdata(17,-1) "Rate3"
             set tbdata(18,-1) "LCID  (5)"
             set tbdata(19,-1) "Rate4"
             set tbdata(20,-1) "LCID  (6)"
             set tbdata(21,-1) "Rate5"
             set tbdata(22,-1) "LCID  (7)"
             set tbdata(23,-1) "Rate6"
             set tbdata(24,-1) "LCID  (8)"
             set tbdata(25,-1) "Rate7"
             set tbdata(26,-1) "LCID  (9)"
             set tbdata(27,-1) "Rate8"
             set tbdata(28,-1) "LCID  (10)"
             set tbdata(29,-1) "Rate9"
             set tbdata(30,-1) "LCID  (11)"
             set tbdata(31,-1) "Rate10"
             set tbdata(32,-1) "LCID  (12)"

             set listMP {DENS EX NUXY}
             set labeldac "PLAW"
             wm minsize $parent2 500 230

             $tableName config -colmax 1          
             $tableName config -rowmax 34
       }
        PLAWdyn {
             euidl::label $childsite.lbl$labelin -height 3 \
                  -anchor w \
                  -text [msgcat::mc "Power Law\
                        Material Properties for Material Number $mat"]
             wm title $parent2 [msgcat::mc "Power Law\
                  Properties for Material Number $mat"]
             $parent2 configure  -helpcommand [list ans_loadhelp Hlp_lpl2]

             set numcol 1
             set numrow 10
             
             set tbdata(0,-1) "DENS"
             set tbdata(1,-1) "EX"
             set tbdata(2,-1) "NUXY"
             set tbdata(3,-1) "Strength Coeff (k)"
             set tbdata(4,-1) "Hardening Coef (n)"
             set tbdata(5,-1) "Strn Rate Parm (C)"
             set tbdata(6,-1) "Strn Rate Parm (P)"
             set tbdata(7,-1) "Initial Yield (YP)"
             set tbdata(8,-1) "Formulation   (VP)"

             set listMP {DENS EX NUXY}
             set labeldac "PLAW"
             wm minsize $parent2 500 230

             $tableName config -colmax 1          
             $tableName config -rowmax 10
       }
        HYDRdyn {
             euidl::label $childsite.lbl$labelin -height 3 \
                  -anchor w \
                  -text [msgcat::mc "Hydrodynamic\
                        Material Properties for Material Number $mat"]
             wm title $parent2 [msgcat::mc "Hydrodynamic\
                  Properties for Material Number $mat"]
             $parent2 configure  -helpcommand [list ans_loadhelp Hlp_lpl9]

             set numcol 1
             set numrow 48
             
             set tbdata(0,-1) "DENS"
             set tbdata(1,-1) "EX"
             set tbdata(2,-1) "GXY"
             set tbdata(3,-1) "Yield Stress"
             set tbdata(4,-1) "Hardening Modulus"
             set tbdata(5,-1) "Pressure Cutoff"
             set tbdata(6,-1) "Failure Strain"
             set tbdata(7,-1) "Epsilon (1)"
             set tbdata(8,-1) "Epsilon (2)"
             set tbdata(9,-1) "Epsilon (3)"
             set tbdata(10,-1) "Epsilon (4)"
             set tbdata(11,-1) "Epsilon (5)"
             set tbdata(12,-1) "Epsilon (6)"
             set tbdata(13,-1) "Epsilon (7)"
             set tbdata(14,-1) "Epsilon (8)"
             set tbdata(15,-1) "Epsilon (9)"
             set tbdata(16,-1) "Epsilon (10)"
             set tbdata(17,-1) "Epsilon (11)"
             set tbdata(18,-1) "Epsilon (12)"
             set tbdata(19,-1) "Epsilon (13)"
             set tbdata(20,-1) "Epsilon (14)"
             set tbdata(21,-1) "Epsilon (15)"
             set tbdata(22,-1) "Epsilon (16)"
             set tbdata(23,-1) "Sigma (1)"
             set tbdata(24,-1) "Sigma (2)"
             set tbdata(25,-1) "Sigma (3)"
             set tbdata(26,-1) "Sigma (4)"
             set tbdata(27,-1) "Sigma (5)"
             set tbdata(28,-1) "Sigma (6)"
             set tbdata(29,-1) "Sigma (7)"
             set tbdata(30,-1) "Sigma (8)"
             set tbdata(31,-1) "Sigma (9)"
             set tbdata(32,-1) "Sigma (10)"
             set tbdata(33,-1) "Sigma (11)"
             set tbdata(34,-1) "Sigma (12)"
             set tbdata(35,-1) "Sigma (13)"
             set tbdata(36,-1) "Sigma (14)"
             set tbdata(37,-1) "Sigma (15)"
             set tbdata(38,-1) "Sigma (16)"
             set tbdata(39,-1) "C0"
             set tbdata(40,-1) "C1"
             set tbdata(41,-1) "C2"
             set tbdata(42,-1) "C3"
             set tbdata(43,-1) "C4"
             set tbdata(44,-1) "C5"
             set tbdata(45,-1) "C6"
             set tbdata(46,-1) "E0"
             set tbdata(47,-1) "V0"

             set listMP {DENS EX GXY}
             set labeldac "PLAW"
             wm minsize $parent2 500 230

             $tableName config -colmax 1          
             $tableName config -rowmax 49
       }
        GEOdyn {
             euidl::label $childsite.lbl$labelin -height 3 \
                  -anchor w \
                  -text [msgcat::mc "Geological Cap\
                        Material Properties for Material Number $mat"]
             wm title $parent2 [msgcat::mc "Geological Cap\
                  Properties for Material Number $mat"]
             $parent2 configure  -helpcommand [list ans_loadhelp Hlp_lgca]

             set numcol 1
             set numrow 16
             
             set tbdata(0,-1) "DENS"
             set tbdata(1,-1) "GXY"
             set tbdata(2,-1) "K"
             set tbdata(3,-1) "alpha"
             set tbdata(4,-1) "theta"
             set tbdata(5,-1) "gamma"
             set tbdata(6,-1) "beta"
             set tbdata(7,-1) "Cap surf axs ratio"
             set tbdata(8,-1) "Hardn law exp (d)"
             set tbdata(9,-1) "Hardn law coef (w)"
             set tbdata(10,-1) "Hard law exp (Xo)"
             set tbdata(11,-1) "Kine Harden coeff"
             set tbdata(12,-1) "Kine Harden param"
             set tbdata(13,-1) "Formulation flag"
             set tbdata(14,-1) "Tens cutoff value"

             set listMP {DENS GXY}
             set labeldac "GCAP"
             wm minsize $parent2 500 230

             $tableName config -colmax 1          
             $tableName config -rowmax 16
       }
        THERMdyn {
             euidl::label $childsite.lbl$labelin -height 3 \
                  -anchor w \
                  -text [msgcat::mc "Elastic Viscoplastic Thermal\
                        Material Properties for Material Number $mat"]
             wm title $parent2 [msgcat::mc "Viscoplastic Thermal\
                  Properties for Material Number $mat"]
             $parent2 configure  -helpcommand [list ans_loadhelp Hlp_lpl12]

             set numcol 1
             set numrow 23
             
             set tbdata(0,-1) "DENS"
             set tbdata(1,-1) "EX"
             set tbdata(2,-1) "NUXY"
             set tbdata(3,-1) "ALPX"
             set tbdata(4,-1) "Yield Stress"
             set tbdata(5,-1) "QR1"
             set tbdata(6,-1) "CR1"
             set tbdata(7,-1) "QR2"
             set tbdata(8,-1) "CR2"
             set tbdata(9,-1) "QX1"
             set tbdata(10,-1) "CX1"
             set tbdata(11,-1) "QX2"
             set tbdata(12,-1) "CX2"
             set tbdata(13,-1) "Vk"
             set tbdata(14,-1) "Vm"
             set tbdata(15,-1) "LCID1"
             set tbdata(16,-1) "LCID2"
             set tbdata(17,-1) "LCID3"
             set tbdata(18,-1) "LCID4"
             set tbdata(19,-1) "LCID5"
             set tbdata(20,-1) "LCID6"
             set tbdata(21,-1) "LCID7"

             set listMP {DENS EX NUXY ALPX}
             set labeldac "PLAW"
             wm minsize $parent2 500 230

             $tableName config -colmax 1          
             $tableName config -rowmax 23
       }
        CELLdyn {
             euidl::label $childsite.lbl$labelin -height 3 \
                  -anchor w \
                  -text [msgcat::mc "Closed Cell\
                        Material Properties for Material Number $mat"]
             wm title $parent2 [msgcat::mc "Closed Cell\
                  Properties for Material Number $mat"]
             $parent2 configure  -helpcommand [list ans_loadhelp Hlp_lfo1]

             set numcol 1
             set numrow 9
             
             set tbdata(0,-1) "DENS"
             set tbdata(1,-1) "EX"
             set tbdata(2,-1) "Yld Strs Cnst (a)"
             set tbdata(3,-1) "Yld Strs Cnst (b)"
             set tbdata(4,-1) "Yld Strs Cnst (c)"
             set tbdata(5,-1) "Initial Foam Pres"
             set tbdata(6,-1) "Rat Foam/Poly Dens"
             set tbdata(7,-1) "Init Volmtrc Strn"

             set listMP {DENS EX}
             set labeldac "FOAM"
             wm minsize $parent2 500 230

             $tableName config -colmax 1          
             $tableName config -rowmax 9
       }
        VISCdyn {
             euidl::label $childsite.lbl$labelin -height 3 \
                  -anchor w \
                  -text [msgcat::mc "Viscous\
                        Material Properties for Material Number $mat"]
             wm title $parent2 [msgcat::mc "Viscous\
                  Properties for Material Number $mat"]
             $parent2 configure  -helpcommand [list ans_loadhelp Hlp_lfo3]

             set numcol 1
             set numrow 8
             
             set tbdata(0,-1) "DENS"
             set tbdata(1,-1) "EX"
             set tbdata(2,-1) "NUXY"
             set tbdata(3,-1) "Elastic Stiff PLAW"
             set tbdata(4,-1) "Initial Visc Coeff"
             set tbdata(5,-1) "Elastic Stiffness"
             set tbdata(6,-1) "Visc Coeff PLAW"

             set listMP {DENS EX NUXY}
             set labeldac "FOAM"
             wm minsize $parent2 500 230

             $tableName config -colmax 1          
             $tableName config -rowmax 8
       }
        DENSdyn {
             euidl::label $childsite.lbl$labelin -height 3 \
                  -anchor w \
                  -text [msgcat::mc "Low Density\
                        Material Properties for Material Number $mat"]
             wm title $parent2 [msgcat::mc "Low Density\
                  Properties for Material Number $mat"]
             $parent2 configure  -helpcommand [list ans_loadhelp Hlp_lfo2]

             set numcol 1
             set numrow 11
             
             set tbdata(0,-1) "DENS"
             set tbdata(1,-1) "EX"
             set tbdata(2,-1) "Load Curve ID"
             set tbdata(3,-1) "Tensn Cutoff Strss"
             set tbdata(4,-1) "Hyster Unload Fact"
             set tbdata(5,-1) "Decay Constant"
             set tbdata(6,-1) "Viscous Coeff"
             set tbdata(7,-1) "Shape Unload Fact"
             set tbdata(8,-1) "Failure Option"
             set tbdata(9,-1) "Bulk Viscos Flag"

             set listMP {DENS EX}
             set labeldac "FOAM"
             wm minsize $parent2 500 230

             $tableName config -colmax 1          
             $tableName config -rowmax 11
       }
        CRSHdyn {
             euidl::label $childsite.lbl$labelin -height 3 \
                  -anchor w \
                  -text [msgcat::mc "Crushable\
                        Material Properties for Material Number $mat"]
             wm title $parent2 [msgcat::mc "Crushable\
                  Properties for Material Number $mat"]
             $parent2 configure  -helpcommand [list ans_loadhelp Hlp_lfo4]

             set numcol 1
             set numrow 7
             
             set tbdata(0,-1) "DENS"
             set tbdata(1,-1) "EX"
             set tbdata(2,-1) "NUXY"
             set tbdata(3,-1) "Load Curve ID"
             set tbdata(4,-1) "Tensn Cutoff Value"
             set tbdata(5,-1) "Viscous Damp Coeff"

             set listMP {DENS EX NUXY}
             set labeldac "FOAM"
             wm minsize $parent2 500 230

             $tableName config -colmax 1          
             $tableName config -rowmax 7
       }
        HONEdyn {
             euidl::label $childsite.lbl$labelin -height 3 \
                  -anchor w \
                  -text [msgcat::mc "Honeycomb\
                        Material Properties for Material Number $mat"]
             wm title $parent2 [msgcat::mc "Honeycomb\
                  Properties for Material Number $mat"]
             $parent2 configure  -helpcommand [list ans_loadhelp Hlp_lhon]

             set numcol 1
             set numrow 21
             
             set tbdata(0,-1) "DENS"
             set tbdata(1,-1) "EX"
             set tbdata(2,-1) "NUXY"
             set tbdata(3,-1) "Yield Stress"
             set tbdata(4,-1) "Honeycomb Volume"
             set tbdata(5,-1) "Mat'l Visc Coeff"
             set tbdata(6,-1) "Elast Mod (aa dir)"
             set tbdata(7,-1) "Elast Mod (bb dir)"
             set tbdata(8,-1) "Elast Mod (cc dir)"
             set tbdata(9,-1) "Shear Mod (ab dir)"
             set tbdata(10,-1) "Shear Mod (bc dir)"
             set tbdata(11,-1) "Shear Mod (ca dir)"
             set tbdata(12,-1) "LCID (aa dir)"
             set tbdata(13,-1) "LCID (bb dir)"
             set tbdata(14,-1) "LCID (cc dir)"
             set tbdata(15,-1) "LCID (shear yield)"
             set tbdata(16,-1) "LCID (ab dir)"
             set tbdata(17,-1) "LCID (bc dir)"
             set tbdata(18,-1) "LCID (ca dir)"
             set tbdata(19,-1) "LCID (strain rate)"

             set listMP {DENS EX NUXY}
             set labeldac "HONE"
             wm minsize $parent2 500 230

             $tableName config -colmax 1          
             $tableName config -rowmax 21
       }
        JOHN1dyn {
             euidl::label $childsite.lbl$labelin -height 3 \
                  -anchor w \
                  -text [msgcat::mc "Johnson-Cook Linear Polynomial\
                        Material Properties for Material Number $mat"] \
                  -wraplength 400
             wm title $parent2 [msgcat::mc "Johnson-Cook\
                  Properties for Material Number $mat"]
             $parent2 configure  -helpcommand [list ans_loadhelp Hlp_leo1]

             set numcol 1
             set numrow 28
             
             set tbdata(0,-1) "DENS"
             set tbdata(1,-1) "EX"
             set tbdata(2,-1) "NUXY"
             set tbdata(3,-1) "A"
             set tbdata(4,-1) "B"
             set tbdata(5,-1) "N"
             set tbdata(6,-1) "C"
             set tbdata(7,-1) "M"
             set tbdata(8,-1) "Melt Temp"
             set tbdata(9,-1) "Room Temp"
             set tbdata(10,-1) "Ef P1 SR"
             set tbdata(11,-1) "Specific Heat"
             set tbdata(12,-1) "Fail Stress"
             set tbdata(13,-1) "D1"
             set tbdata(14,-1) "D2"
             set tbdata(15,-1) "D3"
             set tbdata(16,-1) "D4"
             set tbdata(17,-1) "D5"
             set tbdata(18,-1) "C0"
             set tbdata(19,-1) "C1"
             set tbdata(20,-1) "C2"
             set tbdata(21,-1) "C3"
             set tbdata(22,-1) "C4"
             set tbdata(23,-1) "C5"
             set tbdata(24,-1) "C6"
             set tbdata(25,-1) "E0"
             set tbdata(26,-1) "V0"

             set listMP {DENS EX NUXY}
             set labeldac "EOS"
             wm minsize $parent2 500 230
             wm maxsize $parent2 500 250

             $tableName config -colmax 6          
             $tableName config -rowmax 28
       }
        JOHN2dyn {
             euidl::label $childsite.lbl$labelin -height 3 \
                  -anchor w \
                  -text [msgcat::mc "Johnson-Cook Gruneisem\
                        Material Properties for Material Number $mat"]\
                  -wraplength 350
             wm title $parent2 [msgcat::mc "Johnson-Cook\
                  Properties for Material Number $mat"]
             $parent2 configure  -helpcommand [list ans_loadhelp Hlp_leo1]

             set numcol 1
             set numrow 27
             
             set tbdata(0,-1) "DENS"
             set tbdata(1,-1) "EX"
             set tbdata(2,-1) "NUXY"
             set tbdata(3,-1) "A"
             set tbdata(4,-1) "B"
             set tbdata(5,-1) "N"
             set tbdata(6,-1) "C"
             set tbdata(7,-1) "M"
             set tbdata(8,-1) "Melt Temp"
             set tbdata(9,-1) "Room Temp"
             set tbdata(10,-1) "Ef P1 SR"
             set tbdata(11,-1) "Specific Heat"
             set tbdata(12,-1) "Fail Stress"
             set tbdata(13,-1) "D1"
             set tbdata(14,-1) "D2"
             set tbdata(15,-1) "D3"
             set tbdata(16,-1) "D4"
             set tbdata(17,-1) "D5"
             set tbdata(18,-1) "C"
             set tbdata(19,-1) "S1"
             set tbdata(20,-1) "S2"
             set tbdata(21,-1) "S3"
             set tbdata(22,-1) "GAMAO"
             set tbdata(23,-1) "A"
             set tbdata(24,-1) "E(0)"
             set tbdata(25,-1) "V(0)"

             set listMP {DENS EX NUXY}
             set labeldac "EOS"
             wm minsize $parent2 500 230

             $tableName config -colmax 1          
             $tableName config -rowmax 27
       }
        JOHN3dyn {
             euidl::label $childsite.lbl$labelin -height 3 \
                  -anchor w \
                  -text [msgcat::mc "Johnson-Cook Tabulated\
                        Material Properties for Material Number $mat"]\
                  -wraplength 350
             wm title $parent2 [msgcat::mc "Johnson-Cook\
                  Properties for Material Number $mat"]
             $parent2 configure  -helpcommand [list ans_loadhelp Hlp_leo1]

             set numcol 1
             set numrow 52
             
             set tbdata(0,-1) "DENS"
             set tbdata(1,-1) "EX"
             set tbdata(2,-1) "NUXY"
             set tbdata(3,-1) "A"
             set tbdata(4,-1) "B"
             set tbdata(5,-1) "N"
             set tbdata(6,-1) "C"
             set tbdata(7,-1) "M"
             set tbdata(8,-1) "Melt Temp"
             set tbdata(9,-1) "Room Temp"
             set tbdata(10,-1) "Ef P1 SR"
             set tbdata(11,-1) "Specific Heat"
             set tbdata(12,-1) "Fail Stress"
             set tbdata(13,-1) "D1"
             set tbdata(14,-1) "D2"
             set tbdata(15,-1) "D3"
             set tbdata(16,-1) "D4"
             set tbdata(17,-1) "D5"
             set tbdata(18,-1) "GAMMA"
             set tbdata(19,-1) "E0"
             set tbdata(20,-1) "V0"
             set tbdata(21,-1) "epsilon(v1)"
             set tbdata(22,-1) "epsilon(v2)"
             set tbdata(23,-1) "epsilon(v3)"
             set tbdata(24,-1) "epsilon(v4)"
             set tbdata(25,-1) "epsilon(v5)"
             set tbdata(26,-1) "epsilon(v6)"
             set tbdata(27,-1) "epsilon(v7)"
             set tbdata(28,-1) "epsilon(v8)"
             set tbdata(29,-1) "epsilon(v9)"
             set tbdata(30,-1) "epsilon(v10)"
             set tbdata(31,-1) "C1"
             set tbdata(32,-1) "C2"
             set tbdata(33,-1) "C3"
             set tbdata(34,-1) "C4"
             set tbdata(35,-1) "C5"
             set tbdata(36,-1) "C6"
             set tbdata(37,-1) "C7"
             set tbdata(38,-1) "C8"
             set tbdata(39,-1) "C9"
             set tbdata(40,-1) "C10"
             set tbdata(41,-1) "T1"
             set tbdata(42,-1) "T2"
             set tbdata(43,-1) "T3"
             set tbdata(44,-1) "T4"
             set tbdata(45,-1) "T5"
             set tbdata(46,-1) "T6"
             set tbdata(47,-1) "T7"
             set tbdata(48,-1) "T8"
             set tbdata(49,-1) "T9"
             set tbdata(50,-1) "T10"

             set listMP {DENS EX NUXY}
             set labeldac "EOS"
             wm minsize $parent2 500 230

             $tableName config -colmax 1          
             $tableName config -rowmax 52
       }
        NULL1dyn {
             euidl::label $childsite.lbl$labelin -height 3 \
                  -anchor w \
                  -text [msgcat::mc "Null Linear Polynomial \
                        Material Properties for Material Number $mat"]\
                  -wraplength 350
             wm title $parent2 [msgcat::mc "Null\
                  Properties for Material Number $mat"]
             $parent2 configure  -helpcommand [list ans_loadhelp Hlp_leo2]

             set numcol 1
             set numrow 17
             
             set tbdata(0,-1) "DENS"
             set tbdata(1,-1) "EX"
             set tbdata(2,-1) "NUXY"
             set tbdata(3,-1) "Pressure Cutoff"
             set tbdata(4,-1) "Viscosity Coeff"
             set tbdata(5,-1) "Relative Vol-tensn"
             set tbdata(6,-1) "Relative Vol-comp"
             set tbdata(7,-1) "C0"
             set tbdata(8,-1) "C1"
             set tbdata(9,-1) "C2"
             set tbdata(10,-1) "C3"
             set tbdata(11,-1) "C4"
             set tbdata(12,-1) "C5"
             set tbdata(13,-1) "C6"
             set tbdata(14,-1) "E0"
             set tbdata(15,-1) "V0"

             set listMP {DENS EX NUXY}
             set labeldac "EOS"
             wm minsize $parent2 500 230

             $tableName config -colmax 1          
             $tableName config -rowmax 17
       }
        NULL2dyn {
             euidl::label $childsite.lbl$labelin -height 3 \
                  -anchor w \
                  -text [msgcat::mc "Null Gruneisem\
                        Material Properties for Material Number $mat"]\
                  -wraplength 400
             wm title $parent2 [msgcat::mc "Null\
                  Properties for Material Number $mat"]
             $parent2 configure  -helpcommand [list ans_loadhelp Hlp_leo2]

             set numcol 1
             set numrow 16
             
             set tbdata(0,-1) "DENS"
             set tbdata(1,-1) "EX"
             set tbdata(2,-1) "NUXY"
             set tbdata(3,-1) "Pressure Cutoff"
             set tbdata(4,-1) "Viscosity Coeff"
             set tbdata(5,-1) "Relative Vol-tensn"
             set tbdata(6,-1) "Relative Vol-comp"
             set tbdata(7,-1) "C"
             set tbdata(8,-1) "S1"
             set tbdata(9,-1) "S2"
             set tbdata(10,-1) "S3"
             set tbdata(11,-1) "GAMA0"
             set tbdata(12,-1) "A"
             set tbdata(13,-1) "Init Rel Ener E(0)"
             set tbdata(14,-1) "Init Rel Vol V(0)"

             set listMP {DENS EX NUXY}
             set labeldac "EOS"
             wm minsize $parent2 500 230

             $tableName config -colmax 1          
             $tableName config -rowmax 16
       }
        NULL3dyn {
             euidl::label $childsite.lbl$labelin -height 3 \
                  -anchor w \
                  -text [msgcat::mc "Null Tabulated\
                        Material Properties for Material Number $mat"]\
                  -wraplength 400
             wm title $parent2 [msgcat::mc "Null\
                  Properties for Material Number $mat"]
             $parent2 configure  -helpcommand [list ans_loadhelp Hlp_leo2]

             set numcol 1
             set numrow 41
             
             set tbdata(0,-1) "DENS"
             set tbdata(1,-1) "EX"
             set tbdata(2,-1) "NUXY"
             set tbdata(3,-1) "Pressure Cutoff"
             set tbdata(4,-1) "Viscosity Coeff"
             set tbdata(5,-1) "Relative Vol-tensn"
             set tbdata(6,-1) "Relative Vol-comp"
             set tbdata(7,-1) "GAMMA"
             set tbdata(8,-1) "E0"
             set tbdata(9,-1) "V0"
             set tbdata(10,-1) "epsilon(v1)"
             set tbdata(11,-1) "epsilon(v2)"
             set tbdata(12,-1) "epsilon(v3)"
             set tbdata(13,-1) "epsilon(v4)"
             set tbdata(14,-1) "epsilon(v5)"
             set tbdata(15,-1) "epsilon(v6)"
             set tbdata(16,-1) "epsilon(v7)"
             set tbdata(17,-1) "epsilon(v8)"
             set tbdata(18,-1) "epsilon(v9)"
             set tbdata(19,-1) "epsilon(v10)"
             set tbdata(20,-1) "C1"
             set tbdata(21,-1) "C2"
             set tbdata(22,-1) "C3"
             set tbdata(23,-1) "C4"
             set tbdata(24,-1) "C5"
             set tbdata(25,-1) "C6"
             set tbdata(26,-1) "C7"
             set tbdata(27,-1) "C8"
             set tbdata(28,-1) "C9"
             set tbdata(29,-1) "C10"
             set tbdata(30,-1) "T1"
             set tbdata(31,-1) "T2"
             set tbdata(32,-1) "T3"
             set tbdata(33,-1) "T4"
             set tbdata(34,-1) "T5"
             set tbdata(35,-1) "T6"
             set tbdata(36,-1) "T7"
             set tbdata(37,-1) "T8"
             set tbdata(38,-1) "T9"
             set tbdata(39,-1) "T10"

             set listMP {DENS EX NUXY}
             set labeldac "EOS"
             wm minsize $parent2 500 230

             $tableName config -colmax 1          
             $tableName config -rowmax 41
       }
        ZERI1dyn {
             euidl::label $childsite.lbl$labelin -height 3 \
                  -anchor w \
                  -text [msgcat::mc "Zerilli-Armstrong  Linear Polynomial\
                        Material Properties for Material Number $mat"]\
                  -wraplength 400
             wm title $parent2 [msgcat::mc "Zerilli-Armstrong\
                  Properties for Material Number $mat"]
             $parent2 configure  -helpcommand [list ans_loadhelp Hlp_leo3]

             set numcol 1
             set numrow 32
             
             set tbdata(0,-1) "DENS"
             set tbdata(1,-1) "EX"
             set tbdata(2,-1) "NUXY"
             set tbdata(3,-1) "Initial Strain"
             set tbdata(4,-1) "Strn comp-BBC matl"
             set tbdata(5,-1) "Room Temp"
             set tbdata(6,-1) "Pressure Cutoff"
             set tbdata(7,-1) "Spall Type"
             set tbdata(8,-1) "F1"
             set tbdata(9,-1) "F2"
             set tbdata(10,-1) "F3"
             set tbdata(11,-1) "F4"
             set tbdata(12,-1) "F5"
             set tbdata(13,-1) "F6"
             set tbdata(14,-1) "Failure Strain"
             set tbdata(15,-1) "B1"
             set tbdata(16,-1) "B2"
             set tbdata(17,-1) "B3"
             set tbdata(18,-1) "G1"
             set tbdata(19,-1) "G2"
             set tbdata(20,-1) "G3"
             set tbdata(21,-1) "G4"
             set tbdata(22,-1) "C0"
             set tbdata(23,-1) "C1"
             set tbdata(24,-1) "C2"
             set tbdata(25,-1) "C3"
             set tbdata(26,-1) "C4"
             set tbdata(27,-1) "C5"
             set tbdata(28,-1) "C6"
             set tbdata(29,-1) "E0"
             set tbdata(30,-1) "V0"

             set listMP {DENS EX NUXY}
             set labeldac "EOS"
             wm minsize $parent2 500 230

             $tableName config -colmax 1          
             $tableName config -rowmax 32
       }
        ZERI2dyn {
             euidl::label $childsite.lbl$labelin -height 3 \
                  -anchor w \
                  -text [msgcat::mc "Zerilli-Armstrong Gruneisem\
                        Material Properties for Material Number $mat"]\
                  -wraplength 400
             wm title $parent2 [msgcat::mc "Zerilli-Armstrong\
                  Properties for Material Number $mat"]
             $parent2 configure  -helpcommand [list ans_loadhelp Hlp_leo3]

             set numcol 1
             set numrow 31
             
             set tbdata(0,-1) "DENS"
             set tbdata(1,-1) "EX"
             set tbdata(2,-1) "NUXY"
             set tbdata(3,-1) "Initial Strain"
             set tbdata(4,-1) "Strn comp-BBC matl"
             set tbdata(5,-1) "Room Temp"
             set tbdata(6,-1) "Pressure Cutoff"
             set tbdata(7,-1) "Spall Type"
             set tbdata(8,-1) "F1"
             set tbdata(9,-1) "F2"
             set tbdata(10,-1) "F3"
             set tbdata(11,-1) "F4"
             set tbdata(12,-1) "F5"
             set tbdata(13,-1) "F6"
             set tbdata(14,-1) "Failure Strain"
             set tbdata(15,-1) "B1"
             set tbdata(16,-1) "B2"
             set tbdata(17,-1) "B3"
             set tbdata(18,-1) "G1"
             set tbdata(19,-1) "G2"
             set tbdata(20,-1) "G3"
             set tbdata(21,-1) "G4"
             set tbdata(22,-1) "C"
             set tbdata(23,-1) "S1"
             set tbdata(24,-1) "S2"
             set tbdata(25,-1) "S3"
             set tbdata(26,-1) "GAMMA0"
             set tbdata(27,-1) "A"
             set tbdata(28,-1) "E0"
             set tbdata(29,-1) "V0"

             set listMP {DENS EX NUXY}
             set labeldac "EOS"
             wm minsize $parent2 500 230

             $tableName config -colmax 1          
             $tableName config -rowmax 31
       }
        ZERI3dyn {
             euidl::label $childsite.lbl$labelin -height 3 \
                  -anchor w \
                  -text [msgcat::mc "Zerilli-Armstrong Tabulated\
                        Material Properties for Material Number $mat"]\
                  -wraplength 400
             wm title $parent2 [msgcat::mc "Zerilli-Armstrong\
                  Properties for Material Number $mat"]
             $parent2 configure  -helpcommand [list ans_loadhelp Hlp_leo3]

             set numcol 1
             set numrow 56
             
             set tbdata(0,-1) "DENS"
             set tbdata(1,-1) "EX"
             set tbdata(2,-1) "NUXY"
             set tbdata(3,-1) "Initial Strain"
             set tbdata(4,-1) "Strn comp-BBC matl"
             set tbdata(5,-1) "Room Temp"
             set tbdata(6,-1) "Pressure Cutoff"
             set tbdata(7,-1) "Spall Type"
             set tbdata(8,-1) "F1"
             set tbdata(9,-1) "F2"
             set tbdata(10,-1) "F3"
             set tbdata(11,-1) "F4"
             set tbdata(12,-1) "F5"
             set tbdata(13,-1) "F6"
             set tbdata(14,-1) "Failure Strain"
             set tbdata(15,-1) "B1"
             set tbdata(16,-1) "B2"
             set tbdata(17,-1) "B3"
             set tbdata(18,-1) "G1"
             set tbdata(19,-1) "G2"
             set tbdata(20,-1) "G3"
             set tbdata(21,-1) "G4"
             set tbdata(22,-1) "GAMMA"
             set tbdata(23,-1) "E0"
             set tbdata(24,-1) "V0"
             set tbdata(25,-1) "epsilon(v1)"
             set tbdata(26,-1) "epsilon(v2)"
             set tbdata(27,-1) "epsilon(v3)"
             set tbdata(28,-1) "epsilon(v4)"
             set tbdata(29,-1) "epsilon(v5)"
             set tbdata(30,-1) "epsilon(v6)"
             set tbdata(31,-1) "epsilon(v7)"
             set tbdata(32,-1) "epsilon(v8)"
             set tbdata(33,-1) "epsilon(v9)"
             set tbdata(34,-1) "epsilon(v10)"
             set tbdata(35,-1) "C1"
             set tbdata(36,-1) "C2"
             set tbdata(37,-1) "C3"
             set tbdata(38,-1) "C4"
             set tbdata(39,-1) "C5"
             set tbdata(40,-1) "C6"
             set tbdata(41,-1) "C7"
             set tbdata(42,-1) "C8"
             set tbdata(43,-1) "C9"
             set tbdata(44,-1) "C10"
             set tbdata(45,-1) "T1"
             set tbdata(46,-1) "T2"
             set tbdata(47,-1) "T3"
             set tbdata(48,-1) "T4"
             set tbdata(49,-1) "T5"
             set tbdata(50,-1) "T6"
             set tbdata(51,-1) "T7"
             set tbdata(52,-1) "T8"
             set tbdata(53,-1) "T9"
             set tbdata(54,-1) "T10"

             set listMP {DENS EX NUXY}
             set labeldac "EOS"
             wm minsize $parent2 500 230

             $tableName config -colmax 1          
             $tableName config -rowmax 56
       }
        STEN1dyn {
             euidl::label $childsite.lbl$labelin -height 3 \
                  -anchor w \
                  -text [msgcat::mc "Steinberg Linear Polynomial\
                        Material Properties for Material Number $mat"]\
                  -wraplength 400
             wm title $parent2 [msgcat::mc "Steinberg\
                  Properties for Material Number $mat"]
             $parent2 configure  -helpcommand [list ans_loadhelp Hlp_leo5]

             set numcol 1
             set numrow 41
             
             set tbdata(0,-1) "DENS"
             set tbdata(1,-1) "GXY"
             set tbdata(2,-1) "NUXY"
             set tbdata(3,-1) "Initial Yld Strss"
             set tbdata(4,-1) "Hardening Coef"
             set tbdata(5,-1) "Hardening Parm"
             set tbdata(6,-1) "Initial Plast Strn"
             set tbdata(7,-1) "Maximum Yld Stress"
             set tbdata(8,-1) "Shear Modulus Parm"
             set tbdata(9,-1) "Yield Strength Parm"
             set tbdata(10,-1) "Yield Strength Parm"
             set tbdata(11,-1) "Exponential Coeff"
             set tbdata(12,-1) "Atomic Weight"
             set tbdata(13,-1) "Absolute Melt Temp"
             set tbdata(14,-1) "Melting Temp Param"
             set tbdata(15,-1) "Melting Temp Param"
             set tbdata(16,-1) "Pressure Cutoff"
             set tbdata(17,-1) "Spall Type"
             set tbdata(18,-1) "Cold Cmp Enrg Flag"
             set tbdata(19,-1) "Min Bulk Modulus"
             set tbdata(20,-1) "Max Bulk Modulus"
             set tbdata(21,-1) "Cold Cmp Cnst- EC0"
             set tbdata(22,-1) "Cold Cmp Cnst- EC1"
             set tbdata(23,-1) "Cold Cmp Cnst- EC2"
             set tbdata(24,-1) "Cold Cmp Cnst- EC3"
             set tbdata(25,-1) "Cold Cmp Cnst- EC4"
             set tbdata(26,-1) "Cold Cmp Cnst- EC5"
             set tbdata(27,-1) "Cold Cmp Cnst- EC6"
             set tbdata(28,-1) "Cold Cmp Cnst- EC7"
             set tbdata(29,-1) "Cold Cmp Cnst- EC8"
             set tbdata(30,-1) "Cold Cmp Cnst- EC9"
             set tbdata(31,-1) "EOS Constant - C0"
             set tbdata(32,-1) "EOS Constant - C1"
             set tbdata(33,-1) "EOS Constant - C2"
             set tbdata(34,-1) "EOS Constant - C3"
             set tbdata(35,-1) "EOS Constant - C4"
             set tbdata(36,-1) "EOS Constant - C5"
             set tbdata(37,-1) "EOS Constant - C6"
             set tbdata(38,-1) "E0"
             set tbdata(39,-1) "V0"

             set listMP {DENS GXY NUXY}
             set labeldac "EOS"
             wm minsize $parent2 500 230

             $tableName config -colmax 1          
             $tableName config -rowmax 41
             $tableName width -1 19
       }
        STEN2dyn {
             euidl::label $childsite.lbl$labelin -height 3 \
                  -anchor w \
                  -text [msgcat::mc "Steinberg Gruneisem\
                        Material Properties for Material Number $mat"]\
                  -wraplength 350
             wm title $parent2 [msgcat::mc "Steinberg\
                  Properties for Material Number $mat"]
             $parent2 configure  -helpcommand [list ans_loadhelp Hlp_leo5]

             set numcol 1
             set numrow 40
             
             set tbdata(0,-1) "DENS"
             set tbdata(1,-1) "GXY"
             set tbdata(2,-1) "NUXY"
             set tbdata(3,-1) "Initial Yld Strss"
             set tbdata(4,-1) "Hardening Coef"
             set tbdata(5,-1) "Hardening Parm"
             set tbdata(6,-1) "Initial Plast Strn"
             set tbdata(7,-1) "Maximum Yld Stress"
             set tbdata(8,-1) "Shear Modulus Parm"
             set tbdata(9,-1) "Yield Strength Parm"
             set tbdata(10,-1) "Yield Strength Parm"
             set tbdata(11,-1) "Exponential Coeff"
             set tbdata(12,-1) "Atomic Weight"
             set tbdata(13,-1) "Absolute Melt Temp"
             set tbdata(14,-1) "Melting Temp Param"
             set tbdata(15,-1) "Melting Temp Param"
             set tbdata(16,-1) "Pressure Cutoff"
             set tbdata(17,-1) "Spall Type"
             set tbdata(18,-1) "Cold Cmp Enrg Flag"
             set tbdata(19,-1) "Min Bulk Modulus"
             set tbdata(20,-1) "Max Bulk Modulus"
             set tbdata(21,-1) "Cold Cmp Cnst- EC0"
             set tbdata(22,-1) "Cold Cmp Cnst- EC1"
             set tbdata(23,-1) "Cold Cmp Cnst- EC2"
             set tbdata(24,-1) "Cold Cmp Cnst- EC3"
             set tbdata(25,-1) "Cold Cmp Cnst- EC4"
             set tbdata(26,-1) "Cold Cmp Cnst- EC5"
             set tbdata(27,-1) "Cold Cmp Cnst- EC6"
             set tbdata(28,-1) "Cold Cmp Cnst- EC7"
             set tbdata(29,-1) "Cold Cmp Cnst- EC8"
             set tbdata(30,-1) "Cold Cmp Cnst- EC9"
             set tbdata(31,-1) "EOS Constant - C"
             set tbdata(32,-1) "EOS Constant - S1"
             set tbdata(33,-1) "EOS Constant - S2"
             set tbdata(34,-1) "EOS Constant - S3"
             set tbdata(35,-1) "GAMMA0"
             set tbdata(36,-1) "A"
             set tbdata(37,-1) "E0"
             set tbdata(38,-1) "V0"

             set listMP {DENS GXY NUXY}
             set labeldac "EOS"
             wm minsize $parent2 500 230

             $tableName config -colmax 1          
             $tableName config -rowmax 40
             $tableName width -1 19
       }
        STEN3dyn {
             euidl::label $childsite.lbl$labelin -height 3 \
                  -anchor w \
                  -text [msgcat::mc "Steinberg Tabulated\
                        Material Properties for Material Number $mat"]\
                  -wraplength 350
             wm title $parent2 [msgcat::mc "Steinberg\
                  Properties for Material Number $mat"]
             $parent2 configure  -helpcommand [list ans_loadhelp Hlp_leo5]

             set numcol 1
             set numrow 65
             
             set tbdata(0,-1) "DENS"
             set tbdata(1,-1) "GXY"
             set tbdata(2,-1) "NUXY"
             set tbdata(3,-1) "Initial Yld Strss"
             set tbdata(4,-1) "Hardening Coef"
             set tbdata(5,-1) "Hardening Parm"
             set tbdata(6,-1) "Initial Plast Strn"
             set tbdata(7,-1) "Maximum Yld Stress"
             set tbdata(8,-1) "Shear Modulus Parm"
             set tbdata(9,-1) "Yield Strength Parm"
             set tbdata(10,-1) "Yield Strength Parm"
             set tbdata(11,-1) "Exponential Coeff"
             set tbdata(12,-1) "Atomic Weight"
             set tbdata(13,-1) "Absolute Melt Temp"
             set tbdata(14,-1) "Melting Temp Param"
             set tbdata(15,-1) "Melting Temp Param"
             set tbdata(16,-1) "Pressure Cutoff"
             set tbdata(17,-1) "Spall Type"
             set tbdata(18,-1) "Cold Cmp Enrg Flag"
             set tbdata(19,-1) "Min Bulk Modulus"
             set tbdata(20,-1) "Max Bulk Modulus"
             set tbdata(21,-1) "Cold Cmp Cnst- EC0"
             set tbdata(22,-1) "Cold Cmp Cnst- EC1"
             set tbdata(23,-1) "Cold Cmp Cnst- EC2"
             set tbdata(24,-1) "Cold Cmp Cnst- EC3"
             set tbdata(25,-1) "Cold Cmp Cnst- EC4"
             set tbdata(26,-1) "Cold Cmp Cnst- EC5"
             set tbdata(27,-1) "Cold Cmp Cnst- EC6"
             set tbdata(28,-1) "Cold Cmp Cnst- EC7"
             set tbdata(29,-1) "Cold Cmp Cnst- EC8"
             set tbdata(30,-1) "Cold Cmp Cnst- EC9"
             set tbdata(31,-1) "GAMMA"
             set tbdata(32,-1) "E0"
             set tbdata(33,-1) "V0"
             set tbdata(34,-1) "EOS Constant - e1"
             set tbdata(35,-1) "EOS Constant - e2"
             set tbdata(36,-1) "EOS Constant - e3"
             set tbdata(37,-1) "EOS Constant - e4"
             set tbdata(38,-1) "EOS Constant - e5"
             set tbdata(39,-1) "EOS Constant - e6"
             set tbdata(40,-1) "EOS Constant - e7"
             set tbdata(41,-1) "EOS Constant - e8"
             set tbdata(42,-1) "EOS Constant - e9"
             set tbdata(43,-1) "EOS Constant - e10"
             set tbdata(44,-1) "EOS Constant - c1"
             set tbdata(45,-1) "EOS Constant - c2"
             set tbdata(46,-1) "EOS Constant - c3"
             set tbdata(47,-1) "EOS Constant - c4"
             set tbdata(48,-1) "EOS Constant - c5"
             set tbdata(49,-1) "EOS Constant - c6"
             set tbdata(50,-1) "EOS Constant - c7"
             set tbdata(51,-1) "EOS Constant - c8"
             set tbdata(52,-1) "EOS Constant - c9"
             set tbdata(53,-1) "EOS Constant - c10"
             set tbdata(54,-1) "EOS Constant - T1"
             set tbdata(55,-1) "EOS Constant - T2"
             set tbdata(56,-1) "EOS Constant - T3"
             set tbdata(57,-1) "EOS Constant - T4"
             set tbdata(58,-1) "EOS Constant - T5"
             set tbdata(59,-1) "EOS Constant - T6"
             set tbdata(60,-1) "EOS Constant - T7"
             set tbdata(61,-1) "EOS Constant - T8"
             set tbdata(62,-1) "EOS Constant - T9"
             set tbdata(63,-1) "EOS Constant - T10"

             set listMP {DENS GXY NUXY}
             set labeldac "EOS"
             wm minsize $parent2 500 230

             $tableName config -colmax 1          
             $tableName config -rowmax 65
             $tableName width -1 19
       }
        BAMMdyn {
             euidl::label $childsite.lbl$labelin -height 3 \
                  -anchor w \
                  -text [msgcat::mc "Bamman\
                        Material Properties for Material Number $mat"]
             wm title $parent2 [msgcat::mc "Bamman\
                  Properties for Material Number $mat"]
             $parent2 configure  -helpcommand [list ans_loadhelp Hlp_leo4]

             set numcol 1
             set numrow 32
             
             set tbdata(0,-1) "DENS"
             set tbdata(1,-1) "EX"
             set tbdata(2,-1) "NUXY"
             set tbdata(3,-1) "Initial Temp"
             set tbdata(4,-1) "Heat Gen Coeff"
             set tbdata(5,-1) "C1"
             set tbdata(6,-1) "C2"
             set tbdata(7,-1) "C3"
             set tbdata(8,-1) "C4"
             set tbdata(9,-1) "C5"
             set tbdata(10,-1) "C6"
             set tbdata(11,-1) "C7"
             set tbdata(12,-1) "C8"
             set tbdata(13,-1) "C9"
             set tbdata(14,-1) "C10"
             set tbdata(15,-1) "C11"
             set tbdata(16,-1) "C12"
             set tbdata(17,-1) "C13"
             set tbdata(18,-1) "C14"
             set tbdata(19,-1) "C15"
             set tbdata(20,-1) "C16"
             set tbdata(21,-1) "C17"
             set tbdata(22,-1) "C18"
             set tbdata(23,-1) "C19"
             set tbdata(24,-1) "C20"
             set tbdata(25,-1) "A1"
             set tbdata(26,-1) "A2"
             set tbdata(27,-1) "A3"
             set tbdata(28,-1) "A4"
             set tbdata(29,-1) "A5"
             set tbdata(30,-1) "A6"

             set listMP {DENS EX NUXY}
             set labeldac "EOS"
             wm minsize $parent2 500 230

             $tableName config -colmax 1          
             $tableName config -rowmax 32
       }
        SPNGdyn {
             euidl::label $childsite.lbl$labelin -height 3 \
                  -anchor w \
                  -text [msgcat::mc "Linear Elastic Spring\
                        Material Properties for Material Number $mat"]
             wm title $parent2 [msgcat::mc "Linear Elastic Spring\
                  Properties for Material Number $mat"]
             $parent2 configure  -helpcommand [list ans_loadhelp Hlp_ldi0]

             set numcol 1
             set numrow 2
             
             set tbdata(0,-1) "Spring Constant"

             set listMP {}
             set labeldac "DISC"
             wm minsize $parent2 500 230

             $tableName config -colmax 1          
             $tableName config -rowmax 2
       }
        NLSPdyn {
             euidl::label $childsite.lbl$labelin -height 3 \
                  -anchor w \
                  -text [msgcat::mc "General Nonlinear Spring\
                        Material Properties for Material Number $mat"]
             wm title $parent2 [msgcat::mc "General Nonlinear Spring\
                  Properties for Material Number $mat"]
             $parent2 configure  -helpcommand [list ans_loadhelp Hlp_ldi5]

             set numcol 1
             set numrow 6
             
             set tbdata(0,-1) "LCID (loading)"
             set tbdata(1,-1) "LCID (unloading)"
             set tbdata(2,-1) "Hardening Parm"
             set tbdata(3,-1) "Yield Force (tens)"
             set tbdata(4,-1) "Yield Force (comp)"

             set listMP {}
             set labeldac "DISC"
             wm minsize $parent2 500 230

             $tableName config -colmax 1          
             $tableName config -rowmax 6
       }
        NLESdyn {
             euidl::label $childsite.lbl$labelin -height 3 \
                  -anchor w \
                  -text [msgcat::mc "Nonlinear Elastic Spring\
                        Material Properties for Material Number $mat"]
             wm title $parent2 [msgcat::mc "Nonlinear Elastic Spring\
                  Properties for Material Number $mat"]
             $parent2 configure  -helpcommand [list ans_loadhelp Hlp_ldi3]

             set numcol 1
             set numrow 3
             
             set tbdata(0,-1) "Load Curve ID"
             set tbdata(1,-1) "Optional LCID"

             set listMP {}
             wm minsize $parent2 500 230
             set labeldac "DISC"
             $tableName config -colmax 1          
             $tableName config -rowmax 3
       }
        ELSPdyn {
             euidl::label $childsite.lbl$labelin -height 3 \
                  -anchor w \
                  -text [msgcat::mc "Elastoplastic Spring\
                        Material Properties for Material Number $mat"]
             wm title $parent2 [msgcat::mc "Elastoplastic Spring\
                  Properties for Material Number $mat"]
             $parent2 configure  -helpcommand [list ans_loadhelp Hlp_ldi2]

             set numcol 1
             set numrow 4
             
             set tbdata(0,-1) "Elastic Stiffness"
             set tbdata(1,-1) "Tangent Stiffness"
             set tbdata(2,-1) "Yield Force/Moment"

             set listMP {}
             wm minsize $parent2 500 230
             set labeldac "DISC"
             $tableName config -colmax 1          
             $tableName config -rowmax 4
       }
        INSPdyn {
             euidl::label $childsite.lbl$labelin -height 3 \
                  -anchor w \
                  -text [msgcat::mc "Inelastic Spring\
                        Material Properties for Material Number $mat"]
             wm title $parent2 [msgcat::mc "Inelastic Spring\
                  Properties for Material Number $mat"]
             $parent2 configure  -helpcommand [list ans_loadhelp Hlp_ldi7]

             set numcol 1
             set numrow 4
             
             set tbdata(0,-1) "Load Curve ID"
             set tbdata(1,-1) "Unloading Stffness"
             set tbdata(2,-1) "Compress/Tens Flag"

             set listMP {}
             wm minsize $parent2 500 230
             set labeldac "DISC"
             $tableName config -colmax 1          
             $tableName config -rowmax 4
       }
        MAXSdyn {
             euidl::label $childsite.lbl$labelin -height 3 \
                  -anchor w \
                  -text [msgcat::mc "Maxwell Viscosity Spring\
                        Material Properties for Material Number $mat"]
             wm title $parent2 [msgcat::mc "Maxwell Viscosity Spring\
                  Properties for Material Number $mat"]
             $parent2 configure  -helpcommand [list ans_loadhelp Hlp_ldi6]

             set numcol 1
             set numrow 7
             
             set tbdata(0,-1) "Short Time Stiff"
             set tbdata(1,-1) "Long Time Stiff"
             set tbdata(2,-1) "Decay Parameter"
             set tbdata(3,-1) "Cutoff Time"
             set tbdata(4,-1) "For/Mom aft Cutoff"
             set tbdata(5,-1) "Time Implement Opt"

             set listMP {}
             wm minsize $parent2 500 230
             set labeldac "DISC"
             $tableName config -colmax 1          
             $tableName config -rowmax 7
       }
        LNVIdyn {
             euidl::label $childsite.lbl$labelin -height 3 \
                  -anchor w \
                  -text [msgcat::mc "Linear Viscosity Damper\
                        Material Properties for Material Number $mat"]
             wm title $parent2 [msgcat::mc "Linear Viscosity Damper\
                  Properties for Material Number $mat"]
             $parent2 configure  -helpcommand [list ans_loadhelp Hlp_ldi1]

             set numcol 1
             set numrow 2
             
             set tbdata(0,-1) "Damping Constant"

             set listMP {}
             wm minsize $parent2 500 230
             set labeldac "DISC"
             $tableName config -colmax 1          
             $tableName config -rowmax 2
       }
        NLVIdyn {
             euidl::label $childsite.lbl$labelin -height 3 \
                  -anchor w \
                  -text [msgcat::mc "Nonlinear Viscosity Damper\
                        Material Properties for Material Number $mat"]
             wm title $parent2 [msgcat::mc "Nonlinear Viscosity Damper\
                  Properties for Material Number $mat"]
             $parent2 configure  -helpcommand [list ans_loadhelp Hlp_ldi4]

             set numcol 1
             set numrow 2
             
             set tbdata(0,-1) "Load Curve ID"

             set listMP {}
             wm minsize $parent2 500 230
             set labeldac "DISC"
             $tableName config -colmax 1          
             $tableName config -rowmax 2
       }
        CABLdyn {
             euidl::label $childsite.lbl$labelin -height 3 \
                  -anchor w \
                  -text [msgcat::mc "Cable\
                        Material Properties for Material Number $mat"]
             wm title $parent2 [msgcat::mc "Cable\
                  Properties for Material Number $mat"]
             $parent2 configure  -helpcommand [list ans_loadhelp Hlp_lcab]

             set numcol 1
             set numrow 4
             
             set tbdata(0,-1) "DENS"
             set tbdata(1,-1) "EX"
             set tbdata(2,-1) "Load Curve ID"

             set listMP {DENS EX}
             wm minsize $parent2 500 230
             set labeldac "CABL"
             $tableName config -colmax 1          
             $tableName config -rowmax 4
       }
        RIGIdyn {
             euidl::label $childsite.lbl$labelin -height 3 \
                  -anchor w \
                  -text [msgcat::mc "Rigid\
                        Material Properties for Material Number $mat"]
             wm title $parent2 [msgcat::mc "Rigid\
                  Properties for Material Number $mat"]
             $parent2 configure  -helpcommand [list ans_loadhelp Hlp_lrig]

             set numcol 1
             set numrow 4
             
             set tbdata(0,-1) "DENS"
             set tbdata(1,-1) "EX"
             set tbdata(2,-1) "NUXY"

             euidl::label $childsite.lblopt$labelin -height 3 -anchor sw \
                    -text [msgcat::mc "Translational Constraint Parameter"]
             euidl::combobox  $childsite.cmb$labelin -width 20  \
                 -variable [scope tbdata(3,0)]
             $childsite.cmb$labelin insert list end\
                 [list {No constraints}     0\
                       {X displacement}     1\
                       {Y displacement}     2\
                       {Z displacement}     3\
                       {X and Y disps.}     4\
                       {Y and Z disps.}     5\
                       {Z and X disps.}     6\
                       {All disps.}         7\
                 ]
             set check [ans_getvalue RIGI,$mat,EXIS]
             if {$check == 1} {
                set tbdata(3,0) [ans_getvalue RIGI,$mat]
             } else {
                set tbdata(3,0) 0      
             }
             euidl::label $childsite.lblopt1$labelin -height 3 -anchor w \
                    -text [msgcat::mc "Rotational Constraint Parameter"]
             euidl::combobox  $childsite.cmb1$labelin -width 20  \
                 -variable [scope tbdata(4,0)]
             $childsite.cmb1$labelin insert list end\
                 [list {No constraints}     0\
                       {X rotation}         1\
                       {Y rotation}         2\
                       {Z rotation}         3\
                       {X and Y rotate}     4\
                       {Y and Z rotate}     5\
                       {Z and X rotate}     6\
                       {All rotations}      7\
                 ]
             if {$check == 1} {
                set tbdata(4,0) [ans_getvalue RIGI,$mat,CONST,1,CONST,2]
             } else {
                set tbdata(4,0) 0      
             }

             grid $childsite.lblopt$labelin -sticky sw -column 0 -row 5 \
               -columnspan 3
             grid $childsite.cmb$labelin -sticky sw -column 4  -row 5 \
               -columnspan 2

             grid $childsite.lblopt1$labelin -sticky w -column 0 -row 6 \
               -columnspan 3
             grid $childsite.cmb1$labelin -sticky w -column 4  -row 6 \
               -columnspan 2

             set listMP {DENS EX NUXY}
             set labeldac "RIGI"
             wm minsize $parent2 500 230

             $tableName config -colmax 1          
             $tableName config -rowmax 4
       }
     }


     set listTB {ANEL MOONEY EVIS BISO BKIN PLAW\
                 COMP CONCR GCAP FOAM HONE EOS\
                 ANIS DISC CABL RIGI FLUI}
         
     # initialize table
     if {$labelin != "BISOtmp"} {
        for {set j -1} {$j < [expr $numrow - 1]} {incr j 1} {
           set tbdata($j,0) ""
        }
        # get MP values
        set ii 0
        foreach lab $listMP {
           set check [ans_getvalue $lab,$mat,EXIS]
           if {$check > 0} {
              set tbdata($ii,0)  [ans_getvalue $lab,$mat]
              set tbdata($ii,0)  [format "%-10.5G" $tbdata($ii,0)]
              set tbdata($ii,0) [string trimright $tbdata($ii,0)]
           } else {
              set tbdata($ii,0) ""
           }
           set ii [expr $ii+1]
        }

         # get TB values
         if {$labelin == "ORTHdyn"} {
           set check [ans_getvalue ORTHO,$mat,EXIS]
              if {$check == 1} {
                 set tbdata(10,0) [ans_getvalue ORTHO,$mat]
              } else {
                 set tbdata(10,0) 0
              }
          }
         
         if {$labeldac != "ORTH" && $labeldac != "ISOT" \
             && $labeldac != "BLAT"} {
           set jj 1
           set tb [ans_getvalue $labeldac,$mat,EXIS]
           if {$tb == 1} {
               set jtemp 46
               if {$labelin == "ANELdyn"} {
                  set tbdata($ii,0) [ans_getvalue ORTHO,$mat]
                  set ii [expr $ii + 1]
               }
            
               for {set j $ii} {$j < [expr $numrow - 1]} {incr j 1} {
                  switch -glob -- $labelin {
                  EVIS* {
                     if {$jtemp == 49} {
                        set jtemp 61
                     }
                     set tbdata($j,0) [ans_getvalue $labeldac,$mat,TEMP,,CONST,$jtemp]
                     set jtemp [expr $jtemp + 1]
                        } 
                  NULL* {
                     if {$jj <= 4} {
                        set tbdata($j,0) [ans_getvalue $labeldac,$mat,TEMP,,CONST,$jj]
                     } else {
                        set tbdata($j,0) [ans_getvalue $labeldac,$mat,TEMP,,CONST,[expr $jj + 11]]
                     }
                        }
                  default {
                          set tbdata($j,0) [ans_getvalue $labeldac,$mat,TEMP,,CONST,$jj]
                       }
                  }
                  set tbdata($j,0) [format "%-10.5G" $tbdata($j,0)]
                  set tbdata($j,0) [string trimright $tbdata($j,0)]
                  set jj [expr $jj+1]
               }
           }
         }
      }
     
      grid $childsite.lbl$labelin -sticky new -column 0 -row 0 \
            -columnspan 7
      
      #configure tktable
      $tableName configure -rows [expr int($numrow)] -cols [expr int($numcol) + 1] 

      grid $tableName -sticky news -column 0 -row 2 -columnspan 8
      grid rowconfigure $childsite 2 -weight 1

      # Set the max view height for the table
      grid rowconfigure $childsite 2 -minsize 50

      $parent2 configure \
            -okcommand [code matOpts_Ok 0 $mat 0] \
            -cancelcommand [code matOpts_Cancel] \


      update idletasks
      wm minsize $parent2 [winfo reqwidth $parent2] \
                          [expr [winfo reqheight $parent2] + 25] 

     
     grid propagate $childsite 0
      
     set treeChildsite $childsite

     $tableName selection set 0,0
     $tableName activate 0,0
     $tableName selection anchor 0,0
     $tableName see active
 
  
      if [winfo exists .conf] {
         $confirm activate
         raise $confirm
      } else {
        $parent2 activate
      }
   }

   proc matOpts_Ok { flag mat next} {

      variable parent2
      variable labelin
      variable numcol
      variable labtemp
      variable tbopt
      variable numrow
      variable tbdata
      variable tbopt
      variable treeChildsite
      variable tableName
      variable numtb
      variable numt
      variable numlab
      variable listMP
      variable grpher
      

      # Indicate that a material has changed its values
      variable ::euidl::material::ModelControl::localMatlInfoArr
      if {[info exists localMatlInfoArr]} {
         set localMatlInfoArr(matl,$mat,chng) 1
      }
      

      #Find the labels for each model 
      set list {ISOTdyn ORTHdyn ANELdyn FLUIdyn MOONdyn MOON1dyn EVISC BLAT\
                BISOdyn BISOtmp ANISdyn ANISfld BAR3dyn BARLdyn\
                BKINdyn KINEdyn SENSdyn DEPdyn COMPdyn CONCdyn\
                LINRdyn LINR1dyn PLAWdyn HYDRdyn GEOdyn\
                CELLdyn VISCdyn  DENSdyn CRSHdyn HONEdyn JOHN1dyn NULL1dyn\
                ZERI1dyn  STEN1dyn JOHN2dyn NULL2dyn ZERI2dyn STEN2dyn\
                THERMdyn JOHN3dyn NULL3dyn ZERI3dyn STEN3dyn\
                BAMMdyn SPNGdyn NLSPdyn NLESdyn ELSPdyn INSPdyn\
                MAXSdyn LNVIdyn NLVIdyn CABLdyn RIGIdyn}

      set ix [lsearch -exact $list $labelin]
      set tbopt ""
      set tbopt1 ""
      set numlab 0

      if {$ix >= 0} {
               switch -exact -- $labelin {
                    ISOTdyn {
                       
                        set numtb 0
                        set numlab 3
                    }
                    ORTHdyn {
                        
                        set numtb 0
                        set numlab 10
                        catch {ans_sendcommand EDMP,ORTHO,$mat,\
                        $tbdata(10,0)}
                    }
                    ANELdyn {
                        
                        set labtemp "ANEL"
                        set numtb 21
                        set numlab 2
                        catch {ans_sendcommand EDMP,ORTHO,$mat,\
                        $tbdata(1,0)}
                    }
                    EVISC {
                        
                        set labtemp "EVIS"
                        set numtb 4
                        set numlab 1
                    }
                    FLUIdyn {
                        
                        set labtemp "FLUI"
                        set numtb 0
                        set numlab 3
                        catch {ans_sendcommand EDMP,$labtemp,$mat,$tbdata(3,0)}
                    }
                    BLAT {
                       
                        set numtb 0
                        set numlab 2
                    }
                    MOONdyn {
                        
                        set labtemp "MOONEY"
                        set numtb 6
                        set numlab 2
                        set tbopt 2
                    }
                    MOON1dyn {
                        
                        set labtemp "MOONEY"
                        set numtb 2
                        set numlab 2
                        set tbopt 0
                    }
                    BISOdyn {
                        
                        set labtemp "BISO"
                        set numtb 2
                        set numlab 3
                    }
                    BISOtmp {
                        
                        set labtemp "BISO"
                        set numtb 2
                        set numlab 5
                        set numt $numcol
                    }
                    ANISdyn {
                        
                        set labtemp "PLAW"
                        set tbopt 7
                        set numtb 4
                        set numlab 3
                    }
                    ANISfld {
                        
                        set labtemp "PLAW"
                        set tbopt 10
                        set numtb 5
                        set numlab 3
                    }
                    BKINdyn {
                        
                        set labtemp "BKIN"
                        set numtb 2
                        set numlab 3
                    }
                    KINEdyn {
                        
                        set labtemp "PLAW"
                        set tbopt 1
                        set numtb 7
                        set numlab 3
                    }
                    BAR3dyn {
                        
                        set labtemp "PLAW"
                        set tbopt 3
                        set numtb 8
                        set numlab 3
                    }
                    BARLdyn {
                        
                        set labtemp "PLAW"
                        set tbopt 6
                        set numtb 10
                        set numlab 3
                    }
                    SENSdyn {
                        
                        set labtemp "PLAW"
                        set tbopt 4
                        set numtb 4
                        set numlab 3
                    }
                    DEPdyn {
                        
                        set labtemp "PLAW"
                        set tbopt 5
                        set numtb 6
                        set numlab 3
                    }
                    COMPdyn {
                        
                        set labtemp "COMP"
                        set numtb 6
                        set numlab 10
                    }
                    CONCdyn {
                        
                        set labtemp "CONCR"
                        set tbopt 2
                        set numtb 78
                        set numlab 2
                    }
                    LINRdyn {
                        
                        set labtemp "PLAW"
                        set tbopt 8
                        set numtb 27
                        set numlab 3
                    }
                    LINR1dyn {
                        
                        set labtemp "PLAW"
                        set tbopt 11
                        set numtb 30
                        set numlab 3
                    }
                    PLAWdyn {
                        
                        set labtemp "PLAW"
                        set tbopt 2
                        set numtb 6
                        set numlab 3
                    }
                    HYDRdyn {
                        
                        set labtemp "PLAW"
                        set tbopt 9
                        set numlab 3
                        set numtb 44
                    }
                    GEOdyn {
                        
                        set labtemp "GCAP"
                        set numtb 12
                        set numlab 2
                    }
                    THERMdyn {
                        
                        set labtemp "PLAW"
                        set tbopt 12
                        set numtb 18
                        set numlab 4
                    }
                    CELLdyn {
                        
                        set labtemp "FOAM"
                        set tbopt 1
                        set numtb 6
                        set numlab 2
                    }
                    VISCdyn {
                        
                        set labtemp "FOAM"
                        set tbopt 3
                        set numtb 4
                        set numlab 3
                    }
                    DENSdyn {
                        
                        set labtemp "FOAM"
                        set tbopt 2
                        set numtb 8
                        set numlab 2
                    }
                    CRSHdyn {
                        
                        set labtemp "FOAM"
                        set tbopt 4
                        set numtb 3
                        set numlab 3
                    }
                    HONEdyn {
                        
                        set labtemp "HONE"
                        set numtb 17
                        set numlab 3
                    }
                    JOHN1dyn {
                        
                        set labtemp "EOS"
                        set tbopt 1
                        set tbopt1 1
                        set numtb 24
                        set numlab 3
                    }
                    NULL1dyn {
                        set labtemp "EOS"
                        set tbopt 2
                        set tbopt1 1
                        set numtb 24
                        set numlab 3
                        for {set i 15} {$i >= 7} {incr i -1} {
                            set tbdata([expr $i + 11],0) $tbdata($i,0)
                            set tbdata($i,0) ""
                        }
                    }
                    ZERI1dyn {
                        
                        set labtemp "EOS"
                        set tbopt 3
                        set tbopt1 1
                        set numtb 28
                        set numlab 3
                    }
                    STEN1dyn {
                        
                        set labtemp "EOS"
                        set tbopt 5
                        set tbopt1 1
                        set numtb 37
                        set numlab 3
                    }
                    JOHN2dyn {
                        
                        set labtemp "EOS"
                        set tbopt 1
                        set tbopt1 2
                        set numtb 23
                        set numlab 3
                    }
                    NULL2dyn {
 
                        set labtemp "EOS"
                        set tbopt 2
                        set tbopt1 2
                        set numtb 23
                        set numlab 3
                        for {set i 14} {$i >= 7} {incr i -1} {
                            set tbdata([expr $i + 11],0) $tbdata($i,0)
                            set tbdata($i,0) ""
                        }
                    }
                    ZERI2dyn {
                       
                        set labtemp "EOS"
                        set tbopt 3
                        set tbopt1 2
                        set numtb 27
                        set numlab 3
                    }
                    STEN2dyn {
                        
                        set labtemp "EOS"
                        set tbopt 5
                        set tbopt1 2
                        set numtb 36
                        set numlab 3
                    }
                    JOHN3dyn {
                        
                        set labtemp "EOS"
                        set tbopt 1
                        set tbopt1 3
                        set numtb 48
                        set numlab 3
                    }
                    NULL3dyn {
                        set labtemp "EOS"
                        set tbopt 2
                        set tbopt1 3
                        set numtb 48
                        set numlab 3
                        for {set i 39} {$i >= 7} {incr i -1} {
                            set tbdata([expr $i + 11],0) $tbdata($i,0)
                            set tbdata($i,0) ""
                        }
                    }
                    ZERI3dyn {
                        
                        set labtemp "EOS"
                        set tbopt 3
                        set tbopt1 3
                        set numtb 52
                        set numlab 3
                    }
                    STEN3dyn {
                        
                        set labtemp "EOS"
                        set tbopt 5
                        set tbopt1 3
                        set numtb 61
                        set numlab 3
                    }
                    BAMMdyn {
                        
                        set labtemp "EOS"
                        set tbopt 4
                        set numtb 28
                        set numlab 3
                    }
                    SPNGdyn {
                        
                        set labtemp "DISC"
                        set numtb 1
                    }
                    NLSPdyn {
                        
                        set labtemp "DISC"
                        set tbopt 5
                        set numtb 5
                    }
                    NLESdyn {
                       
                        set labtemp "DISC"
                        set tbopt 3
                        set numtb 2
                    }
                    ELSPdyn {
                       
                        set labtemp "DISC"
                        set tbopt 2
                        set numtb 3
                    }
                    INSPdyn {
                        
                        set labtemp "DISC"
                        set tbopt 7
                        set numtb 3
                    }
                    MAXSdyn {
                        
                        set labtemp "DISC"
                        set tbopt 6
                        set numtb 6
                    }
                    LNVIdyn {
                        
                        set labtemp "DISC"
                        set tbopt 1
                        set numtb 1
                    }
                    NLVIdyn {
                        
                        set labtemp "DISC"
                        set tbopt 4
                        set numtb 1
                    }
                    CABLdyn {
                        
                        set labtemp "CABLE"
                        set numtb 0
                        set numlab 2
                        catch {ans_sendcommand EDMP,$labtemp,$mat,\
                        $tbdata(2,0)}
                    }
                    RIGIdyn {
                        
                        set labtemp "RIGI"
                        set numtb 0
                        set numlab 3
                        catch {ans_sendcommand \
                             EDMP,$labtemp,$mat,$tbdata(3,0),$tbdata(4,0)}
                    }
                }
            }


         set listTBnames {BISOdyn BISOtmp MOONdyn MOON1dyn ANELdyn EVISC\
                          ANISdyn ANISfld BKINdyn KINEdyn\
                          BAR3dyn BARLdyn SENSdyn DEPdyn\
                          COMPdyn CONCdyn LINRdyn LINR1dyn PLAWdyn HYDRdyn\
                          GEOdyn THERMdyn CELLdyn VISCdyn DENSdyn CRSHdyn\
                          HONEdyn JOHN1dyn NULL1dyn ZERI1dyn\
                          STEN1dyn JOHN2dyn NULL2dyn ZERI2dyn\
                          STEN2dyn JOHN3dyn NULL3dyn ZERI3dyn\
                          STEN3dyn BAMMdyn SPNGdyn NLSPdyn\
                          NLESdyn ELSPdyn INSPdyn MAXSdyn\
                          LNVIdyn NLVIdyn}
       
            # Get the number of temperatures (This is for BISOtmp)
            if {$labelin == "BISOtmp"} {
               set numt $numcol
            } else {
               set numt 1
            }
            if {$flag != 777} {
                ans_sendcommand )/GO
            } else {
                ans_sendcommand )/NOPR
            }
            if {$labelin == "BISOtmp"} {

                #Reorder TEMPERATURE - Create a list 
                for {set i 0} {$i<$numcol} {incr i 1} { 
                   if {[catch {lappend tempData $tbdata(0,$i)}]} {
                     set tbdata(0,$i) 0
                     lappend tempData $tbdata(0,$i)
                   }
                }
                # Sort the temperatures into a list
               
                if {[catch {set tempSort [lsort -real -unique $tempData]}]} {
                   catch {unset tempData2}
                   foreach junktemp $tempData {
                      regsub -all { } $junktemp {} junktemp
                      if {[catch {ans_evalexpr $junktemp}]} {
                         #set junktemp 0
                          return
                      } else {
                         set junktemp [ans_evalexpr $junktemp]
                      }
                      lappend tempData2 $junktemp
                   }
                   set tempData $tempData2
                   set tempSort [lsort -real -unique $tempData]
                }
                if {[llength $tempData] != [llength $tempSort]} {
                   set tl {}
                   set tempSort [lsort -real $tempData]
                   set tl [lindex $tempSort 0]
                   for {set i 1} {$i < [llength $tempSort]} {incr i} {
                      if {[lindex $tempSort $i] == $tl} {
                         tk_messageBox -icon error \
                               -parent $parent2 \
                               -message [::msgcat::mc "There are multiple temperatures\
                                           with value of $tl"]
                         break
                      }
                      set tl [lindex $tempSort $i]
                   }
                   return
                }
                # We have a valid sorted temperature list tempSort

                #  issue MPTEMP
                # clear mptemp first
                ans_sendcommand )/NOPR
                if {$flag != 777} {
                   catch {ans_sendcommand MPTEMP,,,,,,,,}
                } else {
                   catch {ans_sendcommand )MPTEMP,,,,,,,,}
                }
                ans_sendcommand )/GO
                set n 1
                foreach temp $tempSort {
                   if {$flag != 777} {
                      catch {ans_sendcommand MPTEMP,$n,$temp}
                   } else {
                      ans_sendcommand )/NOPR
                      catch {ans_sendcommand )MPTEMP,$n,$temp}
                   }
                   set n [expr $n +1]
                }


            } 
            # MP commands
            
           
               set h 0
               foreach lab $listMP {
                  set h [expr $h+1]
                  set check [ans_getvalue $lab,$mat,EXIS]
                  ans_sendcommand )/NOPR
                  if {$check == 1} {
                       catch {ans_sendcommand MPDE,$lab,$mat}
                  }
                  ans_sendcommand )/GO 
                  if {$labelin == "BISOtmp"} {                      
                      foreach temp $tempSort {                       
                         set i [lsearch $tempData $temp]
                         if {$lab == "DENS"} {
                            if {[catch {set value $tbdata($h,0)}]} {
                               set value ""
                            }
                         } else {
                             if {[catch {set value $tbdata($h,$i)}]} {
                               set value ""
                             }
                         }
                         regsub -all { } $value {} value
                         if {$flag != 777} {
                           if {[catch {ans_sendcommand MPDATA,$lab,$mat,,$value}]} {
                              ans_sendcommand )/NOPR
                              set tbe [ans_getvalue $lab,$mat,EXIS]
                              if {$tbe == 1} {
                                    catch {ans_sendcommand MPDE,$lab,$mat}
                              }
                              ans_sendcommand )/GO
                              return
                           }
                         } else {
                           ans_sendcommand )/NOPR
                           if {[catch {ans_sendcommand )MPDATA,$lab,$mat,,$value}]} {
                              set tbe [ans_getvalue $lab,$mat,EXIS]
                              if {$tbe == 1} {
                                   set grpher 999
                              }
                              return
                           }
                         }
                      }
                  } else {
                     catch {ans_sendcommand MP,$lab,$mat,$tbdata([expr $h-1],0)} 
                  }
               }

             
            #TB commands

            set tb [lsearch -exact $listTBnames $labelin]
            if {$tb >= 0} {
               set check [ans_getvalue $labtemp,$mat,EXIS]
               ans_sendcommand )/NOPR
               if {$check == 1} {
                 catch {ans_sendcommand TBDE,$labtemp,$mat}
               }
               ans_sendcommand )/GO 
               if {$labelin == "BISOtmp"} {
                 if {$flag != 777} {
                     catch {ans_sendcommand TB,$labtemp,$mat,$numt}
                 } else {
                     ans_sendcommand )/NOPR
                     catch {ans_sendcommand )TB,$labtemp,$mat,$numt}
                 }
                 foreach temp $tempSort {
                    set i [lsearch $tempData $temp]
                    if {$flag != 777} {
                       catch {ans_sendcommand TBTEMP,$temp}
                    } else {
                       catch {ans_sendcommand )TBTEMP,$temp}
                    }                    
                 
                    for {set j 0} {$j < $numtb} {incr j 1} {                
                        if {[catch {set c($j) $tbdata([expr $j + $numlab ],$i)}]} {
                            set c($j) ""
                        }
                        regsub -all { } $c($j) {} c($j)            
                    }
                    if {$flag != 777} {
                      if {[catch {ans_sendcommand \
                       TBDATA,,$c(0),$c(1)}]} {
                        ans_sendcommand )/NOPR
                        catch {ans_sendcommand TBDE,$labtemp,$mat}
                        ans_sendcommand )/GO
                        return
                      }
                    } else {
                       if {[catch {ans_sendcommand \
                        )TBDATA,,$c(0),$c(1)}]} {
                        set grpher 999
                        return
                       }
                    }
                 } 
               } else {
                  catch {ans_sendcommand TB,$labtemp,$mat,,,$tbopt,$tbopt1}
               
                for {set i 1} {$i <=  $numtb} {incr i 1} {
                 if {[catch {set value $tbdata([expr $i+$numlab-1],0)}]} {
                     set value ""
                 }
                 regsub -all { } $value {} value
                 if {$labelin == "EVISC"} {
                        if {$i == 1} {
                           set k 46
                        } elseif {$i == 2} {
                           set k 47
                        } elseif {$i == 3} {
                           set k 48
                        } elseif {$i == 4} {
                           set k 61
                        }
                           if {[catch {ans_sendcommand \
                             TBDAT,$k,$value}]} {
                             ans_sendcommand )/NOPR
                             catch {ans_sendcommand )TBDE,$labtemp,$mat}
                             ans_sendcommand )/GO
                             return
                            }
                 } else {
                        if { $labelin == "MOONdyn" && $tbopt == 2 } {
                          if { $i == 1 || $i == 2 } {
                            set value ""
                          }
                        }
                        if {[catch {ans_sendcommand \
                        TBDAT,$i,$value}]} {
                          ans_sendcommand )/NOPR
                          catch {ans_sendcommand )TBDE,$labtemp,$mat}
                          ans_sendcommand )/GO
                          return
                        }
                 }
                        
                }
               }     
            }
          

         
         
        ans_sendcommand )/GO
        if {$flag != 777} {
            # Unset the variables to make sure the table is clean on reentry. 


            unset numcol
            unset numrow
            unset tbdata

            destroy $parent2
            unset parent2

            euidl::material::ModelControl::matTable_State 1     
        }
    }

   proc matOpts_Cancel {} {
      variable parent2
      variable numcol
      variable numrow
      variable tbdata

      unset tbdata
      unset numcol
      unset numrow
      destroy $parent2
      unset parent2
      euidl::material::ModelControl::matTable_State 1
   }

   #ADD A COLUMN TO THE TABLE# 
   proc addcolumn {} {

        variable parent2
        variable tableName
        variable tbdata
        variable labelin
        variable numrow
        variable numcol
        variable colmax
        variable treeChildsite
     

        if {$numcol >= $colmax} {
             tk_messageBox -icon warning \
                  -title [msgcat::mc "Maximum Number of columns"] \
                  -parent $parent2 \
                  -type ok \
                  -message [msgcat::mc " This table \
                        allows only $colmax temperatures."]
        } else {

           incr numcol

           $tableName tag cell normaltitle 0,-1
           $tableName tag cell normal 0,0

        
           # Insert a column after the currently selected one
           if {[catch {$tableName index active col} curColumn]} {
              set curColumn 0
           }
           $tableName insert col -keeptitles -- $curColumn 1

           # Move the view to see added column
           $tableName xview scroll 1 unit

           # Label this new column
           set tbdata(-1,[expr $numcol - 1]) "T$numcol"
           
           if {[catch {set tbdata(1,[expr $curColumn + 1]) $tbdata(1,0)}]} {
              set tbdata(1,[expr $curColumn + 1]) ""
           }
                         
           #$tableName tag cell disabledtitle 1,[expr $curColumn +1]
           $tableName tag cell disabled 1,[expr $curColumn +1]

           update
           #activate the new column
           $tableName selection activate 1,[expr $curColumn +1]
           $tableName see active

        }
   }


   proc colselect {} {

        variable tableName
        

        #create a list of sorted selected cells format {0,0 0,1 ....}
        set listcell [$tableName curselection]
        set length [llength $listcell]

        #get the first cell and the last cell selected
        set first [lindex  $listcell 0]
        set lastind [expr $length -1]
        set last [lindex  $listcell $lastind]
        
        #get the first and the last col 
        set firstlis [split $first ,]
        set firstcol [lindex  $firstlis 1]
       
        set lastlis [split $last ,]
        set lastcol  [lindex  $lastlis 1]
       
        if {$length == 0} {
             if {[catch {$tableName index active col} firstcol]} {
               set firstcol 2
             }
             set lastcol $firstcol
        }
       
        #Delete all the rows selected
        for {set i $firstcol} {$i <= $lastcol} {incr i 1} {
            delcolumn $firstcol
        }
        
   }

   

    #Returns the rows and columns selected#
    #default to the last one created#

    proc rowselect {} {

        variable tableName

        #create a list of sorted selected cells format {0,0 0,1 ....}
        set listcell [$tableName curselection]
        set length [llength $listcell]

        #get the first cell and the last cell selected
        set first [lindex  $listcell 0]
        set lastind [expr $length -1]
        set last [lindex  $listcell $lastind]
        
        #get the first and the last row 
        set firstlis [split $first ,]
        set firstrow  [lindex  $firstlis 0]
       
       
        set lastlis [split $last ,]
        set lastrow  [lindex  $lastlis 0]
       
       
        if {$length == 0} {
            
             if {[catch {$tableName index active row} firstrow]} {
               set firstrow 2
             }
             set lastrow $firstrow
        }
       
        #Delete all the rows selected
        for {set i $firstrow} {$i <= $lastrow} {incr i 1} {
            delrow $firstrow
        }
        
   }

    proc graph {labgraph index} {

      variable ::euidl::material::ModelControl::matModelArr

      variable labelin
      variable grpher
 
      set grpher 0
     
      # Lower the windows so that the graph isn't obscurred in 3D
      lower $matModelArr(parent)
      update

      #set a dummy material ID
      set matgr [ans_evalexpr mpinqr(0,0,14)]
      set matgr [expr $matgr +1]
 
      # call matOpts_OK with flag on
    
      matOpts_Ok 777 $matgr 0


      set def [ans_evalexpr mpinqr($matgr,0,1)]
      if {$def == 0} {
          return
      }

      
      if {$labgraph == "BISO"} {
        #plot the biso table
        ans_sendcommand )/GO
        if {$grpher != 999} {
          catch {ans_sendcommand )TBPL,$labgraph,$matgr,,,,,,,PREV} 
        }
      } else {
         #Plot MP
         ans_sendcommand )/GO
         if {$grpher != 999} {
            catch {ans_sendcommand )MPPL,$labgraph,$matgr,,,,,,,PREV} 
         }
      }

      #delete everything
      ans_sendcommand )/NOPR
      catch {ans_sendcommand )TBDE,ALL,$matgr}            
      catch {ans_sendcommand )MPDE,ALL,$matgr}            
      ans_sendcommand )/GO
      after 1000 [list raise $matModelArr(parent)]
   }

    #DELETE A COLUMN IN THE TABLE#

    proc delcolumn { curColumn} {

        variable parent2
        variable tableName
        variable labelin
        variable tbdata
        variable numcol
        variable treeChildsite
        
        if {$numcol >= 2} {
            # Delete the current column
            $tableName delete cols -keeptitles -- $curColumn 1

          set numcol [expr $numcol - 1]
         
          if {$numcol < 2} {
               $tableName tag cell disabledtitle 0,-1
               $tableName tag cell disabled 0,0
          }
          $tableName tag cell normal 1,0
      } else {
         tk_messageBox -icon warning \
               -message [msgcat::mc "Cannot remove any more columns"] \
               -parent $parent2
      }
        
   }
}
#
# ============================================================================
# File Name:     table3.eui
# Description:   TB Dialog box for the following labels
#                MISO,MELAS,KINH
#                All these tables are temperature dependent
#                STRESS-STRAIN Curves
#
#                FCON,HFLM
#                Same Format but not STAIN STRESS
#                BH is not temperature dependent
# 
#                Nonlinear Joint Tables JNSA, JNS4, JNS6, JNDA, JND4, JND6,
#                                       JNFA, JNF4, JNF6
# ============================================================================
# The tktable is organized in a special way
# The first 2 rows (-1 & 0) are TITLES 
# Some cols appear flat as separators for the stress-strain data input
#
# rows\cols :  -1    |    0    |     1    |     2    |   3    |   4  ......  
#  -1 |              |     T1  |  entry   | flat cell|   T2   |  entry
#   0 |              |   STRAIN|  STRESS  | flat cell| STRAIN |   STRESS
#   1 | label(1,2...)|  entry  |  entry   | flat cell| entry  |  entry ....
#
# So for N=0 to NTEMP we have 
# col 3N has an entry
# col 3N+1 has an entry
# col 3N+2 is flat
#
namespace eval ::euidl::material::mat3 {
   
   proc TABLE3 {label matid next} {
      
      variable ::euidl::material::ModelControl::matModelArr
        
      #numcol is the number of temps
      #numrow is the number of rows in the table
      variable numcol
      variable numrow
      variable tbdata
      variable labelin
      variable tbopt
     
      #realcol is the real number of cols in the table
      #actrow(x) is the number of active rows for each temp
      variable realcol
      variable actrow 
      
      variable colmax
      variable rowmax
    
      set labelin $label
          
      variable parent3
      variable childsite
      variable tableName
      variable treeChildsite
     
      variable usePlast

      #Disable the rest of the material gui
      euidl::material::ModelControl::matTable_State 0

      if [winfo exists .dlgMatOpts] {
         # Set the display correctly
         $parent3 activate
         return
      }
      set usePlast ""

      set parent3 [euidl::dialog .dlgMatOpts -class EUIDL \
            -master $matModelArr(parent) \
            ]
      set childsite [$parent3 component childsite]

      #SET WINDOW#

      wm minsize $parent3 650 350
    
     
      set mat $matid

      set tableName [euidl::table $childsite.tbl1 \
            -variable [scope tbdata] \
            -rowseparator \n \
            -colseparator \t \
            -validate focusout \
            -validatedata ansreal \
         ]

         
      
     

       # BUTTONS ADD & DELETE & GRAPH# 
   
      
      euidl::button $childsite.addaftc -text [msgcat::mc "Add Temperature"] \
            -command [code addcolumn ] 
      grid $childsite.addaftc -column 0 -row 3

      bind $childsite.addaftc <ButtonRelease-1> \
                  [code ::euidl::material::error::check %W]

      euidl::button $childsite.delcolumn -text [msgcat::mc "Delete Temperature"] \
            -command [code colselect ]
      grid $childsite.delcolumn -column 1 -row 3

      bind $childsite.delcolumn <ButtonRelease-1> \
                  [code ::euidl::material::error::check %W]


      euidl::button $childsite.addaftr -text [msgcat::mc "Add Point"] \
            -command [code addrow ]
      grid $childsite.addaftr -column 3 -row 3

      bind $childsite.addaftr <ButtonRelease-1> \
                  [code ::euidl::material::error::check %W]

      euidl::button $childsite.delrow -text [msgcat::mc "Delete Point"] \
            -command [code rowselect ]
      grid $childsite.delrow -column 4 -row 3

      bind $childsite.delrow <ButtonRelease-1> \
                  [code ::euidl::material::error::check %W]

      euidl::button $childsite.graph -text [msgcat::mc "Graph"] \
            -command [code graph 0 $mat]
      grid $childsite.graph -sticky e -column 6 -row 3

      bind $childsite.graph <ButtonRelease-1> \
                  [code ::euidl::material::error::check %W]

      grid columnconfigure $childsite 2 -minsize 50
      grid columnconfigure $childsite 5 -minsize 40
      grid columnconfigure $childsite 6 -weight 1
 
      $parent3 configure \
            -okcommand [code matOpts_Ok 0 $mat $next] \
            -cancelcommand [code matOpts_Cancel] \
            -helpcommand [list ans_loadhelp Hlp_UI_mat_dat]
      

      # COMMAND DESCRIPTION-HAVE TO CHANGE THE MESSAGE DEPENDING ON THE LABEL
      #set number of cols and rows depending on the label

      set tbopt "    "

      # A defined PLAS model trumps MISO or KINH
      if {$labelin == "MISO" || $labelin == "KINH"} {
         set tbexis [ans_getvalue PLAS,$mat,EXIS]
         if {$tbexis == 1} {
            set labelin PLAS1
         }
      }

      switch -glob -- $labelin {
        
        
         MISO {
            euidl::label $childsite.lbl$labelin -height 3 \
                  -anchor w \
                  -text [msgcat::mc "Multilinear Isotropic Hardening\
                         for Material Number $mat"]
            wm title $parent3 [msgcat::mc "Multilinear Isotropic Hardening\
                         for Material Number $mat"]

            euidl::label $childsite.lblopt$labelin -height 3 -anchor nw \
                    -text  [msgcat::mc "Stress-Strain Options"]
            euidl::combobox  $childsite.cmb$labelin -width 25  \
                 -variable [scope usePlast]
            $childsite.cmb$labelin insert list end\
                 [list {Stress versus Total Strain} MISO_TOT\
                       {Stress versus Plastic Strain} MISO_PLAS\
                 ]
            $childsite.cmb$labelin configure -command [code plasticitySwitch]
            set tbexis [ans_getvalue $labelin,$mat,EXIS]
            if {$tbexis == 1} {
               $childsite.cmb$labelin configure -state disabled
            }

            set numcol 1
            set realcol 3
            set numrow 1
            set actrow(1) 1
            
            #if 20 temperatures are allowed, it means the table can have
            #3*20 columns
            $tableName config -colmax 60
            set colmax 20
            $tableName config -rowmax 101
            set rowmax 100
            $parent3 configure -helpcommand [list ans_loadhelp Hlp_E_CH2miso]
            set tbopt "    "
            set usePlast MISO_TOT
         }
         PLAS* {
            euidl::label $childsite.lbl$labelin -height 3 \
                  -anchor w \
                  -text [msgcat::mc "Multilinear Plasticity\
                       for Material Number $mat"]
            wm title $parent3 [msgcat::mc "  Multilinear Plasticity\
                       for Material Number $mat"]
            euidl::label $childsite.lblopt$labelin -height 3 -anchor nw \
                    -text  [msgcat::mc "Hardening Rule"]
            euidl::combobox  $childsite.cmb$labelin -width 25  \
                 -variable [scope tbopt]
            $childsite.cmb$labelin insert list end\
                 [list {Isotropic} 1\
                       {Kinematic} 4\
                 ]

            set numcol 1
            set realcol 3
            set numrow 1
            set actrow(1) 1
            $tableName config -colmax 120
            set colmax 40
            $tableName config -rowmax 21
            set rowmax 20
            $parent3 configure -helpcommand [list ans_loadhelp Hlp_E_CH2mkin]
            set tbopt 0
            set usePlast MISO_TOT
         }
         MELA {
            euidl::label $childsite.lbl$labelin -height 3 \
                  -anchor w \
                  -text [msgcat::mc "Multilinear Elasticity\
                      for Material Number $mat"]
            wm title $parent3 [msgcat::mc "Multilinear Elastic\
                         for Material Number $mat"]
            set numcol 1
            set realcol 3
            set numrow 1
            set actrow(1) 1
            $tableName config -colmax 60
            set colmax 20
            $tableName config -rowmax 101
            set rowmax 100
            $parent3 configure -helpcommand [list ans_loadhelp Hlp_E_CH2mela]
            set tbopt "    "
         }
         KINH {
            euidl::label $childsite.lbl$labelin -height 3 \
                  -anchor w \
                  -text [msgcat::mc "Multilinear Kinematic Hardening\
                       for Material Number $mat"]
            wm title $parent3 [msgcat::mc "  Multilinear Kinematic Hardening\
                       for Material Number $mat"] 
            euidl::label $childsite.lblopt$labelin -height 3 -anchor nw \
                    -text  [msgcat::mc "Stress-Strain Options"]
            euidl::combobox  $childsite.cmb$labelin -width 25  \
                 -variable [scope usePlast]
            $childsite.cmb$labelin insert list end\
                 [list {Stress versus Total Strain} KINH_TOT\
                       {Stress versus Plastic Strain} KINH_PLAS\
                 ]
            $childsite.cmb$labelin configure -command [code plasticitySwitch]
            set tbexis [ans_getvalue $labelin,$mat,EXIS]
            if {$tbexis == 1} {
               $childsite.cmb$labelin configure -state disabled
            }

            set numcol 1
            set realcol 3
            set numrow 1
            set actrow(1) 1
            $tableName config -colmax 120
            set colmax 40
            $tableName config -rowmax 21
            set rowmax 20
            $parent3 configure -helpcommand [list ans_loadhelp Hlp_E_CH2mkin]  
            set tbopt 0
            set usePlast KINH_TOT
         }
         HFLM {
            euidl::label $childsite.lbl$labelin -height 3 \
                  -anchor w \
                  -text [msgcat::mc "Pipe Flow Data : Film Coefficient\
                       for Material Number $mat"]
            wm title $parent3 [msgcat::mc "  Film Coefficient\
                       for Material Number $mat"] 
            set numcol 1
            set realcol 3
            set numrow 1
            set actrow(1) 1
            $tableName config -colmax 60
            set colmax 20
            $tableName config -rowmax 101
            set rowmax 100  
            $childsite.graph configure -state disabled
            $parent3 configure -helpcommand [list ans_loadhelp Hlp_E_116tabl]
            set tbopt "    "
         }
         FCON {
            euidl::label $childsite.lbl$labelin -height 3 \
                  -anchor w \
                  -text [msgcat::mc "Fluid Conductance\
                       for Material Number $mat"]
            wm title $parent3 [msgcat::mc "Pipe Flow Data :\
                       Fluid Conductance for Material Number $mat"] 
            set numcol 1
            set realcol 3
            set numrow 1
            set actrow(1) 1
            $tableName config -colmax 60
            set colmax 20
            $tableName config -rowmax 101
            set rowmax 100  
            $childsite.graph configure -state disabled 
            $parent3 configure -helpcommand [list ans_loadhelp Hlp_E_116tabl]
            set tbopt "    "
         }
         BH {
            euidl::label $childsite.lbl$labelin -height 3 \
                  -anchor w \
                  -text [msgcat::mc "BH Curve\
                       for Material Number $mat"]
            wm title $parent3 [msgcat::mc "BH Curve\
                       for Material Number $mat"] 
            set numcol 1
            set realcol 3
            set numrow 1
            set actrow(1) 1
            $tableName config -colmax 3
            set colmax 2  
            $tableName config -rowmax 501 
            set rowmax 500

            #destroy the button 

            destroy $childsite.graph

            # Create the menubar for graph
 
            menubutton  $childsite.mb1 -text [msgcat::mc "  Graph  "] \
                -menu $childsite.mb1.menu -borderwidth 2\
                -relief raised
            bind $childsite.mb1 <ButtonPress-1> {focus %W}
            menu $childsite.mb1.menu -tearoff 0
            
            grid $childsite.mb1 -sticky e -column 6 -row 3
            foreach graBH {BH NB MH} {
                #set ind [expr $ind + 1]
                set $graBH [menu $childsite.mb1.menu.m$graBH -tearoff 0]
                $childsite.mb1.menu add command -label [msgcat::mc "$graBH"] -command [code graph $graBH 0]
             }

            $childsite.addaftc configure -state disabled 
            $childsite.delcolumn configure -state disabled
            $parent3 configure -helpcommand [list ans_loadhelp Hlp_E_CH2bh]
            set tbopt "    "
         }
         GASKCOMP {
            euidl::label $childsite.lbl$labelin -height 3 \
                  -anchor w \
                  -text [msgcat::mc "Gasket Compression\
                       for Material Number $mat"]
            wm title $parent3 [msgcat::mc "Gasket Compression\
                       for Material Number $mat"]
            set numcol 1
            set realcol 3
            set numrow 1
            set actrow(1) 1
            $tableName config -colmax 60
            set colmax 100
            $tableName config -rowmax 101
            set rowmax 100
            $parent3 configure -helpcommand [list ans_loadhelp Hlp_gask]
            set tbopt COMP
         }
         GASKLUNL {
            euidl::label $childsite.lbl$labelin -height 3 \
                  -anchor w \
                  -text [msgcat::mc "Gasket Linear Unloading\
                       for Material Number $mat"]
            wm title $parent3 [msgcat::mc "Gasket Linear Unloading\
                       for Material Number $mat"]
            set numcol 1
            set realcol 3
            set numrow 1
            set actrow(1) 1
            $tableName config -colmax 60
            set colmax 100
            $tableName config -rowmax 101
            set rowmax 100
            $parent3 configure -helpcommand [list ans_loadhelp Hlp_gask]
            set tbopt LUNL
         }
         GASKNUNL {
            euidl::label $childsite.lbl$labelin -height 3 \
                  -anchor w \
                  -text [msgcat::mc "Gasket Nonlinear Unloading\
                       for Material Number $mat"]
            wm title $parent3 [msgcat::mc "Gasket Nonlinear Unloading\
                       for Material Number $mat"]
            set numcol 1
            set realcol 3
            set numrow 1
            set actrow(1) 1
            $tableName config -colmax 60
            set colmax 100
            $tableName config -rowmax 101
            set rowmax 100
            $parent3 configure -helpcommand [list ans_loadhelp Hlp_gask]
            set tbopt NUNL
         }
         UNIACOMP {
            euidl::label $childsite.lbl$labelin -height 3 \
                  -anchor w \
                  -text [msgcat::mc "Uniaxial Compression Curve\
                       for Material Number $mat"]
            wm title $parent3 [msgcat::mc "Uniaxial Compression Curve\
                       for Material Number $mat"]
            set numcol 1
            set realcol 3
            set numrow 1
            set actrow(1) 1
            $tableName config -colmax 60
            set colmax 20
            $tableName config -rowmax 101
            set rowmax 100
            $parent3 configure -helpcommand [list ans_loadhelp Hlp_cast]
            set tbopt COMP
         }
         UNIATENS {
            euidl::label $childsite.lbl$labelin -height 3 \
                  -anchor w \
                  -text [msgcat::mc "Uniaxial Tension Curve\
                       for Material Number $mat"]
            wm title $parent3 [msgcat::mc "Uniaxial Tension Curve\
                       for Material Number $mat"]
            set numcol 1
            set realcol 3
            set numrow 1
            set actrow(1) 1
            $tableName config -colmax 60
            set colmax 20
            $tableName config -rowmax 101
            set rowmax 100
            $parent3 configure -helpcommand [list ans_loadhelp Hlp_cast]
            set tbopt TENS
         }
         JOINT* {
            #Depending on the value of TBOP, the JOINT table is different
            foreach num { JNSA JNS4 JNS6 JNDA JND4 JND6 JNFA JNF4 JNF6 } {
                if {$labelin == "JOINT$num"} {
                     set tbopt $num
                     set tboptcmd $tbopt
                     break
                }
            }
            #set labelin JOINT
            set text "    "
            switch -exact -- $tbopt {
                     JNSA { set text "Stiffness for ALL dof" }
                     JNS4 { set text "Stiffness for ROTX dof" }
                     JNS6 { set text "Stiffness for ROTZ dof" }
                     JNDA { set text "Damping for ALL dof" }
                     JND4 { set text "Damping for ROTX dof" }
                     JND6 { set text "Damping for ROTZ dof" }
                     JNFA { set text "Friction for ALL dof" }
                     JNF4 { set text "Friction for ROTX dof" }
                     JNF6 { set text "Friction for ROTZ dof" }
            }
            euidl::label $childsite.lbl$labelin -height 3 \
                 -anchor w\
                 -text [msgcat::mc "JOINT Table for Material Number $mat - $text"]
            wm title $parent3 [msgcat::mc "JOINT Table\
                       for Material Number $mat"]
            set numcol 1
            set realcol 3
            set numrow 1
            set actrow(1) 1
            $tableName config -colmax 60
            set colmax 20
            $tableName config -rowmax 101
            set rowmax 100
            $parent3 configure -helpcommand [list ans_loadhelp Hlp_E_CH2jointma]
         }
      }

     grid $childsite.lbl$labelin -sticky new -column 0 -row 0 \
            -columnspan 7
     
     # TBOPT combo box
     if {$labelin == "KINH" || $labelin == "MISO" || $labelin == "PLAS1" || $labelin == "PLAS4"} {
          grid $childsite.lblopt$labelin -sticky nw -column 0 -row 1 \
            -columnspan 1
          grid $childsite.cmb$labelin -sticky nw -column 1  -row 1 \
            -columnspan 6
     }

     #The 2 first rows are TITLES
     $tableName configure -titlerows 2
     
     #set the tags sunken - disabledsunken -disab
     $tableName tag configure sunken -relief sunken \
           -state normal \
           -background  [$tableName cget -cellbackground]
     $tableName tag cell sunken -1,1

     $tableName tag configure disabledsunken -relief sunken \
           -state disabled \
           -background [$tableName cget -disabledbackground]\
           -foreground [$tableName cget -disabledforeground]

     $tableName tag configure disab  -state disabled   
    
     $tableName tag raise sunken title
     $tableName tag raise disabledsunken title
     $tableName tag raise disab title

     #set the default width
     $tableName configure -colwidth 11
     
      # FILL THE TABLE WITH EXISTING DATA IF TABLE EXISTS
      
         set tboptcmd "    "

         switch -glob -- $labelin {
            UNIA* {
               set tboptcmd $tbopt
            }
            GASK* {
               set tboptcmd $tbopt
            }
            JOIN* {
               set tboptcmd $tbopt
            }
         }

      set tb [ans_getvalue $labelin,$mat,EXIS,,,,$tboptcmd]
      if {$tb == 1} {

          #set tbdata(0,-1) Temps
          $tableName width -1 5

          #get the number of temperatures
          set numcol [expr int([ans_getvalue $labelin,$mat,NTEMP,,,,$tboptcmd])]
          #get the value of each temps TVAL & set the labels
          set numcoluse $numcol
          for {set i 1} {$i<=$numcol} {incr i 1} {
             switch -exact -- $labelin {
             FCON {
                 set tbdata(0,[expr ($i-1)*3 ]) Veloc-Re
                 set tbdata(0,[expr ($i-1)*3 +1]) Fcon-FrF
             }
             HFLM {
                 set tbdata(0,[expr ($i-1)*3 ]) Veloc-Re
                 set tbdata(0,[expr ($i-1)*3 +1]) Hf-Nu
             }
             BH {
                 set tbdata(0,[expr ($i-1)*3 ]) H
                 set tbdata(0,[expr ($i-1)*3 +1]) B
             }
             GASKCOMP {
                 set tbdata(0,[expr ($i-1)*3 ]) CLOSURE
                 set tbdata(0,[expr ($i-1)*3 +1]) PRESSURE
             }
             GASKLUNL {
                 set tbdata(0,[expr ($i-1)*3 ]) CLOSURE
                 set tbdata(0,[expr ($i-1)*3 +1]) SLOPE
             }
             GASKNUNL {
                 set tbdata(0,[expr ($i-1)*3 ]) CLOSURE
                 set tbdata(0,[expr ($i-1)*3 +1]) PRESSURE
             }
             JOINTJNSA {
                 set tbdata(0,[expr ($i-1)*3 ]) DISP 
                 set tbdata(0,[expr ($i-1)*3 +1]) FORCE
             }
             JOINTJNS4 {
                 set tbdata(0,[expr ($i-1)*3 ]) ROTATION
                 set tbdata(0,[expr ($i-1)*3 +1]) MOMENT
             }
             JOINTJNS6 {
                 set tbdata(0,[expr ($i-1)*3 ]) ROTATION
                 set tbdata(0,[expr ($i-1)*3 +1]) MOMENT
             }
             JOINTJNDA {
                 set tbdata(0,[expr ($i-1)*3 ]) VELOCITY
                 set tbdata(0,[expr ($i-1)*3 +1]) FORCE
             }
             JOINTJND4 {
                 set tbdata(0,[expr ($i-1)*3 ]) VELOCITY
                 set tbdata(0,[expr ($i-1)*3 +1]) MOMENT
             }
             JOINTJND6 {
                 set tbdata(0,[expr ($i-1)*3 ]) VELOCITY
                 set tbdata(0,[expr ($i-1)*3 +1]) MOMENT
             }
             JOINTJNFA {
                 set tbdata(0,[expr ($i-1)*3 ]) DISP
                 set tbdata(0,[expr ($i-1)*3 +1]) FORCE
             }
             JOINTJNF4 {
                 set tbdata(0,[expr ($i-1)*3 ]) ROTATION
                 set tbdata(0,[expr ($i-1)*3 +1]) MOMENT
             }
             JOINTJNF6 {
                 set tbdata(0,[expr ($i-1)*3 ]) ROTATION
                 set tbdata(0,[expr ($i-1)*3 +1]) MOMENT
             }
             default {
                 set tbdata(0,[expr ($i-1)*3 ]) STRAIN
                 set tbdata(0,[expr ($i-1)*3 +1]) STRESS
             }
             }
             set tbdata(-1,[expr ($i-1)*3 ]) "T$i"
             set tbdata(-1,[expr ($i-1)*3 +1]) [ans_getvalue $labelin,$mat,TVAL,$i,,,$tboptcmd]            
            # mulitiple table in one record
            # a strain value of zero means to ignore the table
            switch -glob -- $labelin {
              UNIA* {
                set checkval [ans_getvalue $labelin,$mat,TEMP,$tbdata(-1,[expr ($i-1)*3 +1]),CONS,1,$tboptcmd]
                if { $checkval == 0 } {
                   set numcoluse [expr $numcoluse - 1]
                }
                if {$i > 1} {
                   if {$tbdata(-1,[expr ($i-1)*3 +1]) == $tbdata(-1,[expr ($i-2)*3 +1])} {
                      set numcoluse [expr $numcoluse - 1]
                   }
                }
              }
            }
          }
          
          set numcol $numcoluse
          
          set usePlast ""
          if {$labelin == "KINH"} {
             set usePlast KINH_TOT
             set tbopt  [ans_getvalue $labelin,$mat,TBOP]
             if {$tbopt == 4} {
                set usePlast KINH_PLAS
             }
          }
          if {$labelin == "MISO"} {
             set usePlast MISO_TOT
             set tbopt  [ans_getvalue $labelin,$mat,TBOP]
             if {$tbopt == 4} {
                set usePlast MISO_PLAS
             }
          }
          if {$labelin == "PLAS1"} {
             set usePlast MISO_PLAS
             set tbopt  [ans_getvalue $labelin,$mat,TBOP]
             if {$tbopt == 4} {
                set usePlast KINH_PLAS
             }
          }
          if {$labelin == "PLAS4"} {
             set usePlast KINH_PLAS
             set tbopt  [ans_getvalue $labelin,$mat,TBOP]
             if {$tbopt == 1} {
                set usePlast MISO_PLAS
             }
          }

          # Loop through each temperature and get the data
          for {set i 0} {$i<$numcol} {incr i 1} {

              #get the number of rows
              #Inside ANSYS the table is row*temp and filled with
              # zeros if not defined
              set numrow [ans_getvalue $labelin,$mat,TEMP,$tbdata(-1,[expr $i*3 +1]),NCONST,,$tboptcmd]
              #There is 2 data pts per row 
              set numrow [expr $numrow/2]
   
         
              set actrow([expr $i+1]) $numrow
             
              for {set j 1} {$j<=$numrow} {incr j 1} {
                 set tbdata($j,-1) $j
                 set k [expr $j*2 -1]
                 set l [expr $j*2]
                 set tbdata($j,[expr $i*3])\
                   [ans_getvalue $labelin,$mat,TEMP,$tbdata(-1,[expr $i*3 +1]),CONS,$k,$tboptcmd]
                 set tbdata($j,[expr $i*3]) [format "%-10.5G" $tbdata($j,[expr $i*3])]
                 set tbdata($j,[expr $i*3]) [string trimright $tbdata($j,[expr $i*3])]

                 set tbdata($j,[expr $i*3+1])\
                   [ans_getvalue $labelin,$mat,TEMP,$tbdata(-1,[expr $i*3 +1]),CONS,$l,$tboptcmd]
                 set tbdata($j,[expr $i*3+1]) [format "%-10.5G" $tbdata($j,[expr $i*3+1])]
                 set tbdata($j,[expr $i*3+1]) [string trimright $tbdata($j,[expr $i*3+1])]
          
         #End of the table when 0,0 is reached
         #avoid the case : only tbtemp defined -> create 2 blank entries
                 if {$j > 1} {
                    if {$tbdata($j,[expr $i*3]) == 0 && $tbdata($j,[expr $i*3 +1]) == 0} {
                       unset tbdata($j,[expr $i*3])
                       unset tbdata($j,[expr $i*3 +1])
                       set actrow([expr $i+1]) [expr $j -1]
                       break
                    }
                 }
              }
           }
          #Recalculate numrow = max actrow(x)
          set numrow $actrow(1)    
          for {set i 1} {$i <= $numcol} {incr i 1} {
             if {$actrow($i) >= $numrow} {
                 set numrow $actrow($i)
                }         
          }
       
       
   
        #configure the tktable
         
        $tableName configure -rows [expr int($numrow) + 2]\
                             -cols [expr int($numcol)*3 + 1]

        #update realcol 
         set realcol [expr $numcol*3]

         #make the unused cells flat
         
          for {set i 1} {$i<=$numcol} {incr i 1} {
             for {set j [expr $actrow($i)+1]} {$j <= $numrow} {incr j 1} {                
                 label $tableName.dum$j{-}[expr ($i-1)*3 ]
                 $tableName window configure $j,[expr ($i-1)*3 ]\
                              -window $tableName.dum$j{-}[expr ($i-1)*3 ]\
                              -sticky news
                 $tableName tag cell disab $j,[expr ($i-1)*3 ]
                 label $tableName.dum$j{-}[expr ($i-1)*3+1]
                 $tableName window configure $j,[expr ($i-1)*3+1]\
                              -window $tableName.dum$j{-}[expr ($i-1)*3+1]\
                              -sticky news
                 $tableName tag cell disab $j,[expr ($i-1)*3+1]
             }
             for {set j 1} {$j <= $numrow} {incr j 1} {
                 label $tableName.dum$j{-}[expr ($i-1)*3+2]
                 $tableName window configure $j,[expr ($i-1)*3+2]\
                              -window $tableName.dum$j{-}[expr ($i-1)*3+2]\
                              -sticky news
                 $tableName tag cell disab $j,[expr ($i-1)*3+2]
             }
             $tableName tag cell sunken -1,[expr ($i-1)*3 +1]
             $tableName width [expr ($i-1)*3 +2] 5
         }
         #now format temperature data
         for {set i 1} {$i<=$numcol} {incr i 1} {
             set tbdata(-1,[expr ($i - 1)*3 + 1]) \
                 [format "%-10.5G" $tbdata(-1,[expr ($i - 1)*3 + 1])]
             set tbdata(-1,[expr ($i - 1)*3 + 1]) \
                 [string trimright $tbdata(-1,[expr ($i - 1)*3 + 1])]    
         }
         # disable temp cells if only one temperature defined
         if {$numcol > 1} {
            $tableName tag cell normaltitle -1,0
            $tableName tag cell sunken -1,1
         } else {
            $tableName tag cell disabledtitle -1,0
            $tableName tag cell disabledsunken -1,1
         }

      #if table does not exist, set the default
      } else {        
         set tbdata(-1,0) T1
         switch -exact -- $labelin {
         FCON {
                 set tbdata(0,0) Veloc-Re
                 set tbdata(0,1) Fcon-FrF
         }
         HFLM {
                 set tbdata(0,0) Veloc-Re
                 set tbdata(0,1) Hf-Nu
         }
         BH {
                 set tbdata(0,0) H
                 set tbdata(0,1) B
         }
         GASKCOMP {
                 set tbdata(0,0) CLOSURE
                 set tbdata(0,1) PRESSURE
         }
         GASKLUNL {
                 set tbdata(0,0) CLOSURE
                 set tbdata(0,1) SLOPE
         }
         GASKNUNL {
                 set tbdata(0,0) CLOSURE
                 set tbdata(0,1) PRESSURE
         }
         JOINTJNSA {
                 set tbdata(0,0) DISP 
                 set tbdata(0,1) FORCE
         }
         JOINTJNS4 {
                 set tbdata(0,0) ROTATION
                 set tbdata(0,1) MOMENT
         }
         JOINTJNS6 {
                 set tbdata(0,0) ROTATION
                 set tbdata(0,1) MOMENT
         }
         JOINTJNDA {
                 set tbdata(0,0) VELOCITY
                 set tbdata(0,1) FORCE
         }
         JOINTJND4 {
                 set tbdata(0,0) VELOCITY
                 set tbdata(0,1) MOMENT
         }
         JOINTJND6 {
                 set tbdata(0,0) VELOCITY
                 set tbdata(0,1) MOMENT
         }
         JOINTJNFA {
                 set tbdata(0,0) DISP 
                 set tbdata(0,1) FORCE
         }
         JOINTJNF4 {
                 set tbdata(0,0) ROTATION
                 set tbdata(0,1) MOMENT
         }
         JOINTJNF6 {
                 set tbdata(0,0) ROTATION
                 set tbdata(0,1) MOMENT
         }
         default {
                 set tbdata(0,0) STRAIN
                 set tbdata(0,1) STRESS
         }
         }
         set tbdata(1,-1) 1
         #set tbdata(-1,-1) Temps
         set tbdata(-1,1) ""

         $tableName width -1 5
         $tableName width 2 5
         $tableName configure -rows [expr $numrow +2] -cols  [expr $realcol+1]
         $tableName tag cell disabledtitle -1,0
         $tableName tag cell disabledsunken -1,1
         label $tableName.dum1{-}2         
         $tableName window configure 1,2 -window $tableName.dum1{-}2\
                              -sticky news 
         $tableName tag cell disab 1,2        
      }     
   
      grid $tableName -sticky news -column 0 -row 2 -columnspan 8
      grid rowconfigure $childsite 2 -weight 1

      # Set the max view height for the table
      grid rowconfigure $childsite 2 -minsize 150

     #BINDINGS

#     bind Entry <Control-KeyPress-t> [code delcolumn  $high $entf $lblcolf \
#             $labelin %W]
#     bind Entry <Control-KeyPress-r> [code delrow  $high $entf $lblrowf \
#             $labelin %W]

#      $parent3 configure \
#            -okcommand [code matOpts_Ok 0 $mat $next] \
#            -cancelcommand [code matOpts_Cancel] \
#            -helpcommand [list ans_loadhelp Hlp_UI_mat_dat]

#      bind $parent3.buttonBox.ok <ButtonPress-1> "+focus %W"
     
      update idletasks
      wm minsize $parent3 [winfo reqwidth $parent3] \
                          [expr [winfo reqheight $parent3] + 50]

      grid propagate $childsite 0
      
#      uidl::registerWindow $parent3
      $parent3 activate

      set treeChildsite $childsite
    
      $tableName selection set 1,0
      $tableName activate 1,0
      $tableName selection anchor 1,0
      $tableName see active

#      bind $tableName <Return> { break }
      plasticitySwitch
      
   }


   #ADD 3 COLUMNS TO THE TABLE# 
   proc addcolumn {} {
        
        variable parent3
        variable tableName
        variable tbdata
        variable labelin
        variable numcol
        variable numrow
        variable realcol
        variable actrow
        variable colmax
        variable treeChildsite
       

        if {$numcol >= $colmax} {
             tk_messageBox -icon warning \
                  -title [msgcat::mc "Maximum Number of columns"] \
                  -type ok \
                  -message [msgcat::mc " This table\
                           allows only $colmax temperatures."]\
                  -parent $parent3
        } else {
        #temp cells are now available
        $tableName tag cell normaltitle -1,0
        $tableName tag cell sunken -1,1

        # curColumn is the column having the focus in (cursor)
        if {[catch {$tableName index active col} curColumn]} {
           set curColumn 0
        }
        # you want to set Curcolumn = 3*N+2 
        for {set i 1} {$i <= $numcol} {incr i 1} {
                set toto [expr ($i-1) * 3]
                set tata [expr (($i -1) * 3)+1]
                if {$curColumn == $toto} {
                   set curColumn [expr $curColumn +2]
                }  elseif {$curColumn == $tata} {
                   set curColumn [expr $curColumn + 1]
                }
        }
       
        # Insert 3 columns after curColumn
            
        $tableName insert col -keeptitles -- $curColumn 3

        # Move the view to see added column
        $tableName xview scroll 1 unit

        incr numcol 1

        
        #reorganize actrow table
        set h [expr int($curColumn/3 +1)]
        for {set i $numcol} {$i > [expr $h+1]} {incr i -1} {
                 set actrow($i) $actrow([expr $i-1])
            }
        set actrow([expr $h+1]) 1
        
         #create all the flat cells for th cols that have been moved
        
        for {set i $numcol} {$i > [expr $h+1]} {incr i -1} {
           
            for {set b [expr $actrow($i)+1]} {$b <= $numrow} {incr b 1} {
                set z [expr $i*3 -3]
                catch {label  $tableName.dum$b{-}$z}
                $tableName window configure $b,$z\
                              -window $tableName.dum$b{-}$z\
                              -sticky news
                $tableName tag cell disab $b,$z
                catch {label  $tableName.dum$b{-}[expr $z+1]}
                $tableName window configure $b,[expr $z+1]\
                              -window $tableName.dum$b{-}[expr $z+1]\
                              -sticky news
                $tableName tag cell disab $b,[expr $z+1]
            } 
            for {set b 1} {$b <= $numrow} {incr b 1} {
                set z [expr $i*3 -3]
                catch {label  $tableName.dum$b{-}[expr $z+2]}
                $tableName window configure $b,[expr $z+2]\
                              -window $tableName.dum$b{-}[expr $z+2]\
                              -sticky news 
                $tableName tag cell disab $b,[expr $z+2]   
            }                
        }

        # make the cells in the new column flat (except the 2 first)
        for {set i 2} {$i <=$numrow} {incr i 1} {
            catch {label  $tableName.dum$i{-}[expr $curColumn +1]}
            $tableName window configure $i,[expr $curColumn +1]\
                              -window $tableName.dum$i{-}[expr $curColumn +1]\
                              -sticky news
            $tableName tag cell disab $i,[expr $curColumn +1]
            catch {label  $tableName.dum$i{-}[expr $curColumn +2]}
            $tableName window configure $i,[expr $curColumn +2]\
                              -window $tableName.dum$i{-}[expr $curColumn +2]\
                              -sticky news
            $tableName tag cell disab $i,[expr $curColumn +2]
            catch {label  $tableName.dum$i{-}[expr $curColumn +3]}
            $tableName window configure $i,[expr $curColumn +3]\
                              -window $tableName.dum$i{-}[expr $curColumn +3]\
                              -sticky news
            $tableName tag cell disab $i,[expr $curColumn +3]
           
        }
       

        # Label this new column
        set tbdata(-1,$realcol) "T$numcol"
        switch -exact -- $labelin { 
        FCON {
                 set tbdata(0,$realcol) Veloc-Re
                 set tbdata(0,[expr $realcol +1]) Fcon-FrF
        } 
        HFLM {
                 set tbdata(0,$realcol) Veloc-Re
                 set tbdata(0,[expr $realcol +1]) Hf-Nu
        }
        BH {
                 set tbdata(0,$realcol) H
                 set tbdata(0,[expr $realcol +1]) B
        }
        GASKCOMP {
                 set tbdata(0,$realcol) CLOSURE
                 set tbdata(0,[expr $realcol +1]) PRESSURE
        }
        GASKLUNL {
                 set tbdata(0,$realcol) CLOSURE
                 set tbdata(0,[expr $realcol +1]) SLOPE
        }
        GASKNUNL {
                 set tbdata(0,$realcol) CLOSURE
                 set tbdata(0,[expr $realcol +1]) PRESSURE
        }
        JOINTJNSA {
                 set tbdata(0,$realcol) DISP
                 set tbdata(0,[expr $realcol +1]) FORCE
        }
        JOINTJNS4 {
                 set tbdata(0,$realcol) ROTATION
                 set tbdata(0,[expr $realcol +1]) MOMENT
        }
        JOINTJNS6 {
                 set tbdata(0,$realcol) ROTATION
                 set tbdata(0,[expr $realcol +1]) MOMENT
        }
        JOINTJNDA {
                 set tbdata(0,$realcol) VELOCITY
                 set tbdata(0,[expr $realcol +1]) FORCE
        }
        JOINTJND4 {
                 set tbdata(0,$realcol) VELOCITY
                 set tbdata(0,[expr $realcol +1]) MOMENT
        }
        JOINTJND6 {
                 set tbdata(0,$realcol) VELOCITY
                 set tbdata(0,[expr $realcol +1]) MOMENT
        }
        JOINTJNFA {
                 set tbdata(0,$realcol) DISP
                 set tbdata(0,[expr $realcol +1]) FORCE
        }
        JOINTJNF4 {
                 set tbdata(0,$realcol) ROTATION
                 set tbdata(0,[expr $realcol +1]) MOMENT
        }
        JOINTJNF6 {
                 set tbdata(0,$realcol) ROTATION
                 set tbdata(0,[expr $realcol +1]) MOMENT
        }
        default {
                 set tbdata(0,$realcol) STRAIN
                 set tbdata(0,[expr $realcol +1]) STRESS
        }     
        }
        $tableName tag cell sunken -1,[expr $realcol +1]
        catch {label $tableName.dum1{-}[expr $curColumn +3]}
        $tableName window configure 1,[expr $curColumn +3]\
                  -window $tableName.dum1{-}[expr $curColumn +3]\
                  -sticky news
        $tableName tag cell disab 1,[expr $curColumn +3]
        $tableName width [expr $curColumn +3] 5
        
        #update realcol
        incr realcol 3 

        #Move the temperature data
        for {set i [expr $realcol -2]} {$i > [expr $curColumn +3]} {incr i -3} {
             if {[catch {set tbdata(-1,$i) $tbdata(-1,[expr $i-3])}]} {
                         set tbdata(-1,$i) ""
                }
        }
        #set the new temp data to blank
        set tbdata(-1,[expr $curColumn +2]) ""
       
  
        update
        #activate the new column
        $tableName selection activate -1,[expr $curColumn +2]
        $tableName see active
        }

   }


   #ADD A ROW IN THE TABLE#
   proc addrow {} {
        
        variable parent3
        variable tableName
        variable tbdata
        variable labelin
        variable numrow
        variable numcol
        variable realcol
        variable actrow
        variable rowmax
        variable treeChildsite

       
         # curRow is the column having the focus in (cursor)
        if {[catch {$tableName index active row} curRow]} {
           set curRow 1
        }
        if {$curRow <= 0} {
           set curRow 1
        }
        if {[catch {$tableName index active col} curColumn]} {
           set curColumn 0
        }
        if {$curColumn < 0 } {
           set curColumn 0
        }
       
        #h is the temperature index...h has values between 1 and numcol
        set h [expr int($curColumn/3 +1)]

        if {$actrow($h) >= $rowmax} {
             tk_messageBox -icon warning \
                  -title [msgcat::mc "Maximum Number of points"] \
                  -parent $parent3 \
                  -type ok \
                  -message [msgcat::mc " This table \
                        allows only $rowmax points."]
             return
        } 

        # Insert a row after the currently selected one if actrow(h) = numrow
        # in this case you have to create a new row
        # if actrow(h) < numrow you just want to sunken 2 cells

        if {$actrow($h) == $numrow && $curRow > 0} {
           
            #insert a row at the end of the table   
            $tableName insert row -keeptitles -- $actrow($h) 1

            # Move the view to see added row
            #$tableName yview scroll 1 unit

            incr numrow

            # Label this new row
            set tbdata($numrow,-1) $numrow

            #make flat all the new cells in the new row
            for {set w 0} {$w < $realcol} {incr w 1} {
               catch {label $tableName.dum$numrow{-}$w}
               $tableName window configure $numrow,$w\
                  -window $tableName.dum$numrow{-}$w\
                  -sticky news
               $tableName tag cell disab $numrow,$w
            }

            #set curColumn = 3N+1
            for {set i 1} {$i <= $numcol} {incr i 1} {
                set toto [expr ($i-1) * 3]
                set tata [expr (($i -1) * 3)+2]
                if {$curColumn == $toto} {
                   set curColumn [expr $curColumn +1]
                }  elseif {$curColumn == $tata} {
                   set curColumn [expr $curColumn - 1]
                }               
            }
           
            #update the number of active rows for this column
            set actrow($h) [expr $actrow($h) +1]
           
            #make the two cells sunken in the right columns
            destroy $tableName.dum$numrow{-}[expr $curColumn -1]
            destroy $tableName.dum$numrow{-}$curColumn
            $tableName tag cell sunken $numrow,[expr $curColumn -1]
            $tableName tag cell sunken $numrow,$curColumn 

            #move the data if necessary
            for {set i $actrow($h)} {$i > $curRow} {incr i -1} {
               if {[catch {set tbdata($i,$curColumn) \
                            $tbdata([expr $i-1],$curColumn)}]} {
                   set  tbdata($i,$curColumn) ""
               }
               if {[catch {set tbdata($i,[expr $curColumn -1]) \
                            $tbdata([expr $i-1],[expr $curColumn -1])}]} {
                   set tbdata($i,[expr $curColumn -1]) ""
               }
            }
            set tbdata([expr $curRow +1],$curColumn) ""
            set tbdata([expr $curRow +1],[expr $curColumn -1]) ""

        
        } elseif {$actrow($h) < $numrow && $curRow > 0} {
            # in this case you just want to sunken 2 cells
           
            # Move the view to see added row
            #$tableName yview scroll 1 unit

            #set curColumn = 3N+1
            for {set i 1} {$i <= $numcol} {incr i 1} {
                set toto [expr ($i-1) * 3]
                set tata [expr (($i -1) * 3)+2]
                if {$curColumn == $toto} {
                   set curColumn [expr $curColumn +1]
                }  elseif {$curColumn == $tata} {
                   set curColumn [expr $curColumn - 1]
                }
            }

            #update the number of active rows for this column
            set actrow($h) [expr $actrow($h) +1]
            destroy $tableName.dum[expr $actrow($h)]{-}[expr $curColumn -1]
            destroy $tableName.dum[expr $actrow($h)]{-}$curColumn
            $tableName tag cell sunken [expr $actrow($h)],[expr $curColumn -1]
            $tableName tag cell sunken [expr $actrow($h)],$curColumn 

            #Only move the data - no adding rows
            for {set i $actrow($h)} {$i > $curRow} {incr i -1} {
                
               if {[catch {set tbdata($i,$curColumn) \
                            $tbdata([expr $i-1],$curColumn)}]} {
                   set  tbdata($i,$curColumn) ""
               }
               if {[catch {set tbdata($i,[expr $curColumn -1]) \
                            $tbdata([expr $i-1],[expr $curColumn -1])}]} {
                   set tbdata($i,[expr $curColumn -1]) ""
               }
            }
            set tbdata([expr $curRow +1],$curColumn) ""
            set tbdata([expr $curRow +1],[expr $curColumn -1]) ""
       } 
       update
       #activate the new row
       $tableName selection activate [expr $curRow +1],$curColumn
       $tableName see active
            
   }

    #Check the rows selected and call delrow for each of them#
    #default to the last one created#

    proc rowselect {} {

        variable parent3
        variable tableName
        variable treeChildsite

        #create a list of sorted selected cells format {0,0 0,1 ....}
        set listcell [$tableName curselection]
        set length [llength $listcell]

        #get the first cell and the last cell selected
        set first [lindex  $listcell 0]
        set lastind [expr $length -1]
        set last [lindex  $listcell $lastind]
        
        #get the first and the last row 
        set firstlis [split $first ,]
        set firstrow  [lindex  $firstlis 0]
       
        catch {$tableName index active col} curColumn
        catch {$tableName index active row} curRow
       
        set lastlis [split $last ,]
        set lastrow  [lindex  $lastlis 0]
       
       
        if {$length == 0} {
            
             if {[catch {$tableName index active row} firstrow]} {
               set firstrow 2
             }
             set lastrow $firstrow
        }
 
        #Delete all the rows selected
        if { $curColumn < 0 && $curRow < 1 } {
           tk_messageBox -icon warning \
               -message [msgcat::mc "Cannot delete entire table.  You must select a point first"] \
               -parent $parent3
        } elseif { $curColumn < 0 } {
           tk_messageBox -icon warning \
               -message [msgcat::mc "Cannot delete entire row.  You must select a point first"] \
               -parent $parent3
        } elseif { $curRow < 1 } {
           tk_messageBox -icon warning \
               -message [msgcat::mc "Cannot delete entire column.  You must select a point first"] \
               -parent $parent3
        } else {
           for {set i $firstrow} {$i <= $lastrow} {incr i 1} {
              delrow $firstrow
           }
        }

   }
    
    #Check the cols selected and call delcolumn for each of them#
    #default to the last one created#

    proc colselect {} {

        variable tableName
        variable numcol
        

        #create a list of sorted selected cells format {0,0 0,1 ....}
        set listcell [$tableName curselection]
        set length [llength $listcell]

        #get the first cell and the last cell selected
        set first [lindex  $listcell 0]
        set lastind [expr $length -1]
        set last [lindex  $listcell $lastind]
        
        #get the first and the last columns
        set firstlis [split $first ,]
        set firstcol [lindex  $firstlis 1]
       
        set lastlis [split $last ,]
        set lastcol  [lindex  $lastlis 1]
       
        if {$length == 0} {
            
             if {[catch {$tableName index active col} firstcol]} {
               set firstcol 3
             }
             set lastcol $firstcol
        }
        #convert firstcol & lastcol = 3N
        for {set i 1} {$i <= $numcol} {incr i 1} {
               set toto [expr (($i-1) * 3)+1]
               set tata [expr (($i -1) * 3)+2]
               if {$firstcol == $toto} {
                   set firstcol [expr $firstcol -1]
               }  elseif {$firstcol == $tata} {
                   set firstcol [expr $firstcol - 2]
               }
               if {$lastcol == $toto} {
                   set lastcol [expr $lastcol -1]
               }  elseif {$lastcol == $tata} {
                   set lastcol [expr $lastcol - 2]
               }
        }
        #Delete all the columns selected
        for {set i $firstcol} {$i <= $lastcol} {incr i 3} {
            delcolumn $firstcol
        }
        
   }
    #DELETE A COLUMN IN THE TABLE#

    proc delcolumn { curColumn } {

        variable parent3
        variable tableName
        variable labelin
        variable tbdata
        variable numcol
        variable numrow
        variable actrow
        variable realcol
        variable treeChildsite

       
        
        if {$numcol >= 2} {
            #if {[catch {$tableName index active col} curColumn]} {
            #   set curColumn 3
            #}
            #set curColumn = 3N
            #for {set i 1} {$i <= $numcol} {incr i 1} {
            #   set toto [expr (($i-1) * 3)+1]
            #   set tata [expr (($i -1) * 3)+2]
            #   if {$curColumn == $toto} {
            #       set curColumn [expr $curColumn -1]
            #   }  elseif {$curColumn == $tata} {
            #       set curColumn [expr $curColumn - 2]
            #   }
            #}

           

            #reorganize actrow table
            set h [expr int($curColumn/3 +1)]
            for {set i $h} {$i < $numcol} {incr i 1} {
                 set actrow($i) $actrow([expr $i+1])
            }
            set actrow($numcol) 0
            
            #update numcol & realcol
            set numcol [expr $numcol - 1]
            set realcol [expr $realcol - 3]

            #Move the temperature data

            for {set i [expr $curColumn +1]} {$i < [expr $realcol +1]} {incr i 3} {
                   set tbdata(-1,$i) $tbdata(-1,[expr $i+3])
            }
            set tbdata(-1,[expr $realcol +1]) 0 

           
            #delete 3 columns after CurColumn
            $tableName delete cols -keeptitles -- $curColumn 3
         
            #deactivate the temp cells if only one
            if {$numcol < 2} {
               $tableName tag cell disabledtitle -1,0
               $tableName tag cell disabledsunken -1,1
      
            }

            #delete some rows if the biggest column is destroyed
          
            set store  $numrow
            set numrow  $actrow(1)
           
            #recalculate numrow = max actrow(x)
            for {set i 2} {$i <= $numcol} {incr i 1} {
                if {$actrow($i) >= $numrow} {
                   set numrow $actrow($i)
                }
             }
            set number [expr $store - $numrow]
            #delete the unused row
            $tableName delete row -keeptitles -- [expr $numrow+1] $number

             #create all the flat cells for the cols that have been moved
 
            for {set i $numcol} {$i >= $h} {incr i -1} {
                for {set b [expr $actrow($i)+1]} {$b <= $numrow} {incr b 1} {
                   set z [expr $i*3 -3]
                   catch {label  $tableName.dum$b{-}$z}
                   $tableName window configure $b,$z\
                              -window $tableName.dum$b{-}$z\
                              -sticky news
                   $tableName tag cell disab $b,$z
                   catch {label  $tableName.dum$b{-}[expr $z+1]}
                   $tableName window configure $b,[expr $z+1]\
                              -window $tableName.dum$b{-}[expr $z+1]\
                              -sticky news
                   $tableName tag cell disab $b,[expr $z+1]
                } 
                for {set b 1} {$b <= $numrow} {incr b 1} {
                   set z [expr $i*3 -3]
                   catch {label  $tableName.dum$b{-}[expr $z+2]}
                   $tableName window configure $b,[expr $z+2]\
                              -window $tableName.dum$b{-}[expr $z+2]\
                              -sticky news 
                   $tableName tag cell disab $b,[expr $z+2]   
               }                
           }            

        } else {
           tk_messageBox -icon warning \
               -message [msgcat::mc "Cannot remove any more columns"] \
               -parent $parent3
        }
        
   }
   #DELETE A ROW IN THE TABLE#

   proc delrow {curRow} {
        
        variable parent3
        variable tableName
        variable tbdata
        variable labelin
        variable numrow
        variable numcol
        variable realcol
        variable actrow
        variable treeChildsite

        #Procedure: 1-make the 2 last cells flat and move the data
        #           2-if the last row is unused, delete it

        if {[catch {$tableName index active col} curColumn]} {
           set curColumn 1
        }
        set h [expr int($curColumn/3 +1)]
       
        if {$actrow($h) > 1} {
            
         
           #if {[catch {$tableName index active row} curRow]} {
           #   set curRow 1
           #}
              

           #set curColumn = 3N+1
           for {set i 1} {$i <= $numcol} {incr i 1} {
                set toto [expr ($i-1) * 3]
                set tata [expr (($i -1) * 3)+2]
                if {$curColumn == $toto} {
                   set curColumn [expr $curColumn +1]
                }  elseif {$curColumn == $tata} {
                   set curColumn [expr $curColumn - 1]
                }               
           }
           
           #make the 2 last cells flat
          
           label $tableName.dum$actrow($h){-}[expr $curColumn -1]
           $tableName window configure $actrow($h),[expr $curColumn -1]\
                              -window $tableName.dum$actrow($h){-}[expr $curColumn -1]\
                              -sticky news
           $tableName tag cell disab $actrow($h),[expr $curColumn -1]
           label $tableName.dum$actrow($h){-}$curColumn
           $tableName window configure $actrow($h),$curColumn\
                              -window $tableName.dum$actrow($h){-}$curColumn\
                              -sticky news
           $tableName tag cell disab $actrow($h),$curColumn

           #move the data if necessary
           for {set i $curRow} {$i < $actrow($h)} {incr i 1} {
               if {[catch {set tbdata($i,$curColumn) \
                            $tbdata([expr $i+1],$curColumn)}]} {
                   set  tbdata($i,$curColumn) ""
               }
               if {[catch {set tbdata($i,[expr $curColumn -1]) \
                            $tbdata([expr $i+1],[expr $curColumn -1])}]} {
                   set tbdata($i,[expr $curColumn -1]) ""
               }
           }
           set tbdata($actrow($h),$curColumn) ""
           set tbdata($actrow($h),[expr $curColumn -1]) ""

           #update the number of active rows for this column
           set actrow($h) [expr $actrow($h) -1]

           #if all the cells are flat in the last row , delete it !
           
           set flag 0
           for {set i 1} {$i <= $numcol} {incr i 1} {
              if {$actrow($i) == $numrow} {
                  set flag 888
              }
           }
           if {$flag != 888} {          
                $tableName delete row -keeptitles -- $numrow 1
                set numrow [expr $numrow -1]
           }

        } else {
            tk_messageBox -icon warning \
               -message [msgcat::mc "Cannot remove any more rows"] \
               -parent $parent3
        }                        
   }

    proc plasticitySwitch {} {
      variable usePlast
      variable labelin
      variable tbopt
  
      if {[info exists usePlast]} {
         if {$usePlast == "MISO_TOT"} {
            set labelin MISO
            set tbopt 0
         }
         if {$usePlast == "MISO_PLAS"} {
            set labelin PLAS1
            set tbopt 1
         }
         if {$usePlast == "KINH_TOT"} {
            set labelin KINH
            set tbopt 0
         }
         if {$usePlast == "KINH_PLAS"} {
            set labelin PLAS4
            set tbopt 4
         }
      }
    }

    proc graph { graBH matcopy } {

      variable ::euidl::material::ModelControl::matModelArr

      variable labelin
      variable grpher
      variable tbopt

      set grpher 0

      # Lower the windows so that the graph isn't obscurred in 3D
      lower $matModelArr(parent)
      update

      #set a dummy mat ID

      set matgr [ans_evalexpr mpinqr(0,0,14)]
      set matgr [expr $matgr +1]

      if {$labelin == "GASKLUNL"} {
         catch {ans_sendcommand \
            )TBCOPY,GASK,$matcopy,$matgr} 
         catch {ans_sendcommand \
            )TBDEL,GASK,$matgr,,,LUNL}
      }
        
      #call  matOpts_Ok with flag on
      matOpts_Ok 777 $matgr 0

      set def [ans_evalexpr mpinqr($matgr,0,1)]
      if {$def == 0} {
          return
      }
      if {$grpher != 999} {
        switch -glob -- $labelin {
        BH {
           catch {ans_sendcommand \
           )TBPL,$graBH,$matgr,,,,,,,PREV} 
        }
        JOIN* {
           catch {ans_sendcommand \
              )TBPL,$labelin,$matgr,$tbopt,,,,,,PREV} 
        }
        default {
           catch {ans_sendcommand \
              )TBPL,$labelin,$matgr,,,,,,,PREV}                 
        }
        }
      }
      ans_sendcommand )/NOPR
      catch {ans_sendcommand )TBDE,$labelin,$matgr}
      ans_sendcommand )/GO

      after 1000 [list raise $matModelArr(parent)]
   }

   proc matOpts_Ok { flag mat next} {
   
      variable parent3
      variable labelin
      variable numcol
      variable numrow
      variable realcol
      variable actrow
      variable tbdata
      variable treeChildsite
      variable tableName
      variable grpher
      variable tbopt
       
      # Indicate that a material has changed its values
      variable ::euidl::material::ModelControl::localMatlInfoArr
      if {[info exists localMatlInfoArr]} {
         set localMatlInfoArr(matl,$mat,chng) 1
      }
      
         # set this for partial table deletion
         set tboptcmd "    "

         switch -glob -- $labelin {
            UNIA* {
               set tboptcmd $tbopt
            }
            GASK* {
               set tboptcmd $tbopt
            }
            JOIN* {
               set tboptcmd $tbopt
            }
         }

      #Reorder TEMPERATURE - Create a list 
      for {set i 1} {$i<[expr $numcol*3 +1]} {incr i 3} {

         if { [info exists tbdata(-1,$i)] } {
            if {  $tbdata(-1,$i) == "" } {
                   set tbdata(-1,$i) 0
            }       
         } else {
            set tbdata(-1,$i) 0
         }
         if {[catch {lappend tempData $tbdata(-1,$i)}]} {
              set tbdata(-1,$i) 0
              lappend tempData $tbdata(-1,$i)
            }
      }
     
      # Sort the temperatures into a list
      if {[catch {set tempSort [lsort -real -unique $tempData]}]} {
         catch {unset tempData2}
         foreach junktemp $tempData {
            regsub -all { } $junktemp {} junktemp
            if {[catch {ans_evalexpr $junktemp}]} {
               #set junktemp 0
                return
            } else {
               set junktemp [ans_evalexpr $junktemp]
            }
            lappend tempData2 $junktemp
         }
         set tempData $tempData2
         set tempSort [lsort -real -unique $tempData]
      }
      if {[llength $tempData] != [llength $tempSort]} {
         set tl {}
         set tempSort [lsort -real $tempData]
         set tl [lindex $tempSort 0]
         for {set i 1} {$i < [llength $tempSort]} {incr i} {
            if {[lindex $tempSort $i] == $tl} {    
               tk_messageBox -icon error \
                     -message [::msgcat::mc "There are multiple temperatures \
                        with value of $tl"] \
                     -parent $parent3
               break
            }
            set tl [lindex $tempSort $i]
         }
         return
      }

      # We have a valid sorted temperature list tempSort
      
      #TB command
      ans_sendcommand )/NOPR

      set tb [ans_getvalue $labelin,$mat,EXIS,,,,$tboptcmd]
      if {$tb == 1} {
         catch {ans_sendcommand TBDE,$labelin,$mat,,,$tboptcmd}
      }
      # set temp labels for TB,PLAS do not want to affect anything else
      if {$labelin == "PLAS1" || $labelin == "PLAS4"} {
         set labelin "PLAS"
         set tboptsave $tbopt
         if {$tbopt == 1} {
            set tbopt "MISO"
         }
         if {$tbopt == 4} {
            set tbopt "KINH"
         }
      }
      if {$flag != 777} {
          ans_sendcommand )/GO 
          if {[catch {ans_sendcommand \
                        TB,$labelin,$mat,$numcol,$numrow,$tbopt}]} {
#                        catch {ans_sendcommand TBDE,$labelin,$mat}
                        return
          }     
          
      } else {
          if {[catch {ans_sendcommand \
                        )TB,$labelin,$mat,$numcol,$numrow,$tbopt}]} {
                       set grpher 999 
                       return
          }
      }

      if {$labelin == "PLAS"} {
         set tbopt $tboptsave
         set labelin "PLAS$tbopt"
      }

      #TBTEMP-TBPT Command -Loop through the table

      foreach temp $tempSort {
         set i [lsearch $tempData $temp]
         if {$labelin != "BH"} {
            if {$flag != 777} {
                catch {ans_sendcommand TBTEMP,$temp}
            } else {
                catch {ans_sendcommand )TBTEMP,$temp}
            }
         }

         for {set j 1} {$j <= $actrow([expr $i+1])} {incr j 1} { 
               
               #if {[catch {ans_evalexpr $tbdata($j,[expr $i *3])}]} {
               #   set tbdata($j,[expr $i *3]) ""
               #}
               if {[catch {set c(1) $tbdata($j,[expr $i *3])}]} {
                  set c(1) ""
               }
               regsub -all { } $c(1) {} c(1) 
               #if {[catch {ans_evalexpr $tbdata($j,[expr $i *3 + 1])}]} {
               #   set tbdata($j,[expr $i *3 +1]) ""
               #}
               if {[catch {set c(2) $tbdata($j,[expr $i *3 +1])}]} {
                  set c(2) ""
               }
               regsub -all { } $c(2) {} c(2)
               if {$flag != 777} {
                  if {[catch {ans_sendcommand TBPT,,$c(1),$c(2)}]} {
                     ans_sendcommand )/NOPR
                     catch {ans_sendcommand TBDE,$labelin,$mat,,,$tboptcmd}
                     ans_sendcommand )/GO
                     return
                  }
               } else {
                  if {[catch {ans_sendcommand )TBPT,,$c(1),$c(2)}]} {
                     set grpher 999
                     ans_sendcommand )/GO
                     return
                  }
               }
         }
      }
      ans_sendcommand )/GO

      if {$flag != 777} {
        # Unset the variables to make sure the table table is clean
        # on reentry.

        unset numcol
        unset realcol
        unset actrow
        unset numrow
        unset tbdata

        destroy $parent3
        unset parent3
        if {$next != 999} {
           #call next table and don't restart for combined models
           if {$next != 0} {
              euidl::material::ModelControl::table_choice $next $mat 0
              return
           } else {
             euidl::material::ModelControl::matTable_State 1
             return
           }
        }
      }
   }


   proc matOpts_Cancel {} {
      variable parent3
      variable numcol
      variable numrow
      variable actrow
      variable realcol
      variable tbdata

      unset tbdata
      unset numcol
      unset numrow
      unset realcol
      unset actrow
      destroy $parent3
      unset parent3
      
      euidl::material::ModelControl::matTable_State 1
   }

}

#
# ============================================================================
# File Name:     table4.eui
# Description:   TB Dialog box for the following labels
#                ANIS,DP,MKIN,EVIS,CREE(tbop=0),ANAN,PIEZ, (PIEZ2,PIEZ3),PZRS
#                WATE, FAIL, SWEL, DPER
#                All these tables are fixed (not dynamic)
# ============================================================================
namespace eval ::euidl::material::mat4 {
   
   proc TABLE4 {label matid next} {
      
      variable ::euidl::material::ModelControl::matModelArr

      variable numcol
      variable numrow
      variable tbdata
      variable labelin
      variable tbopt 

      set labelin $label
      set tbopt 0
     
      variable parent4
      variable childsite
      variable tableName
      variable treeChildsite
      variable confirm

      euidl::material::ModelControl::matTable_State 0

      if [winfo exists .dlgMatOpts] {
         # Set the display correctly
         $parent4 activate
         return
      }


      set parent4 [euidl::dialog .dlgMatOpts -class EUIDL \
            -master $matModelArr(parent) \
            ]
      set childsite [$parent4 component childsite]

      #SET WINDOW#

      wm minsize $parent4 650 350
    
      set mat $matid

      set tableName [euidl::table $childsite.tbl1 \
            -variable [scope tbdata] \
            -rowseparator \n \
            -colseparator \t \
            -validate focusout \
            -validatedata ansreal \
         ]

         
      
     

      #GRAPH BUTTON

      euidl::button $childsite.graph -text [msgcat::mc "Graph"]\
            -command [code graph]
      grid $childsite.graph -sticky e -column 6 -row 3

      bind $childsite.graph <ButtonRelease-1> \
                  [code ::euidl::material::error::check %W]

      grid columnconfigure $childsite 2 -minsize 50
      grid columnconfigure $childsite 5 -minsize 50
      grid columnconfigure $childsite 6 -weight 1

      $parent4 configure \
            -okcommand [code matOpts_Ok 0 $mat $next] \
            -cancelcommand [code matOpts_Cancel] \
            -helpcommand [list ans_loadhelp Hlp_UI_mat_dat]
      

      # COMMAND DESCRIPTION-HAVE TO CHANGE THE MESSAGE DEPENDING ON THE LABEL
      #set number of cols and rows depending on the label

      switch -exact -- $labelin {
         ANIS {
             euidl::label $childsite.lbl$labelin -height 3 \
                  -anchor w \
                  -text [msgcat::mc "Anisotropic Hardening \
                        for Material Number $mat"]
             wm title $parent4 [msgcat::mc "Anisotropic\
                  Hardening for Material Number $mat"]
             set numcol 3
             set numrow 6
             set tbdata(-1,0) "X"
             set tbdata(-1,1) "Y" 
             set tbdata(-1,2) "Z"
             set tbdata(0,-1) "Tens Yld"
             set tbdata(1,-1) "Tens Tang"
             set tbdata(2,-1) "Comp Yld"
             set tbdata(3,-1) "Comp Tang"
             set tbdata(4,-1) "Shr Yld"
             set tbdata(5,-1) "Shr Tang"
             wm minsize $parent4 540 300
             $childsite.graph configure -state disabled
             $parent4 configure -helpcommand [list ans_loadhelp Hlp_E_CH2anis]

         }
        DPER {
             euidl::label $childsite.lbl$labelin -height 3 \
                  -anchor w \
                  -text [msgcat::mc "Anisotropic Permittivity \
                        for Material Number $mat"]
             wm title $parent4 [msgcat::mc "Anisotropic\
                  Permittivity for Material Number $mat"]
             euidl::label $childsite.lblopt$labelin -height 3 -anchor nw \
                    -text  [msgcat::mc "Permittivity Matrix Options  "]
             euidl::combobox  $childsite.cmb$labelin -width 32  \
                 -variable [scope tbopt]
             $childsite.cmb$labelin insert list end\
                 [list {Permittivity matrix at constant strain} 0\
                       {Permittivity matrix at constant stress} 1\
                 ]
             set tbopt 0
             set numcol 1
             set numrow 6
             set tbdata(-1,0) "Matrix"
             set tbdata(0,-1) "EP11"
             set tbdata(1,-1) "EP22"
             set tbdata(2,-1) "EP33"
             set tbdata(3,-1) "EP12"
             set tbdata(4,-1) "EP23"
             set tbdata(5,-1) "EP13"
             wm minsize $parent4 240 300
             $childsite.graph configure -state disabled
             $parent4 configure -helpcommand [list ans_loadhelp Hlp_E_CH2dper]

         }
         MKIN {
              euidl::label $childsite.lbl$labelin -height 3 \
                    -anchor w\
                    -text [msgcat::mc "Multilinear Kinematic\
                       Hardening for Material Number $mat"]
              wm title $parent4 [msgcat::mc " Multilinear Kinematic\
                  Hardening for Material Number $mat"]
              euidl::label $childsite.lblopt$labelin -height 3 -anchor nw \
                    -text  [msgcat::mc "Stress-Strain Options"]
              euidl::combobox  $childsite.cmb$labelin -width 25  \
                 -variable [scope tbopt]
              $childsite.cmb$labelin insert list end\
                 [list {No stress relaxation} 0\
                       {Recal. Total Plas Strain} 1\
                       {Scale layer Plas Strains} 2\
                 ] 
              set tbopt 0
              set tbdata(-1,0) "Temp"
              set tbdata(0,-1) "Strain"
              for {set i 1} {$i <= 5 } {incr i 1} {
                   set tbdata(-1,$i) "Point$i"
                   set tbdata($i,-1) "Curve$i"
              }
              set numcol 6
              set numrow 6
              $tableName tag cell disabled 0,0
              $parent4 configure -helpcommand [list ans_loadhelp Hlp_E_CH2mkin]

         }
          EVIS {
              euidl::label $childsite.lbl$labelin -height 3\
                    -anchor w \
                    -text [msgcat::mc "Viscoelasticity \
                         for Material Number $mat"]
              wm title $parent4 [msgcat::mc "  Viscoelasticity\
                  for Material Number $mat"]
              for {set i 0} {$i < 5} {incr i 1} {
                 set tbdata(-1,$i) [expr $i+1]
              }
              for {set i 1} {$i <= 19} {incr i 1} {
                 set j [expr $i*5 -4]
                 set k [expr $i*5]
                 set tbdata([expr $i-1],-1) "C$j-C$k" 
              }
              $childsite.graph configure -state disabled
              set numcol 5
              set numrow 19
              $parent4 configure -helpcommand [list ans_loadhelp Hlp_E_CH2evis]
          }
          CREE {
              euidl::label $childsite.lbl$labelin -height 3 \
                      -anchor w\
                      -text [msgcat::mc "Explicit Creep Table for Material Number $mat"]
              wm title $parent4 [msgcat::mc "  Creep Table \
                  for Material Number $mat"]
              
             
              for {set i 0} {$i < 6} {incr i 1} {
                 set tbdata(-1,$i) [expr $i+1]
              }
              for {set i 1} {$i <= 12} {incr i 1} {
                 set j [expr $i*6 -5]
                 set k [expr $i*6]
                 set tbdata([expr $i -1],-1) "C$j-C$k" 
              }
              $childsite.graph configure -state disabled
              set numrow 12
              
              set numcol 6
              $parent4 configure -helpcommand [list ans_loadhelp Hlp_E_CH2cree]
          }
          DP1 {
              set labelin DP
              set tbopt 1
              euidl::label $childsite.lbl$labelin -height 3 \
                     -anchor w \
                     -text [msgcat::mc "Drucker Prager Table \
                           for Material Number $mat"]
              wm title $parent4 [msgcat::mc "Drucker\
                   Prager for Material Number $mat"]
              set tbdata(-1,0) "Cohesion"
              set tbdata(-1,1) "Fric Angle"
              set tbdata(-1,2) "Flow Angle"
              set tbdata(0,-1) "Constants"
              wm minsize $parent4 500 200
              set numcol 3
              set numrow 1

              $parent4 configure -helpcommand [list ans_loadhelp Hlp_E_CH2dp]
          }
          DP2 {
              set labelin DP
              set tbopt 2
              euidl::label $childsite.lbl$labelin -height 3 \
                     -anchor w \
                     -text [msgcat::mc "Drucker Prager Cap Table \
                           for Material Number $mat"]
              wm title $parent4 [msgcat::mc "Drucker\
                   Prager Cap for Material Number $mat"]
              set tbdata(-1,0) "Constants"
              set tbdata(0,-1) "Alpha"
              set tbdata(1,-1) "Theta"
              set tbdata(2,-1) "Lambda"
              set tbdata(3,-1) "Beta"
              set tbdata(4,-1) "R Shape"
              set tbdata(5,-1) "D hard"
              set tbdata(6,-1) "W hard"
              set tbdata(7,-1) "T Cutof"
              set tbdata(8,-1) "Xo Cap"
              wm minsize $parent4 500 200
              set numcol 1
              set numrow 9
 
              $parent4 configure -helpcommand [list ans_loadhelp Hlp_E_CH2dp]
          }
          SWEL {
              euidl::label $childsite.lbl$labelin -height 3 \
                      -anchor w\
                      -text [msgcat::mc "Swelling Table for Material Number $mat"]
              wm title $parent4 [msgcat::mc "Swelling Table \
                  for Material Number $mat"]
              
             
              for {set i 0} {$i < 6} {incr i 1} {
                 set tbdata(-1,$i) [expr $i+1]
              }
              for {set i 1} {$i <= 14} {incr i 1} {
                 set j [expr $i*6 -5]
                 set k [expr $i*6]
                 set tbdata([expr $i -1],-1) "C$j-C$k" 
              }
              $childsite.graph configure -state disabled
              set numrow 14
              
              set numcol 6
              $parent4 configure -helpcommand [list ans_loadhelp Hlp_E_CH2swel]
          }
          ANAN {
              euidl::label $childsite.lbl$labelin -height 3 \
                  -anchor w \
                  -text [msgcat::mc "Anand's Table for Material Number $mat"]
              wm title $parent4 [msgcat::mc "Anand's Table \
                  for Material Number $mat"]
              set tbdata(-1,0) "Constants"
              set tbdata(0,-1) "s0"
              set tbdata(1,-1) "Q/R"
              set tbdata(2,-1) "A"
              set tbdata(3,-1) "xi"
              set tbdata(4,-1) "m"
              set tbdata(5,-1) "h0"
              set tbdata(6,-1) "s (hat)"
              set tbdata(7,-1) "n"
              set tbdata(8,-1) "a"
              wm minsize $parent4 250 350
              set numrow 9
              set numcol 1
              $childsite.graph configure -state disabled
              $parent4 configure -helpcommand [list ans_loadhelp Hlp_E_CH2anan]
          }
          FAIL {
              euidl::label $childsite.lbl$labelin -height 3 \
                  -anchor w \
                  -text [msgcat::mc "Failure Criteria Table for Material Number $mat"]
              wm title $parent4 [msgcat::mc "Failure Criteria Table \
                  for Material Number $mat"]

              set thischild [euidl::labeledframe $childsite.panelopt$labelin \
                  -text [msgcat::mc "Include the following failure calculations"]]
              set thischild [$thischild childsite]

              $tableName height 0 0
              $tableName tag configure disabledflat -relief flat \
                     -state disabled \
                     -background [$tableName cget -disabledbackground]\
                     -foreground [$tableName cget -disabledbackground]
              $tableName tag raise disabledflat title
              $tableName tag cell disabledflat 0,0 
              $tableName tag cell disabledflat 0,1
              $tableName tag cell disabledflat 0,2
              $tableName tag cell disabledflat 0,3
              $tableName tag cell disabledflat 0,4
              $tableName tag cell disabledflat 0,5

              euidl::label $thischild.lblopt1$labelin -height 1 -anchor nw \
                     -text  [msgcat::mc "Criteria 1"]
              euidl::combobox  $thischild.cmb1$labelin -width 32  \
                   -variable [scope tbdata(0,0)]
              $thischild.cmb1$labelin insert list end\
                  [list {Do not include} 0\
                        {Maximum Strain} 1\
                        {User-Defined} -1\
                  ] 

              euidl::label $thischild.lblopt2$labelin -height 1 -anchor nw \
                     -text  [msgcat::mc "Criteria 2"]
              euidl::combobox  $thischild.cmb2$labelin -width 32  \
                   -variable [scope tbdata(0,1)]
              $thischild.cmb2$labelin insert list end\
                  [list {Do not include} 0\
                        {Maximum Stress} 1\
                        {User-Defined} -1\
                  ] 

              euidl::label $thischild.lblopt3$labelin -height 1 -anchor nw \
                     -text  [msgcat::mc "Criteria 3"]
              euidl::combobox  $thischild.cmb3$labelin -width 32  \
                   -variable [scope tbdata(0,2)]
              $thischild.cmb3$labelin insert list end\
                  [list {Do not include} 0\
                        {Tsai-Wu} 1\
                        {Inverse Tsai-Wu} 2\
                        {User-Defined} -1\
                  ] 

              euidl::label $thischild.lblopt4$labelin -height 1 -anchor nw \
                     -text  [msgcat::mc "Criteria 4"]
              euidl::combobox  $thischild.cmb4$labelin -width 32  \
                   -variable [scope tbdata(0,3)]
              $thischild.cmb4$labelin insert list end\
                  [list {Do not include} 0\
                        {User-Defined} -1\
                  ] 

              euidl::label $thischild.lblopt5$labelin -height 1 -anchor nw \
                     -text  [msgcat::mc "Criteria 5"]
              euidl::combobox  $thischild.cmb5$labelin -width 32  \
                   -variable [scope tbdata(0,4)]
              $thischild.cmb5$labelin insert list end\
                  [list {Do not include} 0\
                        {User-Defined} -1\
                  ] 

              euidl::label $thischild.lblopt6$labelin -height 1 -anchor nw \
                     -text  [msgcat::mc "Criteria 6"]
              euidl::combobox  $thischild.cmb6$labelin -width 32  \
                   -variable [scope tbdata(0,5)]
              $thischild.cmb6$labelin insert list end\
                  [list {Do not include} 0\
                        {User-Defined} -1\
                  ] 

              grid $thischild.lblopt1$labelin -sticky nw -column 0 -row 1 \
                -columnspan 3
              grid $thischild.cmb1$labelin -sticky nw -column 4  -row 1 \
                -columnspan 2
              grid $thischild.lblopt2$labelin -sticky nw -column 0 -row 2 \
                -columnspan 3
              grid $thischild.cmb2$labelin -sticky nw -column 4  -row 2 \
                -columnspan 2
              grid $thischild.lblopt3$labelin -sticky nw -column 0 -row 3 \
                -columnspan 3
              grid $thischild.cmb3$labelin -sticky nw -column 4  -row 3 \
                -columnspan 2
              grid $thischild.lblopt4$labelin -sticky nw -column 0 -row 4 \
                -columnspan 3
              grid $thischild.cmb4$labelin -sticky nw -column 4  -row 4 \
                -columnspan 2
              grid $thischild.lblopt5$labelin -sticky nw -column 0 -row 5 \
                -columnspan 3
              grid $thischild.cmb5$labelin -sticky nw -column 4  -row 5 \
                -columnspan 2
              grid $thischild.lblopt6$labelin -sticky nw -column 0 -row 6 \
                -columnspan 3
              grid $thischild.cmb6$labelin -sticky nw -column 4  -row 6 \
                -columnspan 2

              for {set i 0} {$i < 6} {incr i 1} {
                 set tbdata(-1,$i) [expr $i+1]
                 set tbdata(0,$i) 0
              }
           
#              set tbdata(0,-1) "CritKeys"
              set tbdata(1,-1) "Temps"
              set tbdata(2,-1) "xTenStrn"
              set tbdata(3,-1) "xComStrn"
              set tbdata(4,-1) "yTenStrn"
              set tbdata(5,-1) "yComStrn"
              set tbdata(6,-1) "zTenStrn"
              set tbdata(7,-1) "zComStrn"
              set tbdata(8,-1) "xyShStrn"
              set tbdata(9,-1) "yzShStrn"
              set tbdata(10,-1) "xzShStrn"
              set tbdata(11,-1) "xTenStrs"
              set tbdata(12,-1) "xComStrs"
              set tbdata(13,-1) "yTenStrs"
              set tbdata(14,-1) "yComStrs"
              set tbdata(15,-1) "zTenStrs"
              set tbdata(16,-1) "zComStrs"
              set tbdata(17,-1) "xyShStrs"
              set tbdata(18,-1) "yzShStrs"
              set tbdata(19,-1) "xzShStrs"
              set tbdata(20,-1) "Cplng-xy"
              set tbdata(21,-1) "Cplng-yz"
              set tbdata(22,-1) "Cplng-xz"
              set numrow 23
              set numcol 6
              $childsite.graph configure -state disabled
              $parent4 configure -helpcommand [list ans_loadhelp Hlp_E_99fail]
          }
          PIEZ {
             euidl::label $childsite.lbl$labelin -height 3 \
                  -anchor w \
                  -text [msgcat::mc " Piezoelectric Matrix\
                        for Material Number $mat"]
             wm title $parent4 [msgcat::mc "Piezoelectric Matrix\
                  for Material Number $mat"]
             euidl::label $childsite.lblopt$labelin -height 3 -anchor nw \
                    -text  [msgcat::mc "Piezoelectric Matrix Options  "]
             euidl::combobox  $childsite.cmb$labelin -width 32  \
                 -variable [scope tbopt]
             $childsite.cmb$labelin insert list end\
                 [list {Piezoelectric stress matrix [e]} 0\
                       {Piezoelectric strain matrix [d]} 1\
                 ] 
             set tbopt 0
             set numcol 3
             set numrow 6
             set tbdata(-1,0) "X"
             set tbdata(-1,1) "Y" 
             set tbdata(-1,2) "Z"
             set tbdata(0,-1) "X"
             set tbdata(1,-1) "Y"
             set tbdata(2,-1) "Z"
             set tbdata(3,-1) "XY"
             set tbdata(4,-1) "YZ"
             set tbdata(5,-1) "XZ"
             wm minsize $parent4 500 290
             $childsite.graph configure -state disabled
             $parent4 configure -helpcommand [list ans_loadhelp Hlp_E_CH2piez]
          }
          PZRS {
             euidl::label $childsite.lbl$labelin -height 3 \
                  -anchor w \
                  -text [msgcat::mc " Piezoresistive Matrix\
                        for Material Number $mat"]
             wm title $parent4 [msgcat::mc "Piezoresistive Matrix\
                  for Material Number $mat"]
             euidl::label $childsite.lblopt$labelin -height 3 -anchor nw \
                    -text  [msgcat::mc "Piezoresistive Matrix Options  "]
             euidl::combobox  $childsite.cmb$labelin -width 32  \
                 -variable [scope tbopt]
             $childsite.cmb$labelin insert list end\
                 [list {Piezoresistive stress matrix [pi]} 0\
                       {Piezoresistive strain matrix [m]} 1\
                 ]
             set tbopt 0
             set numcol 6
             set numrow 6
             set tbdata(-1,0) "X"
             set tbdata(-1,1) "Y"
             set tbdata(-1,2) "Z"
             set tbdata(-1,3) "XY"
             set tbdata(-1,4) "YZ"
             set tbdata(-1,5) "XZ"
             set tbdata(0,-1) "X"
             set tbdata(1,-1) "Y"
             set tbdata(2,-1) "Z"
             set tbdata(3,-1) "XY"
             set tbdata(4,-1) "YZ"
             set tbdata(5,-1) "XZ"
             wm minsize $parent4 500 290
             $childsite.graph configure -state disabled
             $parent4 configure -helpcommand [list ans_loadhelp Hlp_E_CH2pzrs]
         }
         WATE {
             euidl::label $childsite.lbl$labelin -height 3 \
                  -anchor w \
                  -text [msgcat::mc "WATER Table\
                        for Material Number $mat"]
             wm title $parent4 [msgcat::mc "WATER Table\
                  for Material Number $mat"]
             set numcol 6
             set numrow 33
             for {set i 1} {$i <= 6} { incr i 1} {
                set tbdata(-1,[expr $i-1]) $i
             }
             set tbdata(0,-1) "KKDDPh"
             set tbdata(1,-1) "ZWTh 1-2"
             set tbdata(2,-1) "ZWTh 3-4"
             set tbdata(3,-1) "ZWTh 5-6"
             set tbdata(4,-1) "ZWTh 7-8"
             set tbdata(5,-1) "Re 1-6"
             set tbdata(6,-1) "Re 7-12"
             set tbdata(7,-1) "CD 1-6"
             set tbdata(8,-1) "CD 7-12"
             set tbdata(9,-1) "CT 1-6"
             set tbdata(10,-1) "CT 7-12"
             set tbdata(11,-1) "Temp 1-6" 
             set tbdata(12,-1) "Temp 7-8"
             for {set i 1} {$i <= 20} { incr i 1} {
                set tbdata([expr 12+$i],-1) "Wave$i"
             }
             $childsite.graph configure -state disabled
             $parent4 configure -helpcommand [list ans_loadhelp Hlp_E_59wate]
         }
      }
      grid $childsite.lbl$labelin -sticky new -column 0 -row 0 \
            -columnspan 7
      if {$labelin == "MKIN" || $labelin == "PIEZ" || $labelin == "PZRS" \
          || $labelin == "DPER"} {
          grid $childsite.lblopt$labelin -sticky nw -column 0 -row 1 \
            -columnspan 3
          grid $childsite.cmb$labelin -sticky nw -column 4  -row 1 \
            -columnspan 2
      }

      if {$labelin == "FAIL"} {
          grid $childsite.panelopt$labelin -sticky news -column 0 -row 1 \
            -columnspan 5
      }

     # FILL THE TABLE WITH EXISTING DATA IF TABLE EXISTS
      
      set tb [ans_getvalue $labelin,$mat,EXIS]
      if {$tb == 1} {
         
          #loop through the table
          set n 0
          switch -exact -- $labelin {

           FAIL {
              for {set i 1} {$i<=$numcol} {incr i 1} {
                   #Set the crit keys first
                   set tbdata(0,[expr $i - 1]) \
                   [ans_getvalue $labelin,$mat,CKEY,$i]
                   #Set temperatures
                   set tbdata(1,[expr $i - 1]) [ans_getvalue $labelin,$mat,TVAL,$i]
                   set tbdata(1,[expr $i - 1]) [format "%-12.5G" $tbdata(1,[expr $i - 1])]
                   set tbdata(1,[expr $i - 1]) [string trimright $tbdata(1,[expr $i - 1])]
              }
              for {set j 0} {$j<$numcol} {incr j 1} {

                  if {$j == 0} {
                     for {set i 0} {$i<$numrow} {incr i 1} {
                         set tbdata($i,$j) \
                         [ans_getvalue $labelin,$mat,TEMP,$tbdata(1,$j),CONST,[expr $i-1]]
                         set tbdata($i,$j) [format "%-12.5G" $tbdata($i,$j)] 
                         set tbdata($i,$j) [string trimright $tbdata($i,$j)]                         
                     }
                  } else {
                     set newtemp 1
                     for {set i 0} {$i<$j} {incr i 1} {
                        if {$tbdata(1,$j) == $tbdata(1,$i)} {
                           set newtemp 0
                        }
                     }

                     if {$newtemp == 1} {
                        for {set i 1} {$i<$numrow} {incr i 1} {
                            set tbdata($i,$j) \
                            [ans_getvalue $labelin,$mat,TEMP,$tbdata(1,$j),CONST,[expr $i-1]]
                            set tbdata($i,$j) [format "%-12.5G" $tbdata($i,$j)] 
                            set tbdata($i,$j) [string trimright $tbdata($i,$j)]                         
                        }
                     } else {
                        for {set i 1} {$i<$numrow} {incr i 1} {
                            set tbdata($i,$j) 0
                        }
                     }
                  }
              }
           }
           PIEZ {
              set tbopt  [ans_getvalue $labelin,$mat,TBOP]
              for {set i 0} {$i<$numrow} {incr i 1} {
                for {set j 0} {$j<$numcol} {incr j 1} {
                    set n [expr $n +1]
                    set tbdata($i,$j) \
                      [ans_getvalue $labelin,$mat,TEMP,,CONST,$n] 
                    set tbdata($i,$j) [format "%-12.5G" $tbdata($i,$j)] 
                    set tbdata($i,$j) [string trimright $tbdata($i,$j)]                   
                }
              }              
           }
           PZRS {
              set tbopt  [ans_getvalue $labelin,$mat,TBOP]
              for {set i 0} {$i<$numrow} {incr i 1} {
                for {set j 0} {$j<$numcol} {incr j 1} {
                    set n [expr $n +1]
                    set tbdata($i,$j) \
                      [ans_getvalue $labelin,$mat,TEMP,,CONST,$n]
                    set tbdata($i,$j) [format "%-12.5G" $tbdata($i,$j)]
                    set tbdata($i,$j) [string trimright $tbdata($i,$j)]

                }
              }
           }
           MKIN {           
             for {set i 1} {$i<$numrow} {incr i 1} {
                   set tbdata($i,0) [ans_getvalue $labelin,$mat,TVAL,$i]
                   set tbdata($i,0) [format "%-12.5G" $tbdata($i,0)]
                   set tbdata($i,0) [string trimright $tbdata($i,0)]
             }     
             set tbopt  [ans_getvalue $labelin,$mat,TBOP]
             #STRAIN Data
             for {set j 1} {$j<$numcol} {incr j 1} {
                 set val  [expr -($numcol-$j)]
                 set tbdata(0,$j) \
             [ans_getvalue $labelin,$mat,TEMP,$tbdata(1,0),CONST,[expr -($numcol-$j)]]
                 set tbdata(0,$j) [format "%-12.5G" $tbdata(0,$j)]
                 set tbdata(0,$j) [string trimright $tbdata(0,$j)]
             }
             #rest of the table
             set nTems [ans_getvalue $labelin,$mat,NTEM,]
             for {set i 1} {$i<$numrow} {incr i 1} {

                #Verify if a similar temperature exists
                set status 0
                for {set k [expr $i - 1] } {$k >= 1 } { set k [expr $k - 1] } {
                   if { $tbdata($k,0) == $tbdata($i,0) } {
                      set status 1
                   }
                }

                for {set j 1} {$j<$numcol} {incr j 1} {
                   if { $status == 0 } {
                      if { $i <= $nTems } {
                         set tbdata($i,$j) \
                               [ans_getvalue $labelin,$mat,TEMP,$tbdata($i,0),CONST,$j]
                      } else {
                         set tbdata($i,$j) 0                          
                      }
                    } else {
                           set tbdata($i,$j) 0                          
                    }
                    set tbdata($i,$j) [format "%-12.5G" $tbdata($i,$j)]
                    set tbdata($i,$j) [string trimright $tbdata($i,$j)]
                 }
              }
             
          }
          CREE {
             set tbchk  [ans_getvalue $labelin,$mat,TBOP]        
             if {$tbchk == 0} { 
                for {set i 0} {$i<$numrow} {incr i 1} {
                  for {set j 0} {$j<$numcol} {incr j 1} {
                    set n [expr $n +1]
                    set tbdata($i,$j) \
                      [ans_getvalue $labelin,$mat,TEMP,,CONST,$n] 
                    set tbdata($i,$j) [format "%-12.5G" $tbdata($i,$j)] 
                    set tbdata($i,$j) [string trimright $tbdata($i,$j)]                   
                  }
                }  
             } else { 
                warning creep
             }
          }
          DP {
             set tbchk  [ans_getvalue $labelin,$mat,TBOP]
             if {$tbchk == $tbopt} {
                for {set i 0} {$i<$numrow} {incr i 1} {
                  for {set j 0} {$j<$numcol} {incr j 1} {
                    set n [expr $n +1]
                    set tbdata($i,$j) \
                      [ans_getvalue $labelin,$mat,TEMP,,CONST,$n]
                    set tbdata($i,$j) [format "%-12.5G" $tbdata($i,$j)]
                    set tbdata($i,$j) [string trimright $tbdata($i,$j)]

                  }
                } 
             } else {
                warning dp
             }
          }
          DPER {
             set tbopt  [ans_getvalue $labelin,$mat,TBOP]
             for {set i 0} {$i<$numrow} {incr i 1} {
                for {set j 0} {$j<$numcol} {incr j 1} {
                    set n [expr $n +1]
                    set tbdata($i,$j) \
                      [ans_getvalue $labelin,$mat,TEMP,,CONST,$n] 
                    set tbdata($i,$j) [format "%-12.5G" $tbdata($i,$j)] 
                    set tbdata($i,$j) [string trimright $tbdata($i,$j)]                   
                }
             }
          }
          default {
             for {set i 0} {$i<$numrow} {incr i 1} {
                for {set j 0} {$j<$numcol} {incr j 1} {
                    set n [expr $n +1]
                    set tbdata($i,$j) \
                      [ans_getvalue $labelin,$mat,TEMP,,CONST,$n] 
                    set tbdata($i,$j) [format "%-12.5G" $tbdata($i,$j)] 
                    set tbdata($i,$j) [string trimright $tbdata($i,$j)]                   
                }
             }
          }
         }
      }
      #configure tktable   
      $tableName configure -rows [expr int($numrow) + 1] -cols [expr int($numcol) + 1]
            
      grid $tableName -sticky news -column 0 -row 2 -columnspan 8
      grid rowconfigure $childsite 2 -weight 1

      # Set the max view height for the table
      grid rowconfigure $childsite 2 -minsize 50

     #BINDINGS

#     bind Entry <Control-KeyPress-t> [code delcolumn  $high $entf $lblcolf \
#             $labelin %W]
#     bind Entry <Control-KeyPress-r> [code delrow  $high $entf $lblrowf \
#             $labelin %W]

#      $parent4 configure \
#            -okcommand [code matOpts_Ok 0 $mat $next] \
#            -cancelcommand [code matOpts_Cancel] \
#            -helpcommand [list ans_loadhelp Hlp_UI_mat_dat]

#      bind $parent4.buttonBox.ok <ButtonPress-1> "+focus %W"

#     $tableName config -maxwidth [expr [winfo width $tableName ] - 15]

      update idletasks
      wm minsize $parent4 [winfo reqwidth $parent4] \
                          [winfo reqheight $parent4]
     
      grid propagate $childsite 0
      
#      uidl::registerWindow $parent4
#      $parent4 activate
 
      set treeChildsite $childsite
      
      if {$labelin == "MKIN"} {
         $tableName selection set 1,0
         $tableName activate 1,0
         $tableName selection anchor 1,0
      } else {
         $tableName selection set 0,0
         $tableName activate 0,0
         $tableName selection anchor 0,0
      }
      $tableName see active
    
#      bind $tableName <Return> { break }

      if [winfo exists .conf] {
         $confirm activate
         raise $confirm
      } else {
        $parent4 activate
      }
      
   }

   proc warning {which} {
      variable ::euidl::material::ModelControl::matModelArr


      variable confirm


      if {$which == "creep"} {
          set text "A Creep model has already been defined\n\
                   for this material model number.        \n\
                    Do you want to overwrite it?"
      } elseif {$which == "dp"} {
           set text "An Drucker-Prager model has already been\n\
                     defined for this material model number. \n\
                      Do you want to overwrite it?"
      }

      set confirm [::euidl::dialog .conf -class EUIDL \
             -master $matModelArr(parent) \
             -okbutton 0 -helpbutton 0 -cancelbutton 0 ]

     
      set childsi [$confirm component childsite]
      wm title $confirm [msgcat::mc "Warning"]
     
      euidl::label $childsi.lbl -text [msgcat::mc $text] 
      grid $childsi.lbl -row 0 -column 0 -columnspan 2
      euidl::button $childsi.yes -height 1 -text [msgcat::mc "Yes"] \
                       -command [code updatechoice 1]
      grid $childsi.yes -row 1 -column 0 
      euidl::button $childsi.no -height 1 -text [msgcat::mc "No"] \
            -command [code updatechoice 0]
      grid $childsi.no -row 1 -column 1
     
    
      update idletasks
    
     

    
   }

   proc updatechoice {val} {
      
       variable confirm
       variable parent4
       
       
       if {$val == 1} {
           destroy $confirm
           $parent4 activate
       } elseif { $val == 0 } {
           destroy $confirm
           destroy $parent4
           euidl::material::ModelControl::matTable_State 1
       }
       
   }
   
 
    proc graph {} {

      variable ::euidl::material::ModelControl::matModelArr

      variable labelin
      variable grpher

      set grpher 0

      # Lower the windows so that the graph isn't obscurred in 3D
      lower $matModelArr(parent)
      update

      set matgr [ans_evalexpr mpinqr(0,0,14)]
      set matgr [expr $matgr +1]

      #call matOptsOk with flag on

      matOpts_Ok 777 $matgr 0

      set def [ans_evalexpr mpinqr($matgr,0,1)]
      if {$def == 0} {
          return
      }
      if {$grpher != 999} {
         catch {ans_sendcommand \
              )TBPL,$labelin,$matgr,,,,,,,PREV}
      }
      ans_sendcommand )/NOPR
      catch {ans_sendcommand )TBDE,$labelin,$matgr}
      ans_sendcommand )/GO

      after 1000 [list raise $matModelArr(parent)]
   }

   proc matOpts_Ok { flag mat next} {
   
      variable parent4
      variable labelin
      variable numcol
      variable numrow
      variable tbdata
      variable tbopt
      variable tableName
      variable grpher
      
      ans_sendcommand )/NOPR

      # Indicate that a material has changed its values
      variable ::euidl::material::ModelControl::localMatlInfoArr
      if {[info exists localMatlInfoArr]} {
         set localMatlInfoArr(matl,$mat,chng) 1
      }
      
      #TB command
      set tb [ans_getvalue $labelin,$mat,EXIS]
      if {$tb == 1} {
         catch {ans_sendcommand TBDE,$labelin,$mat}
      }
      ans_sendcommand )/GO

      # DP table uses labels for tb option
      if {$labelin == "DP"} {
         if {$tbopt == 2 || $tbopt =="CAP"} {
            set tbopt "CAP"
         } else {
            set tbopt ""
         }
      }
      
      if {$flag != 777} {
            if {[catch {ans_sendcommand \
                        TB,$labelin,$mat,,,$tbopt}]} {
#                        catch {ans_sendcommand TBDE,$labelin,$mat}
                        return
            }            
      } else {
            ans_sendcommand )/NOPR
            if {[catch {ans_sendcommand )TB,$labelin,$mat,,,$tbopt}]} {
                      set grpher 999
                      ans_sendcommand )/GO
                      return
            }
      }
      
      #TBMODIF Command -Loop through the table

      # switch rows and columns for this one
      if {$labelin == "DPER"} {
         for {set h 0} {$h<$numrow} {incr h 1} {
            for {set j 0} {$j<$numcol} {incr j 1} {
              #if {[catch {ans_evalexpr $tbdata($h,$j)}]} {
              #    set tbdata($h,$j) ""
              #}
              if {[catch {set value $tbdata($h,$j)}]} {
                  set value ""
              }
              regsub -all { } $value {} value
              if {$flag != 777} {
                  if {[catch {ans_sendcommand \
                       TBMODIF,[expr $j+1],[expr $h+1],$value}]} {
                       ans_sendcommand )/NOPR
                       catch {ans_sendcommand TBDE,$labelin,$mat}
                       ans_sendcommand )/GO
                       return
                  }
              } else {
                 if {[catch {ans_sendcommand \
                       )TBMODIF,[expr $j+1],[expr $h+1],$value}]} {
                       set grpher 999
                       ans_sendcommand )/GO
                       return
                 }
              }
            }
         }
      } else {

         for {set h 0} {$h<$numrow} {incr h 1} {
            for {set j 0} {$j<$numcol} {incr j 1} {
              #if {[catch {ans_evalexpr $tbdata($h,$j)}]} {
              #    set tbdata($h,$j) ""
              #}
              if {[catch {set value $tbdata($h,$j)}]} {
                  set value ""
              }
              regsub -all { } $value {} value
              if {$flag != 777} {
                  if {[catch {ans_sendcommand \
                        TBMODIF,[expr $h+1],[expr $j+1],$value}]} {
                       ans_sendcommand )/NOPR
                       catch {ans_sendcommand TBDE,$labelin,$mat}
                       ans_sendcommand )/GO
                       return
                  }
              } else {
                 if {[catch {ans_sendcommand \
                       )TBMODIF,[expr $h+1],[expr $j+1],$value}]} {
                       set grpher 999
                       ans_sendcommand )/GO
                       return
                 }
              }           
            }     
         }
      }
     
      ans_sendcommand )/GO

      if {$flag != 777} {
           # Unset the variables to make sure the table table is clean
           # on reentry.

           unset numcol
           unset numrow
           unset tbdata

           destroy $parent4
           if {$next != 999} {
              #call next table and don't restart for combined models
              if {$next != 0} {
                 euidl::material::ModelControl::table_choice $next $mat 0
                 return
              } else {
                 euidl::material::ModelControl::matTable_State 1
                 return
              }
           }
      }
       
   }

   proc matOpts_Cancel {} {
      variable parent4
      variable numcol
      variable numrow
      variable tbdata

      unset tbdata
      unset numcol
      unset numrow
      destroy $parent4
      unset parent4
      
      euidl::material::ModelControl::matTable_State 1
   }

}

# ============================================================================
# File Name:     table5.eui
# Description:   MP Dialog box for the following labels
#                        
#               -Structural implicit
#                ISOT (EX,NUXY)
#                ORTH (EX,EY,EZ,NU(OR PR)XY,YZ,XZ,GXY,GYZ,GXZ)
#                ALPI (ALPX,REFT)
#                ALPO (ALPX,ALPY,ALPZ,REFT)
#                DENS, DAMP, ALPD, BETD, DMPR, MU, 
#                DELD (Constant density for DYNA)
#                ALPL (ALPX for DYNA)
#                ISLS (EX,NUXY,ALPX for DYNA)
#              -Thermal
#                 C, HF, ENTH, EMIS ,QRAT ,KXX, KORT (KXX,KYY,KZZ)
#              -Electromagnetics
#                MURX,MURO(MURX,MURY,MURZ)
#                MGXX, MGOR (MGXX,MGYY,MGZZ)
#                 PERX, PERO (PERX,PERY,PERZ)
#                RSVX, RSVO (RSVX,RSVY,RSVZ)
#                LSST, SBKX, SBKO (SBKX,SBKY,SBKZ)
#              -Acoustics
#                SONC,( MUAC (Boundary admittance: MU))
#              -Fluids
#                VISC
#              -Diffusion
#                DXX, DORT (DXX,DYY,DZZ), 
#                BETI (BETX,CREF),BETO (BETX,BETY,BETZ,CREF),
#                CSAT
#                All these labels are temperature dependent
# ============================================================================

namespace eval ::euidl::material::mat5 {

   
   proc TABLE5 {label matid next} {
      
      variable ::euidl::material::ModelControl::matModelArr
        

      variable numcol
      variable numrow
      variable tbdata
      variable labelin
      variable labgraph 
      variable reftemp
      variable refconc
      set labelin $label

      variable colmin
      set colmin 1
     
      variable colmax
      set colmax 100

      variable parent5
      variable childsite
      variable tableName
      variable treeChildsite
      variable confirm

      euidl::material::ModelControl::matTable_State 0

      if [winfo exists .dlgMatOpts] {
         # Set the display correctly
         $parent5 activate
         return
      }


      set parent5 [euidl::dialog .dlgMatOpts -class EUIDL \
            -master $matModelArr(parent) \
            ]
      set childsite [$parent5 component childsite]

      #SET WINDOW#


      wm minsize $parent5 650 350
    
      set mat $matid

      set tableName [euidl::table $childsite.tbl1 \
            -variable [scope tbdata] \
            -rowseparator \n \
            -colseparator \t \
            -validate focusout \
            -validatedata ansreal \
         ]

         
      
     

       # BUTTONS ADD & DELETE # 
   
      
      euidl::button $childsite.addaftc -text [msgcat::mc "Add Temperature"] \
            -command [code addcolumn ] 
      grid $childsite.addaftc -column 0 -row 3

      bind $childsite.addaftc <ButtonRelease-1> \
                  [code ::euidl::material::error::check %W]

      euidl::button $childsite.delcolumn -text [msgcat::mc "Delete Temperature"] \
            -command [code colselect ]
      grid $childsite.delcolumn -column 1 -row 3

      bind $childsite.delcolumn <ButtonRelease-1> \
                  [code ::euidl::material::error::check %W]

      #Graph button OR Graph drop-down

      set listMPmult {ISOT ORTH ALPO CTEO THSO KORT MURO PERO KORT MGOR RSVO ISLS SBKO DORT BETO}
       
      set match [lsearch -exact $listMPmult $labelin]
      if {$match >= 0} {
         # Create the menubar for graph
         menubutton  $childsite.mb1 -text [msgcat::mc "Graph"] \
            -menu $childsite.mb1.menu -borderwidth 2\
            -relief raised 
         bind $childsite.mb1 <ButtonPress-1> {focus %W}
         menu $childsite.mb1.menu -tearoff 0
            
         grid $childsite.mb1 -sticky e -column 6 -row 3


      } else {
          euidl::button $childsite.graph -text [msgcat::mc "Graph"]\
              -command [code graph 888 1]
          grid $childsite.graph -sticky e -column 6 -row 3
  
          bind $childsite.graph <ButtonRelease-1> \
                  [code ::euidl::material::error::check %W]
          
      }

      grid columnconfigure $childsite 2 -minsize 50
      grid columnconfigure $childsite 5 -minsize 50
      grid columnconfigure $childsite 6 -weight 1

      $tableName config -colwidth 13
      

      # COMMAND DESCRIPTION-HAVE TO CHANGE THE MESSAGE DEPENDING ON THE LABEL
      #set number of cols and rows depending on the label

      switch -exact -- $labelin {
         ISOT {
             euidl::label $childsite.lbl$labelin -height 3 \
                  -anchor w \
                  -text [msgcat::mc " Linear Isotropic Material Properties\
                        for Material Number $mat"]
             wm title $parent5 [msgcat::mc "Linear Isotropic Properties\
                  for Material Number $mat"]
             set numcol 1
             set numrow 2
             
             set tbdata(1,-1) "EX"

             #check if minor or major poisson have been defined
             set nu 0
             set pr 0
             set nu [ans_getvalue NUXY,$mat,EXIS]
             set pr [ans_getvalue PRXY,$mat,EXIS]
                             
             if {$nu != 0 && $pr == 0} {
                  set tbdata(2,-1) "NUXY"
             } else {
                  set tbdata(2,-1) "PRXY"
             }
             
             wm minsize $parent5 500 230
             
             
             $tableName config -colmax 100             
             $tableName config -rowmax 3
             
             #set the graph drop-down button
             set ind 0
             foreach m [list EX $tbdata(2,-1)] {
                set ind [expr $ind + 1]
                set $m [menu $childsite.mb1.menu.m$m -tearoff 0]
                $childsite.mb1.menu add command -label [msgcat::mc "$m"] -command [code graph $m $ind]
                
             }
         }

         ISLS {
             euidl::label $childsite.lbl$labelin -height 3 \
                  -anchor w \
                  -text [msgcat::mc " Linear Isotropic Material Properties\
                        for Material Number $mat"]
             wm title $parent5 [msgcat::mc "Linear Isotropic Properties\
                  for Material Number $mat"]
             set numcol 1
             set numrow 3
             
             set tbdata(1,-1) "EX"
             set tbdata(3,-1) "ALPX"

             #check if minor or major poisson have been defined
             set nu 0
             set pr 0
             set nu [ans_getvalue NUXY,$mat,EXIS]
             set pr [ans_getvalue PRXY,$mat,EXIS]
                             
             if {$nu != 0 && $pr == 0} {
                  set tbdata(2,-1) "NUXY"
             } else {
                  set tbdata(2,-1) "PRXY"
             }
             
             wm minsize $parent5 500 230
             
             
             $tableName config -colmax 100             
             $tableName config -rowmax 3
             
             #set the graph drop-down button
             set ind 0
             foreach m [list EX $tbdata(2,-1) ALPX] {
                set ind [expr $ind + 1]
                set $m [menu $childsite.mb1.menu.m$m -tearoff 0]
                $childsite.mb1.menu add command -label [msgcat::mc "$m"] -command [code graph $m $ind]
                
             }
         }
     
         ORTH {
             euidl::label $childsite.lbl$labelin -height 3 \
                  -anchor w \
                  -text [msgcat::mc "Linear Orthotropic Material Properties\
                        for Material Number $mat"]
             wm title $parent5 [msgcat::mc "Linear Orthotropic Properties\
                  for Material Number $mat"]
             
             wm minsize $parent5 510 385

             #Must have the choice between Minor or Major Poisson ratio

             menubutton  $childsite.mb2 -text [msgcat::mc "Choose Poisson's Ratio"] \
                    -menu $childsite.mb2.menu -borderwidth 2\
                    -relief raised
             bind $childsite.mb2 <ButtonPress-1> {focus %W}
             menu $childsite.mb2.menu
            
             grid $childsite.mb2 -sticky w -column 0 -row 1
             set ind 0
             foreach po {Major_Pr Minor_Nu} {
                set ind [expr $ind + 1]
                set $po [menu $childsite.mb2.menu.m$po -tearoff 0]
                $childsite.mb2.menu add command -label [msgcat::mc "$po"] -command [code poisson $ind]
             }

             #check if minor or major poisson have been defined
             set nu 0
             foreach lab {NUXY NUYZ NUXZ} {
                  set temp [ans_getvalue $lab,$mat,EXIS]
                  set nu [expr $nu +$temp]
             }
             set pr 0
             foreach lab {PRXY PRYZ PRXZ} {
                  set temp [ans_getvalue $lab,$mat,EXIS]
                  set pr [expr $pr +$temp]
             }
            
             if {$nu != 0 && $pr == 0} {
                  set tbdata(4,-1) "NUXY"
                  set tbdata(5,-1) "NUYZ"
                  set tbdata(6,-1) "NUXZ"
             } else {
                  set tbdata(4,-1) "PRXY"
                  set tbdata(5,-1) "PRYZ"
                  set tbdata(6,-1) "PRXZ"
             }
             set numcol 1
             set numrow 9
             set tbdata(1,-1) "EX"
             set tbdata(2,-1) "EY"
             set tbdata(3,-1) "EZ"
             set tbdata(7,-1) "GXY"
             set tbdata(8,-1) "GYZ"
             set tbdata(9,-1) "GXZ"
             
             #set the graph drop-down button
             set ind 0
             foreach m [list EX EY EZ \
                             $tbdata(4,-1) $tbdata(5,-1) $tbdata(6,-1)\
                             GXY GYZ GXZ] {
                set ind [expr $ind + 1]
                set $m [menu $childsite.mb1.menu.m$m -tearoff 0]
                $childsite.mb1.menu add command -label [msgcat::mc "$m"] -command [code graph $m $ind]
             }
    
             $tableName config -colmax 100
             $tableName config -rowmax 10
         }
         DENS {
             euidl::label $childsite.lbl$labelin -height 3 \
                  -anchor w \
                  -text [msgcat::mc "Density for Material Number $mat"]
             wm title $parent5 [msgcat::mc "Density for Material Number $mat"]
             set numcol 1
             set numrow 1
             set tbdata(1,-1) "DENS"
             
             wm minsize $parent5 510 210

             $tableName config -colmax 100
             $tableName config -rowmax 2
         }
         DELD {
             euidl::label $childsite.lbl$labelin -height 3 \
                  -anchor w \
                  -text [msgcat::mc "Density for Material Number $mat"]
             wm title $parent5 [msgcat::mc "Density for Material Number $mat"]
             set numcol 1
             set numrow 1
             set tbdata(1,-1) "DENS"
             
             wm minsize $parent5 510 210

             $tableName config -colmax 1
             $tableName config -rowmax 2
             $childsite.delcolumn configure -state disabled 
             $childsite.addaftc configure -state disabled
             $childsite.graph configure -state disabled
         }
         DAMP {
             euidl::label $childsite.lbl$labelin -height 3 \
                  -anchor w \
                  -text [msgcat::mc "Constant Damping for Material Number $mat"]
             wm title $parent5 [msgcat::mc "Damping for Material Number $mat"]
             wm minsize $parent5 510 210
             set numcol 1
             set numrow 1
             set tbdata(1,-1) "DAMP"
            
             $tableName config -colmax 100
             $tableName config -rowmax 2
         }
         ALPD {
             euidl::label $childsite.lbl$labelin -height 3 \
                  -anchor w \
                  -text [msgcat::mc "Mass Matrix Damping Multiplier for Material Number $mat"]
             wm title $parent5 [msgcat::mc "Damping for Material Number $mat"]
             wm minsize $parent5 510 210
             set numcol 1
             set numrow 1
             set tbdata(1,-1) "ALPD"
            
             $tableName config -colmax 100
             $tableName config -rowmax 2
         }
         BETD {
             euidl::label $childsite.lbl$labelin -height 3 \
                  -anchor w \
                  -text [msgcat::mc "Stiffness Matrix Damping Multiplier for Material Number $mat"]
             wm title $parent5 [msgcat::mc "Damping for Material Number $mat"]
             wm minsize $parent5 510 210
             set numcol 1
             set numrow 1
             set tbdata(1,-1) "BETD"
            
             $tableName config -colmax 100
             $tableName config -rowmax 2
         }
         DMPR {
             euidl::label $childsite.lbl$labelin -height 3 \
                  -anchor w \
                  -text [msgcat::mc "Frequency Independent Damping for Material Number $mat"]
             wm title $parent5 [msgcat::mc "Damping for Material Number $mat"]
             wm minsize $parent5 510 210
             set numcol 1
             set numrow 1
             set tbdata(1,-1) "DMPR"

             $tableName config -colmax 1
             $tableName config -rowmax 2
             $childsite.delcolumn configure -state disabled 
             $childsite.addaftc configure -state disabled
             $childsite.graph configure -state disabled
         }
         MU {
             euidl::label $childsite.lbl$labelin -height 3 \
                  -anchor w \
                  -text [msgcat::mc "Friction Coefficient for Material Number $mat"]
             wm title $parent5 [msgcat::mc "Friction Coefficient for Material Number $mat"]
             wm minsize $parent5 510 210
             set numcol 1
             set numrow 1
             set tbdata(1,-1) "MU"
             set ind 0
            
             $tableName config -colmax 100
             $tableName config -rowmax 2
         }
          ALPI {
             euidl::label $childsite.lbl$labelin -height 3 \
                  -anchor w \
                  -text [msgcat::mc "Thermal Expansion Secant Coefficient for Material Number $mat"]
             wm title $parent5 [msgcat::mc "Thermal Expansion Secant Coefficient for Material Number $mat"]
             wm minsize $parent5 510 250
             euidl::label $childsite.lbl1$labelin -height 3 \
                  -anchor w \
                  -text [msgcat::mc "Reference temperature"]
             euidl::entry $childsite.ent -width 9\
                   -variable [scope reftemp] \
                   -validate focusout \
                   -validatedata ansreal 
             grid $childsite.lbl1$labelin -sticky w -column 0 -row 1
             grid $childsite.ent -sticky w -column 1 -row 1
             set numcol 1
             set numrow 1
             set tbdata(1,-1) "ALPX"
             set reftemp ""
            
             $tableName config -colmax 100
             $tableName config -rowmax 2
         }
          CTEI {
             euidl::label $childsite.lbl$labelin -height 3 \
                  -anchor w \
                  -text [msgcat::mc "Thermal Expansion Instantaneous Coefficient for Material Number $mat"]
             wm title $parent5 [msgcat::mc "Thermal Expansion Instantaneous Coefficient for Material Number $mat"]
             wm minsize $parent5 510 250
             euidl::label $childsite.lbl1$labelin -height 3 \
                  -anchor w \
                  -text [msgcat::mc "Reference temperature"]
             euidl::entry $childsite.ent -width 9\
                   -variable [scope reftemp] \
                   -validate focusout \
                   -validatedata ansreal
             grid $childsite.lbl1$labelin -sticky w -column 0 -row 1
             grid $childsite.ent -sticky w -column 1 -row 1
             set numcol 1
             set numrow 1
             set tbdata(1,-1) "CTEX"
             set reftemp ""

             $tableName config -colmax 100
             $tableName config -rowmax 2
         }
          THSI {
             euidl::label $childsite.lbl$labelin -height 3 \
                  -anchor w \
                  -text [msgcat::mc "Thermal Strain for Material Number $mat"]
             wm title $parent5 [msgcat::mc "Thermal Strain for Material Number $mat"]
             wm minsize $parent5 510 250
             euidl::label $childsite.lbl1$labelin -height 3 \
                  -anchor w \
                  -text [msgcat::mc "Reference temperature"]
             euidl::entry $childsite.ent -width 9\
                   -variable [scope reftemp] \
                   -validate focusout \
                   -validatedata ansreal
             grid $childsite.lbl1$labelin -sticky w -column 0 -row 1
             grid $childsite.ent -sticky w -column 1 -row 1
             set numcol 2
             set colmin 2
             set numrow 1
             set tbdata(1,-1) "THSX"
             set reftemp ""

             $tableName config -colmax 100
             $tableName config -rowmax 2
         }
          BETI {
             euidl::label $childsite.lbl$labelin -height 3 \
                  -anchor w \
                  -text [msgcat::mc "Diffusion Expansion Coefficient for Material Number $mat"]
             wm title $parent5 [msgcat::mc "Diffusion Expansion Coefficient for Material Number $mat"]
             wm minsize $parent5 510 250
             euidl::label $childsite.lbl1$labelin -height 3 \
                  -anchor w \
                  -text [msgcat::mc "Reference concentration"]
             euidl::entry $childsite.ent -width 9\
                   -variable [scope refconc] \
                   -validate focusout \
                   -validatedata ansreal 
             grid $childsite.lbl1$labelin -sticky w -column 0 -row 1
             grid $childsite.ent -sticky w -column 1 -row 1
             set numcol 1
             set numrow 1
             set tbdata(1,-1) "BETX"
             set refconc ""
            
             $tableName config -colmax 100
             $tableName config -rowmax 2
         }
         ALPL {
             euidl::label $childsite.lbl$labelin -height 3 \
                  -anchor w \
                  -text [msgcat::mc "Thermal Expansion Coefficient for Material Number $mat"]
             wm title $parent5 [msgcat::mc "Thermal Expansion Coefficient for Material Number $mat"]
             wm minsize $parent5 510 250
             set numcol 1
             set numrow 1
             set tbdata(1,-1) "ALPX"
            
             $tableName config -colmax 100
             $tableName config -rowmax 2
         }
         ALPO {
             euidl::label $childsite.lbl$labelin -height 3 \
                  -anchor w \
                  -text [msgcat::mc "Thermal Expansion Secant Coefficient for Material Number $mat"]
             wm title $parent5 [msgcat::mc " Thermal Expansion Secant Coefficient for Material Number $mat"]
             wm minsize $parent5 510 310
             euidl::label $childsite.lbl1$labelin -height 3 \
                  -anchor w \
                  -text [msgcat::mc "Reference temperature"]
             euidl::entry $childsite.ent -width 9\
                   -variable [scope reftemp]\
                   -validate focusout \
                   -validatedata ansreal
             grid $childsite.lbl1$labelin -sticky w -column 0 -row 1
             grid $childsite.ent -sticky w -column 1 -row 1
             set numcol 1
             set numrow 3
             set tbdata(1,-1) "ALPX"
             set tbdata(2,-1) "ALPY"
             set tbdata(3,-1) "ALPZ"
             set reftemp ""
             set ind 0
             foreach m {ALPX ALPY ALPZ} {
                set ind [expr $ind + 1]
                set $m [menu $childsite.mb1.menu.m$m]
                $childsite.mb1.menu add command -label [msgcat::mc "$m"] -command [code graph $m $ind]
             }
             $tableName config -colmax 100
             $tableName config -rowmax 4
         }
         CTEO {
             euidl::label $childsite.lbl$labelin -height 3 \
                  -anchor w \
                  -text [msgcat::mc "Thermal Expansion Instantaneous Coefficient for Material Number $mat"]
             wm title $parent5 [msgcat::mc " Thermal Expansion Instantaneous Coefficient for Material Number $mat"]
             wm minsize $parent5 510 310
             euidl::label $childsite.lbl1$labelin -height 3 \
                  -anchor w \
                  -text [msgcat::mc "Reference temperature"]
             euidl::entry $childsite.ent -width 9\
                   -variable [scope reftemp]\
                   -validate focusout \
                   -validatedata ansreal
             grid $childsite.lbl1$labelin -sticky w -column 0 -row 1
             grid $childsite.ent -sticky w -column 1 -row 1
             set numcol 1
             set numrow 3
             set tbdata(1,-1) "CTEX"
             set tbdata(2,-1) "CTEY"
             set tbdata(3,-1) "CTEZ"
             set reftemp ""
             set ind 0
             foreach m {CTEX CTEY CTEZ} {
                set ind [expr $ind + 1]
                set $m [menu $childsite.mb1.menu.m$m]
                $childsite.mb1.menu add command -label [msgcat::mc "$m"] -command [code graph $m $ind]
             }
             $tableName config -colmax 100
             $tableName config -rowmax 4
         }
         THSO {
             euidl::label $childsite.lbl$labelin -height 3 \
                  -anchor w \
                  -text [msgcat::mc "Thermal Strain Material Number $mat"]
             wm title $parent5 [msgcat::mc " Thermal Strain for Material Number $mat"]
             wm minsize $parent5 510 310
             euidl::label $childsite.lbl1$labelin -height 3 \
                  -anchor w \
                  -text [msgcat::mc "Reference temperature"]
             euidl::entry $childsite.ent -width 9\
                   -variable [scope reftemp]\
                   -validate focusout \
                   -validatedata ansreal
             grid $childsite.lbl1$labelin -sticky w -column 0 -row 1
             grid $childsite.ent -sticky w -column 1 -row 1
             set numcol 2
             set colmin 2
             set numrow 3
             set tbdata(1,-1) "THSX"
             set tbdata(2,-1) "THSY"
             set tbdata(3,-1) "THSZ"
             set reftemp ""
             set ind 0
             foreach m {THSX THSY THSZ} {
                set ind [expr $ind + 1]
                set $m [menu $childsite.mb1.menu.m$m]
                $childsite.mb1.menu add command -label [msgcat::mc "$m"] -command [code graph $m $ind]
             }
             $tableName config -colmax 100
             $tableName config -rowmax 4
         }
         BETO {
             euidl::label $childsite.lbl$labelin -height 3 \
                  -anchor w \
                  -text [msgcat::mc "Diffusion Expansion Coefficient for Material Number $mat"]
             wm title $parent5 [msgcat::mc " Thermal Expansion Coefficient for Material Number $mat"]
             wm minsize $parent5 510 310
             euidl::label $childsite.lbl1$labelin -height 3 \
                  -anchor w \
                  -text [msgcat::mc "Reference concentration"]
             euidl::entry $childsite.ent -width 9\
                   -variable [scope refconc]\
                   -validate focusout \
                   -validatedata ansreal
             grid $childsite.lbl1$labelin -sticky w -column 0 -row 1
             grid $childsite.ent -sticky w -column 1 -row 1
             set numcol 1
             set numrow 3
             set tbdata(1,-1) "BETX"
             set tbdata(2,-1) "BETY"
             set tbdata(3,-1) "BETZ"
             set refconc ""
             set ind 0
             foreach m {BETX BETY BETZ} {
                set ind [expr $ind + 1]
                set $m [menu $childsite.mb1.menu.m$m]
                $childsite.mb1.menu add command -label [msgcat::mc "$m"] -command [code graph $m $ind]
             }
             $tableName config -colmax 100
             $tableName config -rowmax 4
         }
         C {
             euidl::label $childsite.lbl$labelin -height 3 \
                  -anchor w \
                  -text [msgcat::mc "Specific Heat for Material Number $mat"]
             wm title $parent5 [msgcat::mc "Specific Heat for Material Number $mat"]
             wm minsize $parent5 510 210
             set numcol 1
             set numrow 1
             set tbdata(1,-1) "C"
             
             $tableName config -colmax 100
             $tableName config -rowmax 2
         }
         ENTH {
             euidl::label $childsite.lbl$labelin -height 3 \
                  -anchor w \
                  -text [msgcat::mc "Enthalpy for Material Number $mat"]
             wm title $parent5 [msgcat::mc "Enthalpy for Material Number $mat"]
             wm minsize $parent5 510 210
             set numcol 1
             set numrow 1
             set tbdata(1,-1) "ENTH"
             
             $tableName config -colmax 100
             $tableName config -rowmax 2
         }
         EMIS {
             euidl::label $childsite.lbl$labelin -height 3 \
                  -anchor w \
                  -text [msgcat::mc "Emissivity for Material Number $mat"]
             wm title $parent5 [msgcat::mc "Emissivity for Material Number $mat"]
             wm minsize $parent5 510 210
             set numcol 1
             set numrow 1
             set tbdata(1,-1) "EMIS"
            
             $tableName config -colmax 100
             $tableName config -rowmax 2
         }
         QRAT {
             euidl::label $childsite.lbl$labelin -height 3 \
                  -anchor w \
                  -text  [msgcat::mc "Heat Generation Rate for Material Number $mat"]
             wm title $parent5 [msgcat::mc "Heat Generation Rate for Material Number $mat"]
             wm minsize $parent5 510 210
             set numcol 1
             set numrow 1
             set tbdata(1,-1) "QRATE"
            
             $tableName config -colmax 100
             $tableName config -rowmax 2
         }
         VISC {
             euidl::label $childsite.lbl$labelin -height 3 \
                  -anchor w \
                  -text  [msgcat::mc "Viscosity for Material Number $mat"]
             wm title $parent5 [msgcat::mc "Viscosity for Material Number $mat"]
             wm minsize $parent5 510 210
             set numcol 1
             set numrow 1
             set tbdata(1,-1) "VISC"
            
             $tableName config -colmax 100
             $tableName config -rowmax 2
         }
         HF {
             euidl::label $childsite.lbl$labelin -height 3 \
                  -anchor w \
                  -text  [msgcat::mc "Convection or Film Coefficient for Material Number $mat"]
             wm title $parent5 [msgcat::mc "Convection or Film Coefficient for Material Number $mat"]
             wm minsize $parent5 510 210
             set numcol 1
             set numrow 1
             set tbdata(1,-1) "HF"
            
             $tableName config -colmax 100
             $tableName config -rowmax 2
         }
         KXX {
             euidl::label $childsite.lbl$labelin -height 3 \
                  -anchor w \
                  -text  [msgcat::mc "Conductivity (Isotropic) for Material Number $mat"]
             wm title $parent5 [msgcat::mc " Conductivity for Material Number $mat"]
             wm minsize $parent5 510 210
             set numcol 1
             set numrow 1
             set tbdata(1,-1) "KXX"
            
             $tableName config -colmax 100
             $tableName config -rowmax 2
         }
         KORT {
             euidl::label $childsite.lbl$labelin -height 3 \
                  -anchor w \
                  -text  [msgcat::mc "Conductivity (Orthotropic) for Material Number $mat"]
             wm title $parent5 [msgcat::mc " Conductivity for Material Number $mat"]
             wm minsize $parent5 510 270
             set numcol 1
             set numrow 3
             set tbdata(1,-1) "KXX"
             set tbdata(2,-1) "KYY"
             set tbdata(3,-1) "KZZ"
             set ind 0
             foreach m {KXX KYY KZZ} {
                set ind [expr $ind + 1]
                set $m [menu $childsite.mb1.menu.m$m -tearoff 0]
                $childsite.mb1.menu add command -label [msgcat::mc "$m"] -command [code graph $m $ind]
             }
             $tableName config -colmax 100
             $tableName config -rowmax 4
         }
         DXX {
             euidl::label $childsite.lbl$labelin -height 3 \
                  -anchor w \
                  -text  [msgcat::mc "Diffusivity (Isotropic) for Material Number $mat"]
             wm title $parent5 [msgcat::mc " Diffusivity for Material Number $mat"]
             wm minsize $parent5 510 210
             set numcol 1
             set numrow 1
             set tbdata(1,-1) "DXX"
            
             $tableName config -colmax 100
             $tableName config -rowmax 2
         }
         DORT {
             euidl::label $childsite.lbl$labelin -height 3 \
                  -anchor w \
                  -text  [msgcat::mc "Diffusivity (Orthotropic) for Material Number $mat"]
             wm title $parent5 [msgcat::mc " Diffusivity for Material Number $mat"]
             wm minsize $parent5 510 270
             set numcol 1
             set numrow 3
             set tbdata(1,-1) "DXX"
             set tbdata(2,-1) "DYY"
             set tbdata(3,-1) "DZZ"
             set ind 0
             foreach m {DXX DYY DZZ} {
                set ind [expr $ind + 1]
                set $m [menu $childsite.mb1.menu.m$m -tearoff 0]
                $childsite.mb1.menu add command -label [msgcat::mc "$m"] -command [code graph $m $ind]
             }
             $tableName config -colmax 100
             $tableName config -rowmax 4
         }
         CSAT {
             euidl::label $childsite.lbl$labelin -height 3 \
                  -anchor w \
                  -text  [msgcat::mc "Saturated Concentration for Material Number $mat"]
             wm title $parent5 [msgcat::mc " Saturated Concentration for Material Number $mat"]
             wm minsize $parent5 510 210
             set numcol 1
             set numrow 1
             set tbdata(1,-1) "CSAT"
            
             $tableName config -colmax 100
             $tableName config -rowmax 2
         }
         MURX {
             euidl::label $childsite.lbl$labelin -height 3 \
                  -anchor w \
                  -text  [msgcat::mc "Relative Permeability (Constant) for Material Number $mat"]
             wm title $parent5 [msgcat::mc "Permeability for Material Number $mat"]
             wm minsize $parent5 510 210
             set numcol 1
             set numrow 1
             set tbdata(1,-1) "MURX"
            
             $tableName config -colmax 100
             $tableName config -rowmax 2
         }
         MURO {
             euidl::label $childsite.lbl$labelin -height 3 \
                  -anchor w \
                  -text  [msgcat::mc "Relative Permeability (Orthotropic) for Material Number $mat"]
             wm title $parent5 [msgcat::mc "Permeability for Material Number $mat"]
             wm minsize $parent5 510 270
             set numcol 1
             set numrow 3
             set tbdata(1,-1) "MURX"
             set tbdata(2,-1) "MURY"
             set tbdata(3,-1) "MURZ"
             set ind 0
             foreach m {MURX MURY MURZ} {
                set ind [expr $ind + 1]
                set $m [menu $childsite.mb1.menu.m$m -tearoff 0]
                $childsite.mb1.menu add command -label [msgcat::mc "$m"] -command [code graph $m $ind]
             }
             $tableName config -colmax 100
             $tableName config -rowmax 4
         }
          MGXX {
             euidl::label $childsite.lbl$labelin -height 3 \
                  -anchor w \
                  -text  [msgcat::mc "Coercive Force (Constant) for Material Number $mat"]
             wm title $parent5 [msgcat::mc "Coercive Force for Material Number $mat"]
             wm minsize $parent5 510 210
             set numcol 1
             set numrow 1
             set tbdata(1,-1) "MGXX"
            
             $tableName config -colmax 100
             $tableName config -rowmax 2
         }
         MGOR {
             euidl::label $childsite.lbl$labelin -height 3 \
                  -anchor w \
                  -text  [msgcat::mc "Coercive Force (Orthotropic) for Material Number $mat"]
             wm title $parent5 [msgcat::mc "Coercive Force for Material Number $mat"]
             wm minsize $parent5 510 270
             set numcol 1
             set numrow 3
             set tbdata(1,-1) "MGXX"
             set tbdata(2,-1) "MGYY"
             set tbdata(3,-1) "MGZZ"
             set ind 0
             foreach m {MGXX MGYY MGZZ} {
                set ind [expr $ind + 1]
                set $m [menu $childsite.mb1.menu.m$m -tearoff 0]
                $childsite.mb1.menu add command -label [msgcat::mc "$m"] -command [code graph $m $ind]
             }
             $tableName config -colmax 100
             $tableName config -rowmax 4
         }
         PERX {
             euidl::label $childsite.lbl$labelin -height 3 \
                  -anchor w \
                  -text  [msgcat::mc "Relative Permittivity (Constant) for Material Number $mat"]
             wm title $parent5 [msgcat::mc "Relative Permittivity for Material Number $mat"]
             wm minsize $parent5 510 210
             set numcol 1
             set numrow 1
             set tbdata(1,-1) "PERX"
            
             $tableName config -colmax 100
             $tableName config -rowmax 2
         }
         PERO {
             euidl::label $childsite.lbl$labelin -height 3 \
                  -anchor w \
                  -text  [msgcat::mc "Relative Permittivity (Orthotropic) for Material Number $mat"]
             wm title $parent5 [msgcat::mc "Relative Permittivity for Material Number $mat"]
             wm minsize $parent5 510 270
             set numcol 1
             set numrow 3
             set tbdata(1,-1) "PERX"
             set tbdata(2,-1) "PERY"
             set tbdata(3,-1) "PERZ"
             set ind 0
             foreach m {PERX PERY PERZ} {
                set ind [expr $ind + 1]
                set $m [menu $childsite.mb1.menu.m$m -tearoff 0]
                $childsite.mb1.menu add command -label [msgcat::mc "$m"] -command [code graph $m $ind]
             }
             $tableName config -colmax 100
             $tableName config -rowmax 4
         }
         RSVX {
             euidl::label $childsite.lbl$labelin -height 3 \
                  -anchor w \
                  -text  [msgcat::mc "Resistivity (Constant) for Material Number $mat"]
             wm title $parent5 [msgcat::mc "Resistivity for Material Number $mat"]
             wm minsize $parent5 510 210
             set numcol 1
             set numrow 1
             set tbdata(1,-1) "RSVX"
            
             $tableName config -colmax 100
             $tableName config -rowmax 2
         }
         RSVO {
             euidl::label $childsite.lbl$labelin -height 3 \
                  -anchor w \
                  -text  [msgcat::mc "Resistivity (Orthotropic) for Material Number $mat"]
             wm title $parent5 [msgcat::mc "Resistivity for Material Number $mat"]
             wm minsize $parent5 510 270
             set numcol 1
             set numrow 3
             set tbdata(1,-1) "RSVX"
             set tbdata(2,-1) "RSVY"
             set tbdata(3,-1) "RSVZ"
             set ind 0

             foreach m {RSVX RSVY RSVZ} {
                set ind [expr $ind + 1]
                set $m [menu $childsite.mb1.menu.m$m -tearoff 0]
                $childsite.mb1.menu add command -label [msgcat::mc "$m"] -command [code graph $m $ind]
             }
             $tableName config -colmax 100
             $tableName config -rowmax 4
         }
         SONC {
             euidl::label $childsite.lbl$labelin -height 3 \
                  -anchor w \
                  -text  [msgcat::mc "Sonic Velocity for Material Number $mat"]
             wm title $parent5 [msgcat::mc "Sonic Velocity for Material Number $mat"]
             wm minsize $parent5 510 210
             set numcol 1
             set numrow 1
             set tbdata(1,-1) "SONC"
            
             $tableName config -colmax 100
             $tableName config -rowmax 2
         }
         MUAC {
             euidl::label $childsite.lbl$labelin -height 3 \
                  -anchor w \
                  -text  [msgcat::mc "Boundary Admittance for Material Number $mat"]
             wm title $parent5 [msgcat::mc "Boundary Admittance for Material Number $mat"]
             wm minsize $parent5 510 210
             set numcol 1
             set numrow 1
             set tbdata(1,-1) "MU"
            
             $tableName config -colmax 100
             $tableName config -rowmax 2
         }
         LSST {
             euidl::label $childsite.lbl$labelin -height 3 \
                  -anchor w \
                  -text  [msgcat::mc "Loss Tangent for Material Number $mat"]
             wm title $parent5 [msgcat::mc "Loss Tangent for Material Number $mat"]
             wm minsize $parent5 510 210
             set numcol 1
             set numrow 1
             set tbdata(1,-1) "LSST"
            
             $tableName config -colmax 100
             $tableName config -rowmax 2
         }

         SBKX {
             euidl::label $childsite.lbl$labelin -height 3 \
                  -anchor w \
                  -text  [msgcat::mc "Seebeck Coefficients (Constant) for Material Number $mat"]
             wm title $parent5 [msgcat::mc "Seebeck Coefficients for Material Number $mat"]
             wm minsize $parent5 510 210
             set numcol 1
             set numrow 1
             set tbdata(1,-1) "SBKX"

             $tableName config -colmax 100
             $tableName config -rowmax 2
         }
         SBKO {
             euidl::label $childsite.lbl$labelin -height 3 \
                  -anchor w \
                  -text  [msgcat::mc "Seebeck Coefficients (Orthotropic) for Material Number $mat"]
             wm title $parent5 [msgcat::mc "Seebeck Coefficients for Material Number $mat"]
             wm minsize $parent5 510 270
             set numcol 1
             set numrow 3
             set tbdata(1,-1) "SBKX"
             set tbdata(2,-1) "SBKY"
             set tbdata(3,-1) "SBKZ"
             set ind 0
             foreach m {SBKX SBKY SBKZ} {
                set ind [expr $ind + 1]
                set $m [menu $childsite.mb1.menu.m$m -tearoff 0]
                $childsite.mb1.menu add command -label [msgcat::mc "$m"] -command [code graph $m $ind]
             }
             $tableName config -colmax 100
             $tableName config -rowmax 4
         }
      }
   
  

      grid $childsite.lbl$labelin -sticky new -column 0 -row 0 \
            -columnspan 7
      

     # FILL THE TABLE WITH EXISTING DATA IF TABLE EXISTS FOR each label

      #special case REFT for ALP, CTE, or THS label
      if {$labelin == "ALPI" || $labelin == "ALPO" || \
          $labelin == "CTEI" || $labelin == "CTEO" || \
          $labelin == "THSI" || $labelin == "THSO" } {
         set mp [ans_getvalue REFT,$mat,EXIS]
         if {$mp == 1} {
            set reftemp  [ans_getvalue REFT,$mat,TEMP]
            set reftemp [format "%-12.5G" $reftemp]
            set reftemp [string trimright $reftemp]
         }
          # Use this function instead of *GET.  It will get this value
          # set by the TREF command in REFT does not exist
          #set reftemp  [ans_evalexpr trfget($mat)]
          #set reftemp [format "%-12.5G" $reftemp]
          #set reftemp [string trimright $reftemp]
      }
      #special case CREF for BET label
      if {$labelin == "BETI" || $labelin == "BETO" } {
         set mp [ans_getvalue CREF,$mat,EXIS]
         if {$mp == 1} {
            set refconc  [ans_getvalue CREF,$mat,TEMP]
            set refconc [format "%-12.5G" $refconc]
            set refconc [string trimright $refconc]
         }
      }

      #set defaults
      $tableName tag cell disabledtitle 0,-1
      $tableName tag cell disabled 0,0
      set tbdata(-1,0) T1
      set tbdata(0,-1) Temperatures

      if {$labelin == "THSI" || $labelin == "THSO"} {
         set tbdata(-1,0) T1
         set tbdata(-1,1) T2
         set tbdata(0,-1) Temperatures
         $tableName tag cell normaltitle 0,0
         $tableName tag cell normaltitle 0,-1
         $tableName tag cell normal 0,0
      }

      $tableName configure -rows [expr $numrow +2] -cols  [expr $numcol +1]

      set numcolcheck 0

      for {set k 1} {$k <= $numrow} {incr k 1} {
     
        set tb [ans_getvalue $tbdata($k,-1),$mat,EXIS]
         
         
        if {$tb == 1} {

          set tbdata(0,-1) Temperatures
          # Get the number of temperatures
          set numcol [expr int([ans_getvalue $tbdata($k,-1),$mat,NTEM])]

          # use this to find out if all labels have the same temperature variation
          if {$k == 1} {
             set numcolcheck $numcol
             for {set i 1} {$i<=$numcol} {incr i 1} {
                set tbdata(-1,[expr $i - 1]) "T$i"
                set tempcheck($i) [ans_getvalue $tbdata($k,-1),$mat,TVAL,$i] 
                set tempcheck($i) [format "%-12.5G" $tempcheck($i)] 
                set tempcheck($i) [string trimright $tempcheck($i)]           
             }
          }

          if {$k != 1} {
             #Check number of temperatures for the ISOT case
             #Maybe this might have to be done for all cases and not just ISOT
             if { $labelin == "ISOT" } {
                if { $numcolcheck != $numcol } {
                   ans_senderror 2 "Number of Temperatures defined for $tbdata($k,-1) do not match $tbdata(1,-1). \
                                    These cannot be handled by the gui currently."
                   matOpts_Cancel
                   return
                }

                for {set i 1} {$i<=$numcol} {incr i 1} {
                   set tempcur [ans_getvalue $tbdata($k,-1),$mat,TVAL,$i] 
                   set tempcur [format "%-12.5G" $tempcur ] 
                   set tempcur [string trimright $tempcur ]      

                   if { $tempcur != $tempcheck($i) } {
                      ans_senderror 2 "Temperature values for $tbdata($k,-1) do not match $tbdata(1,-1). \
                                       These cannot be handled by the gui currently."
                      matOpts_Cancel
                      return
                   }
                }
             }
          }

          
          # Get the value of each temperature
          for {set i 1} {$i<=$numcol} {incr i 1} {
             set tbdata(-1,[expr $i - 1]) "T$i"
             set tbdata(0,[expr $i - 1]) [ans_getvalue $tbdata($k,-1),$mat,TVAL,$i]          
          }

          # Loop through data for each temperature
           #special case ,if ISOT, get the value of NUXY if exist (NUXY == PRXY)
           if {$labelin == "ISOT" || $labelin == "ISLS"} {
                 set mp [ans_getvalue NUXY,$mat,EXIS]
                 if {$mp == 1} {
                    for {set i 1} {$i<=$numcol} {incr i 1} {              
                         set tbdata(2,[expr $i - 1]) \
                          [ans_getvalue NUXY,$mat,TEMP,$tbdata(0,[expr $i - 1])] 
                         set tbdata(2,[expr $i - 1]) [format "%-12.5G" $tbdata(2,[expr $i - 1])] 
                         set tbdata(2,[expr $i - 1]) [string trimright $tbdata(2,[expr $i - 1])]           
                    }
                 }
          } 
         
          for {set i 1} {$i<=$numcol} {incr i 1} {              
                 set tbdata($k,[expr $i - 1]) \
                     [ans_getvalue $tbdata($k,-1),$mat,TEMP,$tbdata(0,[expr $i - 1])]
                 set tbdata($k,[expr $i - 1]) [format "%-12.5G" $tbdata($k,[expr $i - 1])]
                 set tbdata($k,[expr $i - 1]) [string trimright $tbdata($k,[expr $i - 1])]           
           }
         #Now format temperature data
         for {set i 1} {$i<=$numcol} {incr i 1} {
             set tbdata(0,[expr $i - 1]) [format "%-12.5G" $tbdata(0,[expr $i - 1])]
             set tbdata(0,[expr $i - 1]) [string trimright $tbdata(0,[expr $i - 1])]          
         }
         #configure tktable
         $tableName configure -rows [expr int($numrow) + 2] -cols [expr int($numcol) + 1] 
         if {$numcol > 1} {
            $tableName tag cell normaltitle 0,-1
            $tableName tag cell normal 0,0
         } 
       } 
     }
      if {$labelin == "DELD"} {
         set tbdata(-1,0) " "
         set tbdata(0,-1) " "
         set tbdata(0,0) " "
         $tableName configure -titlerows 2
         $tableName tag cell normaltitle 0,0
      }
      grid $tableName -sticky news -column 0 -row 2 -columnspan 8
      grid rowconfigure $childsite 2 -weight 1

      # Set the max view height for the table
      grid rowconfigure $childsite 2 -minsize 50

     #BINDINGS

#     bind Entry <Control-KeyPress-t> [code delcolumn  $high $entf $lblcolf \
#             $labelin %W]
#     bind Entry <Control-KeyPress-r> [code delrow  $high $entf $lblrowf \
#             $labelin %W]

      $parent5 configure \
            -okcommand [code matOpts_Ok 0 $mat $next] \
            -cancelcommand [code matOpts_Cancel] \
            -helpcommand [list ans_loadhelp Hlp_C_MP]

#      bind $parent5.buttonBox.ok <ButtonPress-1> "+focus %W"

#     $tableName config -maxwidth [expr [winfo width $tableName ] - 15]

      update idletasks
      wm minsize $parent5 [winfo reqwidth $parent5] \
                         [expr [winfo reqheight $parent5] + 50 ]
     
      grid propagate $childsite 0
      
      #Give out a warning message if 
      set alreadyExists 0
      if {$labelin == "ALPI" || $labelin == "ALPO"} {
          set list2 {CTEX CTEY CTEZ THSX THSY THSZ}

          foreach lab $list2 {
          set iDoesExist [ans_getvalue $lab,$matid,EXIS]
             if { $iDoesExist == 1 } {
                set alreadyExists 1
             }
          }
      }
      if {$labelin == "CTEI" || $labelin == "CTEO"} {
          set list2 {ALPX ALPY ALPZ THSX THSY THSZ}

          foreach lab $list2 {
          set iDoesExist [ans_getvalue $lab,$matid,EXIS]
             if { $iDoesExist == 1 } {
                set alreadyExists 1
             }
          }
      }
      if {$labelin == "THSI" || $labelin == "THSO" } {
          set list2 {ALPX ALPY ALPZ CTEX CTEY CTEZ}

          foreach lab $list2 {
          set iDoesExist [ans_getvalue $lab,$matid,EXIS]
             if { $iDoesExist == 1 } {
                set alreadyExists 1
             }
          }
      }
      if { $alreadyExists == 1 } {
         warning therm
         return
      }

#      uidl::registerWindow $parent5
      $parent5 activate

      set treeChildsite $childsite

      $tableName selection set 1,0
      $tableName activate 1,0
      $tableName selection anchor 1,0
      $tableName see active
 
#      bind $tableName <Return> { break }

      
   }


   #ADD A COLUMN TO THE TABLE# 
   proc addcolumn {} {
        
        variable parent5
        variable tableName
        variable tbdata
        variable labelin
        variable numrow
        variable numcol
        variable colmax
        variable treeChildsite
     

        if {$numcol >= $colmax} {
             tk_messageBox -icon warning \
                  -title [msgcat::mc "Maximum Number of columns"] \
                  -parent $parent5 \
                  -type ok \
                  -message [msgcat::mc " This table \
                        allows only $colmax temperatures."]
        } else {

           incr numcol

           $tableName tag cell normaltitle 0,-1
           $tableName tag cell normal 0,0

        
           # Insert a column after the currently selected one
           if {[catch {$tableName index active col} curColumn]} {
              set curColumn 0
           }
           $tableName insert col -keeptitles -- $curColumn 1

           # Move the view to see added column
           #$tableName xview scroll 1 unit

           # Label this new column
           set tbdata(-1,[expr $numcol - 1]) "T$numcol"
           

           update
           #activate the new column
           $tableName selection activate 1,[expr $curColumn +1]
           $tableName see active

        }
   }


   proc colselect {} {

        variable tableName
        

        #create a list of sorted selected cells format {0,0 0,1 ....}
        set listcell [$tableName curselection]
        set length [llength $listcell]

        #get the first cell and the last cell selected
        set first [lindex  $listcell 0]
        set lastind [expr $length -1]
        set last [lindex  $listcell $lastind]
        
        #get the first and the last col 
        set firstlis [split $first ,]
        set firstcol [lindex  $firstlis 1]
       
        set lastlis [split $last ,]
        set lastcol  [lindex  $lastlis 1]
       
        if {$length == 0} {
             if {[catch {$tableName index active col} firstcol]} {
               set firstcol 2
             }
             set lastcol $firstcol
        }
       
        #Delete all the rows selected
        for {set i $firstcol} {$i <= $lastcol} {incr i 1} {
            delcolumn $firstcol
        }
        
   }


    #DELETE A COLUMN IN THE TABLE#

    proc delcolumn { curColumn} {

        variable parent5
        variable tableName
        variable labelin
        variable tbdata
        variable numcol
        variable colmin
        variable treeChildsite
        
        if {$numcol >= [expr $colmin + 1]} {
            # Delete the current column
            #if {[catch {$tableName index active col} curColumn]} {
            #   set curColumn 2
            #}
            $tableName delete cols -keeptitles -- $curColumn 1

          set numcol [expr $numcol - 1]
         
          if {$numcol < 2} {
               $tableName tag cell disabledtitle 0,-1
               $tableName tag cell disabled 0,0
          }

      } else {
         tk_messageBox -icon warning \
               -message [msgcat::mc "Cannot remove any more columns"] \
               -parent $parent5
      }
        
   }
    
    #This proc changes from minor to major NU -> PR and vice & versa
    #both in the table labels and in the graph drop-down list
    proc poisson { flag } {
      variable tbdata
      variable childsite
       
      if {$flag == 2} {
         set tbdata(4,-1) "NUXY"
         set tbdata(5,-1) "NUYZ"
         set tbdata(6,-1) "NUXZ"
        
         for {set i 1} {$i <= 9} {incr i 1} {
             $childsite.mb1.menu delete $i
         }
         set ind 0
         foreach m {EX EY EZ NUXY NUYZ NUXZ GXY GYZ GXZ} {
                set ind [expr $ind + 1]
                destroy  $childsite.mb1.menu.m$m 
                set $m [menu $childsite.mb1.menu.m$m -tearoff 0]
                $childsite.mb1.menu add command -label [msgcat::mc "$m"] -command [code graph $m $ind]
        }
      } elseif {$flag == 1} {
         set tbdata(4,-1) "PRXY"
         set tbdata(5,-1) "PRYZ"
         set tbdata(6,-1) "PRXZ"
         
         for {set i 1} {$i <= 9} {incr i 1} {
             $childsite.mb1.menu delete $i
         }
         set ind 0
         foreach m {EX EY EZ PRXY PRYZ PRXZ GXY GYZ GXZ} {
                set ind [expr $ind + 1]
                destroy  $childsite.mb1.menu.m$m 
                set $m [menu $childsite.mb1.menu.m$m -tearoff 0]
                $childsite.mb1.menu add command -label [msgcat::mc "$m"] -command [code graph $m $ind]
        }
      }  
    }

   
    

   proc warning {which} {
      variable ::euidl::material::ModelControl::matModelArr
      variable confirm
      variable parent5

      set text "Not Defined"
      if { [string equal -nocase -length 4 $which "therm"] } {
          set text "A Thermal Expansion model has already been defined\n\
                   for this material model number.        \n\
                    Do you want to overwrite it?"
      } else {
          return
      }
      
      catch { destroy .conf }
      set confirm [::euidl::dialog .conf -class EUIDL \
             -master $matModelArr(parent) \
             -okbutton 0 -helpbutton 0 -cancelbutton 0 ]

     
      set childsi [$confirm component childsite]
      wm title $confirm [msgcat::mc "Warning"]
  
      euidl::label $childsi.lbl -text [msgcat::mc $text ] 
      grid $childsi.lbl -row 0 -column 0 -columnspan 2
      euidl::button $childsi.yes -height 1 -text [msgcat::mc "Yes"] \
                       -command [code updatechoice 1]
      grid $childsi.yes -row 1 -column 0 
      euidl::button $childsi.no -height 1 -text [msgcat::mc "No"] \
            -command [code updatechoice 0]
      grid $childsi.no -row 1 -column 1
     
      wm deiconify $confirm
      raise $confirm

      update idletasks
   }

   proc updatechoice {val} {
      
       variable confirm
       variable parent5       
       
       if {$val == 1} {
           destroy $confirm
           .dlgMatOpts activate
       } elseif { $val == 0 } {
           destroy $confirm
           destroy .dlgMatOpts
           euidl::material::ModelControl::matTable_State 1
       }
       
   }

    proc graph {labgraph index} {
       
      variable ::euidl::material::ModelControl::matModelArr

      variable tbdata
      variable numrow
      variable parent5
      variable labelin
      variable numcol
      variable treeChildsite
      variable tableName
      variable reftemp
      variable refconc

      set grpher 0

      # Lower the windows so that the graph isn't obscurred in 3D
      lower $matModelArr(parent)
      update

      #set a dummy material ID
      set matgr [ans_evalexpr mpinqr(0,0,14)]
      set matgr [expr $matgr +1]

      
      if {$labgraph == 888} {
         set labgraph $tbdata(1,-1)
      }
      
      #Reorder TEMPERATURE - Create a list 
      for {set i 0} {$i<$numcol} {incr i 1} {
         if {[catch {lappend tempData $tbdata(0,$i)}]} {
                     set tbdata(0,$i) 0
                     lappend tempData $tbdata(0,$i)
         } 
      }
      # Sort the temperatures into a list
      if {[catch {set tempSort [lsort -real -unique $tempData]}]} {
         catch {unset tempData2}
         foreach junktemp $tempData {
            regsub -all { } $junktemp {} junktemp
            if {[catch {ans_evalexpr $junktemp}]} {
               #set junktemp 0
                return
            } else {
               set junktemp [ans_evalexpr $junktemp]
            }
            lappend tempData2 $junktemp
         }
         set tempData $tempData2
         set tempSort [lsort -real -unique $tempData]
      }
      if {[llength $tempData] != [llength $tempSort]} {
         set tl {}
         set tempSort [lsort -real $tempData]
         set tl [lindex $tempSort 0]
         for {set i 1} {$i < [llength $tempSort]} {incr i} {
            if {[lindex $tempSort $i] == $tl} {
               tk_messageBox -icon error \
                     -message [::msgcat::mc "There are multiple temperatures \
                        with value of $tl"] \
                     -parent $parent5
               break
            }
            set tl [lindex $tempSort $i]
         }
         return
      }

      # We have a valid sorted temperature list tempSort
      
      ans_sendcommand )/NOPR

      # issue MPTEMP
      # clear mptemp first
      catch {ans_sendcommand )MPTEMP,,,,,,,,}

      set n 1
      foreach temp $tempSort {
          set i [lsearch $tempData $temp]
          catch {ans_sendcommand )MPTEMP,$n,$temp}
          set n [expr $n +1]
      } 
      #MP command

      #special case REFT , just a separate entry
      if {$labelin == "ALPI" || $labelin == "ALPO" || \
          $labelin == "CTEI" || $labelin == "CTEO" || \
          $labelin == "THSI" || $labelin == "THSO" } {
         #set mp [ans_getvalue REFT,$mat,EXIS]
         #if {$mp == 1} {
         #    ans_sendcommand MPDE,REFT,$matgr
         #}
         if {[catch {set reftem $reftemp}]} {
               set reftem ""
         }
         regsub -all { } $reftem {} reftem
         if {[catch {ans_sendcommand )UIMP,$matgr,REFT,,,$reftem}]} {
                 ans_sendcommand )/NOPR
                 catch {ans_sendcommand MPDE,REFT,$matgr}
                 ans_sendcommand )/GO
                return
         }
      }
      #special case CREF , just a separate entry
      if {$labelin == "BETI" || $labelin == "BETO" } {
         if {[catch {set refcon $refconc}]} {
               set refcon ""
         }
         regsub -all { } $refcon {} refcon
         if {[catch {ans_sendcommand )UIMP,$matgr,CREF,,,$refcon}]} {
                 ans_sendcommand )/NOPR
                 catch {ans_sendcommand MPDE,CREF,$matgr}
                 ans_sendcommand )/GO
                return
         }
      }
            
         set tb [ans_getvalue $labgraph,$matgr,EXIS]
         if {$tb == 1} {
            catch {ans_sendcommand )MPDE,$labgraph,$matgr}
         }

         #MPDATA Command -Loop through the table
         
         
        
         foreach temp $tempSort {
            set i [lsearch $tempData $temp]
            #if {[catch {ans_evalexpr $tbdata($index,$i)}]} {
            #      set tbdata($index,$i) ""
            #}
            if {[catch {set c(1) $tbdata($index,$i)}]} {
                  set c(1) ""
            }
            regsub -all { } $c(1) {} c(1)
            if {[catch {ans_sendcommand \
                  )MPDATA,$labgraph,$matgr,,$c(1)}]} {
                 set grpher 999
            }
         }
      
          ans_sendcommand )/GO 
          if {$grpher != 999} {
             catch {ans_sendcommand )MPPL,$labgraph,$matgr,,,,,,,PREV}
          }
          ans_sendcommand )/NOPR
          set mpe [ans_getvalue $labgraph,$matgr,EXIS]
          if {$mpe == 1} {
             catch {ans_sendcommand )MPDE,$labgraph,$matgr}
          }
          set mpe [ans_getvalue REFT,$matgr,EXIS]
          if {$mpe == 1} {
             catch {ans_sendcommand )MPDE,REFT,$matgr}
          }
          set mpe [ans_getvalue CREF,$matgr,EXIS]
          if {$mpe == 1} {
             catch {ans_sendcommand )MPDE,CREF,$matgr}
          }
          ans_sendcommand )/GO

      after 1000 [list raise $matModelArr(parent)]
   }
   #The ok procedure might not need  a flag anymore
   proc matOpts_Ok { flag mat next} {
   
      variable parent5
      variable labelin
      variable numcol
      variable numrow
      variable tbdata
      variable tbopt
      variable reftemp
      variable refconc
      variable treeChildsite
      variable tableName

      # Indicate that a material has changed its values
      variable ::euidl::material::ModelControl::localMatlInfoArr
      if {[info exists localMatlInfoArr]} {
         set localMatlInfoArr(matl,$mat,chng) 1
      }

      #Reorder TEMPERATURE - Create a list 
      for {set i 0} {$i<$numcol} {incr i 1} { 
         if {[catch {lappend tempData $tbdata(0,$i)}]} {
                     set tbdata(0,$i) 0
                     lappend tempData $tbdata(0,$i)
         }
      }
      # Sort the temperatures into a list
      if {[catch {set tempSort [lsort -real -unique $tempData]}]} {
         catch {unset tempData2}
         foreach junktemp $tempData {
            regsub -all { } $junktemp \
                         {} junktemp
            if {[catch {ans_evalexpr $junktemp}]} {
               #set junktemp 0
                return
            } else {
               set junktemp [ans_evalexpr $junktemp]
            }
            lappend tempData2 $junktemp
         }
         set tempData $tempData2
         set tempSort [lsort -real -unique $tempData]
      }
      if {[llength $tempData] != [llength $tempSort]} {
         set tl {}
         set tempSort [lsort -real $tempData]
         set tl [lindex $tempSort 0]
         for {set i 1} {$i < [llength $tempSort]} {incr i} {
            if {[lindex $tempSort $i] == $tl} {
               tk_messageBox -icon error \
                     -message [::msgcat::mc "There are multiple temperatures \
                        with value of $tl"] \
                     -parent $parent5
               break
            }
            set tl [lindex $tempSort $i]
         }
         return
      }

      # We have a valid sorted temperature list tempSort

      # issue MPTEMP
      # clear mptemp first
      ans_sendcommand )/NOPR
      catch {ans_sendcommand MPTEMP,,,,,,,,}
      ans_sendcommand )/GO
      set n 1
      foreach temp $tempSort {
      #    set i [lsearch $tempData $temp]
      #    ans_sendcommand MPTEMP,$n, $tbdata(0,$i)
          catch {ans_sendcommand MPTEMP,$n,$temp}
          set n [expr $n +1]
      } 
      #MPDELE command if necessary

      #special case REFT , just a separate entry
      if {$labelin == "ALPI" || $labelin == "ALPO" || \
          $labelin == "CTEI" || $labelin == "CTEO" || \
          $labelin == "THSI" || $labelin == "THSO" } {
         #set mp [ans_getvalue REFT,$mat,EXIS]
         #if {$mp == 1} {
         #    ans_sendcommand MPDE,REFT,$mat
         #}
         if {[catch {set reftem $reftemp}]} {
               set reftem ""
         }
         regsub -all { } $reftem {} reftem
         if {[catch {ans_sendcommand UIMP,$mat,REFT,,,$reftem}]} {
                 ans_sendcommand )/NOPR
                 catch {ans_sendcommand MPDE,REFT,$mat}
                 ans_sendcommand )/GO
                return
         }
      }
      #special case CREF , just a separate entry
      if {$labelin == "BETI" || $labelin == "BETO" } {
         #set mp [ans_getvalue CREF,$mat,EXIS]
         #if {$mp == 1} {
         #    ans_sendcommand MPDE,CREF,$mat
         #}
         if {[catch {set refcon $refconc}]} {
               set refcon ""
         }
         regsub -all { } $refcon {} refcon
         if {[catch {ans_sendcommand UIMP,$mat,CREF,,,$refcon}]} {
                 ans_sendcommand )/NOPR
                 catch {ans_sendcommand MPDE,CREF,$mat}
                 ans_sendcommand )/GO
                return
         }
      }

      #Special case orth , delete all poisson coeft, minor & major
      if {$labelin == "ORTH"} {
         set defined [ans_evalexpr mpinqr($mat,0,1)]
         if {$defined > 0 } {
           foreach lab {NUXY NUYZ NUXZ PRXY PRYZ PRXZ} {
             ans_sendcommand )/NOPR
             catch {ans_sendcommand MPDE,$lab,$mat}
             ans_sendcommand )/GO             
           }
         }
      }

      #Special case Isotropic : if the poisson's ratio (PRXY) is\
      #constant (only one column) AND the input is blank THEN a \
      #warning should pop up to explain that the default of 0.3 is\
      # NOT applied and that PRXY = 0
      if {$labelin == "ISOT" || $labelin == "ISLS" } {
         if {[catch {set prxyblank $tbdata(2,0)}]} {
                     set prxyblank ""
         }
         if {$numcol == 1 && $prxyblank == ""} {
            tk_messageBox -icon warning \
               -title [msgcat::mc "Note"] \
               -parent $parent5 \
               -type ok \
               -message [msgcat::mc "PRXY will be set to 0.0"]
         }
      }
      

      #Special case: ISOTROPIC should overwrite ORTHOTROPIC MP's 
      ans_sendcommand )/GOPR
      set list {ISOT ALPI CTEI THSI ALPO CTEO THSO KXX DXX MURX MGXX PERX RSVX BETI}
      set ix [lsearch -exact $list $labelin]
      if {$ix >= 0} {
            set defined [ans_evalexpr mpinqr($mat,0,1)]
            if {$defined > 0 } {
               switch -exact -- $labelin {
                    ISOT {
                        set list2 {EX EY EZ NUXY NUYZ NUXZ \
                                  PRXY PRYZ PRXZ GXY GYZ GXZ}
                    }
                    ALPI {                       
                        set list2 {ALPX ALPY ALPZ CTEX CTEY CTEZ THSX THSY THSZ}
                    }
                    CTEI {                       
                        set list2 {ALPX ALPY ALPZ CTEX CTEY CTEZ THSX THSY THSZ}
                    }
                    THSI {                       
                        set list2 {ALPX ALPY ALPZ CTEX CTEY CTEZ THSX THSY THSZ}
                    }
                    ALPO {                       
                        set list2 {ALPX ALPY ALPZ CTEX CTEY CTEZ THSX THSY THSZ}
                    }
                    CTEO {                       
                        set list2 {ALPX ALPY ALPZ CTEX CTEY CTEZ THSX THSY THSZ}
                    }
                    THSO {                       
                        set list2 {ALPX ALPY ALPZ CTEX CTEY CTEZ THSX THSY THSZ}
                    }
                    KXX {                       
                        set list2 {KXX KYY KZZ}
                    }
                    DXX {                       
                        set list2 {DXX DYY DZZ}
                    }
                    BETI {                       
                        set list2 {BETX BETY BETZ}
                    }
                    MURX {                       
                        set list2 {MURX MURY MURZ}
                    }
                    MGXX {                       
                        set list2 {MGXX MGYY MGZZ}
                    }
                    PERX {                       
                        set list2 {PERX PERY PERZ}
                    }
                    RSVX {                       
                        set list2 {RSVX RSVY RSVZ}
                    }
               }
               foreach lab $list2 {
                  ans_sendcommand )/NOPR
                  set iDoesExist [ans_getvalue $lab,$mat,EXIS]
                  if { $iDoesExist == 1 } {
                      catch {ans_sendcommand MPDE,$lab,$mat}
                  }
                  ans_sendcommand )/GO
               }
            }
      }

      #Process the complete table

      for {set f 1} {$f <= $numrow} {incr f 1} {  
         set tb [ans_getvalue $tbdata($f,-1),$mat,EXIS]
         if {$tb == 1} {
            ans_sendcommand )/NOPR
            catch {ans_sendcommand MPDE,$tbdata($f,-1),$mat}
            ans_sendcommand )/GO 
         }
        

         #MPDATA Command -Loop through the table

        
         foreach temp $tempSort {
            set i [lsearch $tempData $temp]
            #for {set k 1} {$k <= 6} {incr k} {
            #      if {[catch {set c($k) $tbdata([expr $f + $k -1],$i)}]} {
            #         set c($k) ""
            #          puts $c($k)
            #      }
            #  }
            # ans_sendcommand MPDATA,$tbdata($f,-1),$mat,,$c(1),$c(2),$c(3),$c(4),$c(5),$c(6)
           
            #if {[catch {ans_evalexpr $tbdata($f,$i)}]} {
            #   set tbdata($f,$i) ""
            #}
            if {[catch {set c(1) $tbdata($f,$i)}]} {
                     set c(1) ""
               }
            regsub -all { } $c(1) {} c(1)
            if {[catch {ans_sendcommand MPDATA,$tbdata($f,-1),$mat,,$c(1)}]} {
                  ans_sendcommand )/NOPR
                  set tbe [ans_getvalue $tbdata($f,-1),$mat,EXIS]
                  if {$tbe == 1} {
                   catch {ans_sendcommand MPDE,$tbdata($f,-1),$mat}
                  }
                  ans_sendcommand )/GO
                  return
            }
         }
      }
      if {$flag != 777} {
        # Unset the variables to make sure the table table is clean
        # on reentry.

        unset numcol
        unset numrow
        unset tbdata

        destroy $parent5
        if {$next != 999} {
           #call next table and don't restart for combined models
           if {$next != 0} {
              euidl::material::ModelControl::table_choice $next $mat 0
              return
           } else {
              euidl::material::ModelControl::matTable_State 1     
              return
           }
        }
      }
   }

   proc matOpts_Cancel {} {
      variable parent5
      variable numcol
      variable numrow
      variable tbdata

      unset tbdata
      unset numcol
      unset numrow
      destroy $parent5
      unset parent5
      euidl::material::ModelControl::matTable_State 1
   }


}

namespace eval ::euidl::material::error {
   
   proc check { w } {
    global tkPriv

     focus $w
     update
     set var [euidl::errHandler::getStatus]
     if { [euidl::errHandler::getStatus] == 1 } {
            if {[string equal $w $tkPriv(buttonWindow)]} {
               set tkPriv(buttonWindow) ""
               $w configure -relief $tkPriv(relief)
            }
        return -code break
     } 
   }
}
# ============================================================================
# File Name:     table6.eui
# Description:   TB Dialog box for the following labels
#                GASK (NUNL)
#                All these tables are temperature dependent
#                STRESS-STRAIN Curves
#
# ============================================================================
# The tktable is organized in a special way
# The first 2 rows (-1 & 0) are TITLES 
# Some cols appear flat as separators for the stress-strain data input
#
# rows\cols :  -1    |    0    |     1    |     2    |   3    |   4  ......  
#  -1 |              |     T1  |  entry   | flat cell|   T2   |  entry
#   0 |              |   STRAIN|  STRESS  | flat cell| STRAIN |   STRESS
#   1 | label(1,2...)|  entry  |  entry   | flat cell| entry  |  entry ....
#
# So for N=0 to NTEMP we have 
# col 3N has an entry
# col 3N+1 has an entry
# col 3N+2 is flat
#
namespace eval ::euidl::material::mat6 {
   
   proc TABLE6 {label matid next} {
      
      variable ::euidl::material::ModelControl::matModelArr
        
      #numcol is the number of temps
      #numrow is the number of rows in the table
      variable numtab
      variable curtab

      variable numcol
      variable allnumcol
      variable numrow
      variable allnumrow

      variable labelin
      variable tbopt
     
      #realcol is the real number of cols in the table
      #actrow(x) is the number of active rows for each temp
      variable realcol
      
      variable tabmax
      variable colmax
      variable rowmax
    
      set labelin $label
      set curtab 1
      set numtab 1
          
      variable parent6
      variable childsite
      variable tableName
      variable treeChildsite
     
      variable tbdata

      variable maxntb
      variable actrow
      set maxntb 100
      for { set ntb 1 } { $ntb <= $maxntb } { incr ntb 1 } {
         variable tbdata$ntb
         variable actrow$ntb
      }

      variable matlabel

      euidl::material::ModelControl::matTable_State 0

      if [winfo exists .dlgMatOpts] {
         # Set the display correctly
         $parent6 activate
         return
      }


      set parent6 [euidl::dialog .dlgMatOpts -class EUIDL \
            -master $matModelArr(parent) \
            ]
      set childsite [$parent6 component childsite]

      #SET WINDOW#

      wm minsize $parent6 650 350
    
     
      set mat $matid
      set matlabel $matid

      set tableName [euidl::table $childsite.tbl1 \
            -variable [scope tbdata] \
            -rowseparator \n \
            -colseparator \t \
            -validate focusout \
            -validatedata ansreal \
         ]

      # BUTTONS ADD & DELETE & GRAPH# 
      
      euidl::button $childsite.addaftc -text [msgcat::mc "Add Temp"] \
            -command [code addcolumn ] 
      grid $childsite.addaftc -column 0 -row 3

      bind $childsite.addaftc <ButtonRelease-1> \
                  [code ::euidl::material::error::check %W]

      euidl::button $childsite.delcolumn -text [msgcat::mc "Delete Temp"] \
            -command [code colselect ]
      grid $childsite.delcolumn -column 1 -row 3

      bind $childsite.delcolumn <ButtonRelease-1> \
                  [code ::euidl::material::error::check %W]


      euidl::button $childsite.addaftr -text [msgcat::mc "Add Point"] \
            -command [code addrow ]
      grid $childsite.addaftr -column 3 -row 3

      bind $childsite.addaftr <ButtonRelease-1> \
                  [code ::euidl::material::error::check %W]

      euidl::button $childsite.delrow -text [msgcat::mc "Delete Point"] \
            -command [code rowselect ]
      grid $childsite.delrow -column 4 -row 3

      bind $childsite.delrow <ButtonRelease-1> \
                  [code ::euidl::material::error::check %W]


      euidl::button $childsite.prevtable \
            -tooltip [msgcat::mc "Go To Previous Curve"] \
            -text [msgcat::mc "<"] \
            -command [code prevtable ]
      grid $childsite.prevtable -column 6 -row 3 -sticky news

      bind $childsite.prevtable <ButtonRelease-1> \
                  [code ::euidl::material::error::check %W]

      euidl::button $childsite.addtable -text [msgcat::mc "Add Curve"] \
            -command [code addtable ]
      grid $childsite.addtable -column 7 -row 3 -sticky news

      euidl::button $childsite.deltable -text [msgcat::mc "Del Curve"] \
            -command [code deletetable ]
      grid $childsite.deltable -column 8 -row 3 -sticky news


      euidl::button $childsite.nexttable \
            -tooltip [msgcat::mc "Go To Next Curve"] \
            -text [msgcat::mc ">"] \
            -command [code nexttable ]
      grid $childsite.nexttable -column 9 -row 3 -sticky nws

      bind $childsite.nexttable <ButtonRelease-1> \
                  [code ::euidl::material::error::check %W]

      #Graph button OR Graph drop-down

      set listMPmult {GASKNUNL}

      set match [lsearch -exact $listMPmult $labelin]
      if {$match >= 0} {
         # Create the menubar for graph
         menubutton  $childsite.mb1 -text [msgcat::mc "Graph"] \
            -menu $childsite.mb1.menu -borderwidth 2 \
            -relief raised
         bind $childsite.mb1 <ButtonPress-1> {focus %W}
         menu $childsite.mb1.menu -tearoff 0

         grid $childsite.mb1 -sticky e -column 11 -row 3

      } else {

         euidl::button $childsite.graph -text [msgcat::mc "Graph"] \
               -command [code graph 0]
         grid $childsite.graph -sticky e -column 11 -row 3

         bind $childsite.graph <ButtonRelease-1> \
                     [code ::euidl::material::error::check %W]
      }

      grid columnconfigure $childsite 2 -minsize 50
      grid columnconfigure $childsite 5 -minsize 40
      grid columnconfigure $childsite 7 -minsize 40
      grid columnconfigure $childsite 9 -weight 1
 
      $parent6 configure \
            -okcommand [code matOpts_Ok 0 $mat $next] \
            -cancelcommand [code matOpts_Cancel] \
            -helpcommand [list ans_loadhelp Hlp_UI_mat_dat]
      

      # COMMAND DESCRIPTION-HAVE TO CHANGE THE MESSAGE DEPENDING ON THE LABEL
      #set number of cols and rows depending on the label

      switch -exact -- $labelin {
        
         GASKNUNL {
            euidl::label $childsite.lbl$labelin -height 3 \
                  -anchor w \
                  -text [msgcat::mc "Gasket Nonlinear Unloading\
                       for Material Number $mat: Curve number $curtab/$numtab"]
            wm title $parent6 [msgcat::mc "Gasket Nonlinear Unloading\
                       for Material Number $mat"]
            set numcol 1
            set realcol 3
            set numrow 1
            set actrow(1) 1
            $tableName config -colmax 60
            set colmax 100
            $tableName config -rowmax 101
            set rowmax 100
            $parent6 configure -helpcommand [list ans_loadhelp Hlp_gask]
            set tbopt NUNL
            $childsite.lbl$labelin configure \
                        -text [msgcat::mc "Gasket Nonlinear Unloading\
                             for Material Number $matlabel: Curve number $curtab/$numtab"]

             #set the graph drop-down button
             set ind 0
             foreach m [list All Current] {
                set ind [expr $ind + 1]
                $childsite.mb1.menu add command \
                     -label [msgcat::mc "$m"] \
                     -command [code graph $m] 

             }
         }
      }

     grid $childsite.lbl$labelin -sticky new -column 0 -row 0 \
            -columnspan 12
     
     #The 2 first rows are TITLES
     $tableName configure -titlerows 2
     
     #set the tags sunken - disabledsunken -disab
     $tableName tag configure sunken -relief sunken \
           -state normal \
           -background  [$tableName cget -cellbackground]
     $tableName tag cell sunken -1,1

     $tableName tag configure disabledsunken -relief sunken \
           -state disabled \
           -background [$tableName cget -disabledbackground]\
           -foreground [$tableName cget -disabledforeground]

     $tableName tag configure disab  -state disabled   
    
     $tableName tag raise sunken title
     $tableName tag raise disabledsunken title
     $tableName tag raise disab title

     #set the default width
     $tableName configure -colwidth 11
     

      filltable $mat

   
      grid $tableName -sticky news -column 0 -row 2 -columnspan 12
      grid rowconfigure $childsite 2 -weight 1

      # Set the max view height for the table
      grid rowconfigure $childsite 2 -minsize 150

     
      update idletasks
      wm minsize $parent6 [expr [winfo reqwidth $parent6] + 50] \
                          [expr [winfo reqheight $parent6] + 50]

      grid propagate $childsite 0
      
      $parent6 activate

      set treeChildsite $childsite
    
      $tableName selection set 1,0
      $tableName activate 1,0
      $tableName selection anchor 1,0
      $tableName see active
   }

   proc nexttable {} {
      variable tbdata
      variable realcol
      variable maxntb
      for { set ntb 1 } { $ntb <= $maxntb } { incr ntb 1 } {
         variable tbdata$ntb
         variable actrow$ntb
      }
      variable curtab
      variable numtab
      variable tableName
      variable actrow
      variable numcol
      variable allnumcol
      variable numrow
      variable allnumrow
      variable labelin
      variable parent6
      variable matlabel

      if { $curtab >= $numtab } {
         return
      }

      #Copy from buffer to actual data      
      catch { unset tbdata$curtab }
      catch { unset actrow$curtab }
      array set tbdata$curtab [array get tbdata]
      array set actrow$curtab [array get actrow]
      set allnumrow($curtab) $numrow
      set allnumcol($curtab) $numcol

      #updata curtab
      set curtab [expr $curtab + 1 ]

      #Copy from next data to buffer
      catch { unset tbdata }
      catch { unset actrow }
      array set tbdata [array get tbdata$curtab]
      array set actrow [array get actrow$curtab]
      set numrow $allnumrow($curtab)
      set numcol $allnumcol($curtab)
      update idletasks
      updatatablestate

      #reconfigure the label
      set childsite [$parent6 component childsite]
      $childsite.lbl$labelin configure \
                  -text [msgcat::mc "Gasket Nonlinear Unloading\
                       for Material Number $matlabel: Curve number $curtab/$numtab"]

   }

   proc prevtable {} {
      variable tbdata
      variable maxntb
      for { set ntb 1 } { $ntb <= $maxntb } { incr ntb 1 } {
         variable tbdata$ntb
         variable actrow$ntb
      }
      variable numtab
      variable curtab
      variable tableName
      variable actrow
      variable numcol
      variable allnumcol
      variable numrow
      variable allnumrow
      variable realcol
      variable labelin
      variable parent6
      variable matlabel

      if { $curtab == 1 } {
         return
      }
      
      catch { unset tbdata$curtab }
      catch { unset actrow$curtab }
      array set tbdata$curtab [array get tbdata]
      array set actrow$curtab [array get actrow]
      set allnumrow($curtab) $numrow
      set allnumcol($curtab) $numcol

      set curtab [expr $curtab - 1 ]

      catch { unset tbdata }
      catch { unset actrow }
      set numrow $allnumrow($curtab)
      set numcol $allnumcol($curtab)
      array set tbdata [array get tbdata$curtab]
      array set actrow [array get actrow$curtab]

      update idletasks
      updatatablestate

      #reconfigure the label
      set childsite [$parent6 component childsite]
      $childsite.lbl$labelin configure \
                  -text [msgcat::mc "Gasket Nonlinear Unloading\
                       for Material Number $matlabel: Curve number $curtab/$numtab"]

   }


   proc addtable {} {
      variable tbdata
      variable maxntb
      for { set ntb 1 } { $ntb <= $maxntb } { incr ntb 1 } {
         variable tbdata$ntb
         variable actrow$ntb
      }
      variable curtab
      variable numtab
      variable tableName
      variable actrow
      variable numcol
      variable allnumcol
      variable numrow
      variable allnumrow
      variable labelin
      variable parent6
      variable matlabel
      variable tableName
      variable realcol

      if { $numtab >= $maxntb } {
         ans_senderror 2 "Total number of Tables cannot go above $maxntb."
         return
      }

      # copy table data that is currently being edited
      catch { unset actrow$curtab }
      catch { unset tbdata$curtab }
      array set tbdata$curtab [array get tbdata]
      array set actrow$curtab [array get actrow]
      set allnumcol($curtab) $numcol
      set allnumrow($curtab) $numrow

      
      set numtab [expr $numtab + 1]
      set curtab [expr $curtab + 1]
      
      for { set i $numtab } { $i > $curtab} { incr i -1 } {

         set front $i
         set back [expr $i - 1]


         #Unset the +1 data
         catch { unset tbdata$front }
         catch { unset actrow$front }

         #Copy forward
         array set tbdata$front [array get tbdata$back]
         array set actrow$front [array get actrow$back]
         set allnumrow($front) $allnumrow($back)
         set allnumcol($front) $allnumcol($back)
      }

      catch { unset tbdata }
      catch { unset actrow }
      set numcol 1
      set realcol 3
      set numrow 1
      array set actrow { 1 1 }

      set tbdata(-1,0) T1
      switch -exact -- $labelin {
       GASKNUNL {
               set tbdata(0,0) CLOSURE
               set tbdata(0,1) PRESSURE
       }
       default {
               set tbdata(0,0) STRAIN
               set tbdata(0,1) STRESS
       }
      }
      set tbdata(1,-1) 1
      set tbdata(-1,1) 0.0
      set tbdata(1,0) 0.0
      set tbdata(1,1) 0.0

      $tableName width -1 5
      $tableName width 2 5
      $tableName configure -rows [expr $numrow +2] -cols  [expr $realcol+1]
      $tableName tag cell disabledtitle -1,0
      $tableName tag cell disabledsunken -1,1
      catch { label $tableName.dum1{-}2  }
      $tableName window configure 1,2 -window $tableName.dum1{-}2\
                           -sticky news 
      $tableName tag cell disab 1,2        

      #Clear old data
      catch { unset tbdata$curtab }
      catch { unset actrow$curtab }

      array set tbdata$curtab [array get tbdata]
      array set actrow$curtab [array get actrow]
      set allnumcol($curtab) $numcol
      set allnumrow($curtab) $numrow

      update idletasks
      updatatablestate

      #reconfigure the label
      set childsite [$parent6 component childsite]
      $childsite.lbl$labelin configure \
                  -text [msgcat::mc "Gasket Nonlinear Unloading\
                       for Material Number $matlabel: Curve number $curtab/$numtab"]
   }

   proc deletetable {} {
      variable tbdata
      variable maxntb
      for { set ntb 1 } { $ntb <= $maxntb } { incr ntb 1 } {
         variable tbdata$ntb
         variable actrow$ntb
      }
      variable curtab
      variable numtab
      variable tableName
      variable actrow
      variable numcol
      variable allnumcol
      variable numrow
      variable allnumrow
      variable labelin
      variable parent6
      variable matlabel
      variable tableName
      variable realcol

      if { $numtab > 1 } {

         #Copy front to back
         for { set i $curtab } { $i < $numtab} { incr i 1 } {

            set back $i
            set front [expr $i + 1]


            #Unset the +1 data
            catch { unset tbdata$back }
            catch { unset actrow$back }

            #Copy forward
            array set tbdata$back [array get tbdata$front]
            array set actrow$back [array get actrow$front]
            set allnumrow($back) $allnumrow($front)
            set allnumcol($back) $allnumcol($front)
         }

         #Unset the +1 data
         catch { unset tbdata$numtab }
         catch { unset actrow$numtab }

         #Decrease numtab
         set numtab [expr $numtab - 1]
         
         if { $curtab > $numtab } {
            set curtab [expr $curtab - 1]
         }

         #Copy from database to buffer
         array set tbdata [array get tbdata$curtab]
         array set actrow [array get actrow$curtab]
         set numrow $allnumrow($curtab)
         set numcol $allnumcol($curtab)

      } else {

         catch { unset tbdata }
         catch { unset actrow }
         set numcol 1
         set realcol 3
         set numrow 1
         array set actrow { 1 1 }

         set tbdata(-1,0) T1
         switch -exact -- $labelin {
          GASKNUNL {
                  set tbdata(0,0) CLOSURE
                  set tbdata(0,1) PRESSURE
          }
          default {
                  set tbdata(0,0) STRAIN
                  set tbdata(0,1) STRESS
          }
         }
         set tbdata(1,-1) 1
         set tbdata(-1,1) 0.0
         set tbdata(1,0) 0.0
         set tbdata(1,1) 0.0

         $tableName width -1 5
         $tableName width 2 5
         $tableName configure -rows [expr $numrow +2] -cols  [expr $realcol+1]
         $tableName tag cell disabledtitle -1,0
         $tableName tag cell disabledsunken -1,1
         catch { label $tableName.dum1{-}2  }
         $tableName window configure 1,2 -window $tableName.dum1{-}2\
                              -sticky news 
         $tableName tag cell disab 1,2        

         #Clear old data
         catch { unset tbdata$curtab }
         catch { unset actrow$curtab }

         array set tbdata$curtab [array get tbdata]
         array set actrow$curtab [array get actrow]
         set allnumcol($curtab) $numcol
         set allnumrow($curtab) $numrow
      }

      update idletasks
      updatatablestate

      #reconfigure the label
      set childsite [$parent6 component childsite]
      $childsite.lbl$labelin configure \
                  -text [msgcat::mc "Gasket Nonlinear Unloading\
                       for Material Number $matlabel: Curve number $curtab/$numtab"]
   }

   proc updatatablestate {} {
      #numcol is the number of temps
      #numrow is the number of rows in the table
      variable numtab
      variable numcol
      variable realcol
      variable numrow
      variable tbdata
      variable numtemp
      variable labelin
      variable tbopt
      variable actrow
     
      #realcol is the real number of cols in the table
      #actrow(x) is the number of active rows for each temp
      variable realcol 
      
      variable tabmax
      variable colmax
      variable rowmax
              
      variable parent6
      variable childsite
      variable tableName
      variable treeChildsite

      #configure the tktable

      $tableName configure -rows [expr int($numrow) + 2]\
                           -cols [expr int($numcol)*3 + 1]

      #update realcol 
      set realcol [expr $numcol*3]

      #make the unused cells flat

      for {set i 1} {$i<=$numcol} {incr i 1} {
         for {set j [expr $actrow($i)+1]} {$j <= $numrow} {incr j 1} {                
             catch { label $tableName.dum$j{-}[expr ($i-1)*3 ] }
             $tableName window configure $j,[expr ($i-1)*3 ]\
                          -window $tableName.dum$j{-}[expr ($i-1)*3 ]\
                          -sticky news
             $tableName tag cell disab $j,[expr ($i-1)*3 ]
             catch { label $tableName.dum$j{-}[expr ($i-1)*3+1] }
             $tableName window configure $j,[expr ($i-1)*3+1]\
                          -window $tableName.dum$j{-}[expr ($i-1)*3+1]\
                          -sticky news
             $tableName tag cell disab $j,[expr ($i-1)*3+1]
         }
         for {set j 1} {$j <= $numrow} {incr j 1} {
             catch { label $tableName.dum$j{-}[expr ($i-1)*3+2] }
             $tableName window configure $j,[expr ($i-1)*3+2]\
                          -window $tableName.dum$j{-}[expr ($i-1)*3+2]\
                          -sticky news
             $tableName tag cell disab $j,[expr ($i-1)*3+2]
         }
         $tableName tag cell sunken -1,[expr ($i-1)*3 +1]
         $tableName width [expr ($i-1)*3 +2] 5
      }

      #now format temperature data
      #for {set i 1} {$i<=$numcol} {incr i 1} {
      #   set tbdata(-1,[expr ($i - 1)*3 + 1]) \
      #       [format "%-10.5G" $tbdata(-1,[expr ($i - 1)*3 + 1])]
      #   set tbdata(-1,[expr ($i - 1)*3 + 1]) \
      #       [string trimright $tbdata(-1,[expr ($i - 1)*3 + 1])]    
      #}
      # disable temp cells if only one temperature defined
      #if {$numcol > 1} {
      #   $tableName tag cell normaltitle -1,0
      #   $tableName tag cell sunken -1,1
      #} else {
      #   $tableName tag cell disabledtitle -1,0
      #   $tableName tag cell disabledsunken -1,1
      #}
   }


   proc filltable { mat } {

      #numcol is the number of temps
      #numrow is the number of rows in the table
      variable numtab
      variable curtab
      variable numcol
      variable numrow
      variable allnumcol
      variable allnumrow
      variable tbdata
      variable maxntb
      for { set ntb 1 } { $ntb <= $maxntb } { incr ntb 1 } {
         variable tbdata$ntb
         variable actrow$ntb
      }
      variable actrow
      variable numtemp
      variable labelin
      variable tbopt
      variable realcol
     
      #realcol is the real number of cols in the table
      #actrow(x) is the number of active rows for each temp
      variable realcol
      
      variable tabmax
      variable colmax
      variable rowmax
              
      variable parent6
      variable childsite
      variable tableName
      variable treeChildsite
      variable matlabel

      # FILL THE TABLE WITH EXISTING DATA IF TABLE EXISTS
      
      set tboptcmd "    "

      switch -glob -- $labelin {
         GASK* {
            set tboptcmd $tbopt
         }
      }

      set tb [ans_getvalue $labelin,$mat,EXIS,,,,$tboptcmd]
      if {$tb == 1} {          

          #set tbdata(0,-1) Temps
          $tableName width -1 5
         
          #Get the number of tables
          set numtab [expr int([ans_getvalue $labelin,$mat,NTAB,,,,$tboptcmd])]

          #Loop through each curve or table
          for {set icurve $numtab} {$icurve >= 1} {incr icurve -1} {

             #get the number of temperatures
             set numcol [expr int([ans_getvalue $labelin,$mat,NTEMP,,,,$tboptcmd,$icurve])]
             #get the value of each temps TVAL & set the labels
             for {set i 1} {$i<=$numcol} {incr i 1} {
                switch -exact -- $labelin {
                   GASKNUNL {
                       set tbdata(0,[expr ($i-1)*3 ]) CLOSURE
                       set tbdata(0,[expr ($i-1)*3 +1]) PRESSURE
                   }
                   default {
                       set tbdata(0,[expr ($i-1)*3 ]) STRAIN
                       set tbdata(0,[expr ($i-1)*3 +1]) STRESS
                   }
                }
                set tbdata(-1,[expr ($i-1)*3 ]) "T$i"
                set tbdata(-1,[expr ($i-1)*3 +1]) [ans_getvalue $labelin,$mat,TVAL,$i,,,$tboptcmd,$icurve]            
             }
          
          
             # Loop through each temperature and get the data
             for {set i 0} {$i<$numcol} {incr i 1} {

                #get the number of rows
                #Inside ANSYS the table is row*temp and filled with
                # zeros if not defined
                set numrow [ans_getvalue $labelin,$mat,TEMP,$tbdata(-1,[expr $i*3 +1]),NCONST,,$tboptcmd,$icurve]
                #There is 2 data pts per row 
                set numrow [expr $numrow/2]


                set actrow([expr $i+1]) $numrow

                for {set j 1} {$j<=$numrow} {incr j 1} {
                   set tbdata($j,-1) $j
                   set k [expr $j*2 -1]
                   set l [expr $j*2]
                   set tbdata($j,[expr $i*3])\
                     [ans_getvalue $labelin,$mat,TEMP,$tbdata(-1,[expr $i*3 +1]),CONS,$k,$tboptcmd,$icurve]
                   set tbdata($j,[expr $i*3]) [format "%-10.5G" $tbdata($j,[expr $i*3])]
                   set tbdata($j,[expr $i*3]) [string trimright $tbdata($j,[expr $i*3])]

                   set tbdata($j,[expr $i*3+1])\
                     [ans_getvalue $labelin,$mat,TEMP,$tbdata(-1,[expr $i*3 +1]),CONS,$l,$tboptcmd,$icurve]
                   set tbdata($j,[expr $i*3+1]) [format "%-10.5G" $tbdata($j,[expr $i*3+1])]
                   set tbdata($j,[expr $i*3+1]) [string trimright $tbdata($j,[expr $i*3+1])]

                   #End of the table when 0,0 is reached
                   #avoid the case : only tbtemp defined -> create 2 blank entries
                   if {$j > 1} {
                      if {$tbdata($j,[expr $i*3]) == 0 && $tbdata($j,[expr $i*3 +1]) == 0} {
                         unset tbdata($j,[expr $i*3])
                         unset tbdata($j,[expr $i*3 +1])
                         set actrow([expr $i+1]) [expr $j -1]
                         break
                      }
                   }
                }
             }
             #Recalculate numrow = max actrow(x)
             set numrow $actrow(1)    
             for {set i 1} {$i <= $numcol} {incr i 1} {
                if {$actrow($i) >= $numrow} {
                    set numrow $actrow($i)
                }         
             }

             array set tbdata$icurve [array get tbdata]
             array set actrow$icurve [array get actrow]
             set allnumcol($icurve) $numcol
             set allnumrow($icurve) $numrow
          }
       
       
   
          #configure the tktable

          $tableName configure -rows [expr int($numrow) + 2]\
                               -cols [expr int($numcol)*3 + 1]

          #update realcol 
          set realcol [expr $numcol*3]

          #make the unused cells flat

          for {set i 1} {$i<=$numcol} {incr i 1} {
             for {set j [expr $actrow($i)+1]} {$j <= $numrow} {incr j 1} {                
                 label $tableName.dum$j{-}[expr ($i-1)*3 ]
                 $tableName window configure $j,[expr ($i-1)*3 ]\
                              -window $tableName.dum$j{-}[expr ($i-1)*3 ]\
                              -sticky news
                 $tableName tag cell disab $j,[expr ($i-1)*3 ]
                 label $tableName.dum$j{-}[expr ($i-1)*3+1]
                 $tableName window configure $j,[expr ($i-1)*3+1]\
                              -window $tableName.dum$j{-}[expr ($i-1)*3+1]\
                              -sticky news
                 $tableName tag cell disab $j,[expr ($i-1)*3+1]
             }
             for {set j 1} {$j <= $numrow} {incr j 1} {
                 label $tableName.dum$j{-}[expr ($i-1)*3+2]
                 $tableName window configure $j,[expr ($i-1)*3+2]\
                              -window $tableName.dum$j{-}[expr ($i-1)*3+2]\
                              -sticky news
                 $tableName tag cell disab $j,[expr ($i-1)*3+2]
             }
             $tableName tag cell sunken -1,[expr ($i-1)*3 +1]
             $tableName width [expr ($i-1)*3 +2] 5
          }
          #now format temperature data
          for {set i 1} {$i<=$numcol} {incr i 1} {
             set tbdata(-1,[expr ($i - 1)*3 + 1]) \
                 [format "%-10.5G" $tbdata(-1,[expr ($i - 1)*3 + 1])]
             set tbdata(-1,[expr ($i - 1)*3 + 1]) \
                 [string trimright $tbdata(-1,[expr ($i - 1)*3 + 1])]    
          }
          # disable temp cells if only one temperature defined
          #if {$numcol > 1} {
          #   $tableName tag cell normaltitle -1,0
          #   $tableName tag cell sunken -1,1
          #} else {
          #   $tableName tag cell disabledtitle -1,0
          #   $tableName tag cell disabledsunken -1,1
          #}

      #if table does not exist, set the default
      } else {        
         set curtab 1
         set tbdata(-1,0) T1
         switch -exact -- $labelin {
          GASKNUNL {
                  set tbdata(0,0) CLOSURE
                  set tbdata(0,1) PRESSURE
          }
          default {
                  set tbdata(0,0) STRAIN
                  set tbdata(0,1) STRESS
          }
         }
         set tbdata(1,-1) 1
         #set tbdata(-1,-1) Temps
         set tbdata(1,-1) 1
         set tbdata(-1,1) 0.0
         set tbdata(1,0) 0.0
         set tbdata(1,1) 0.0

         $tableName width -1 5
         $tableName width 2 5
         $tableName configure -rows [expr $numrow +2] -cols  [expr $realcol+1]
         #$tableName tag cell disabledtitle -1,0
         #$tableName tag cell disabledsunken -1,1
         label $tableName.dum1{-}2         
         $tableName window configure 1,2 -window $tableName.dum1{-}2\
                              -sticky news 
         #$tableName tag cell disab 1,2  
         set allnumrow($curtab)  $numrow
         set allnumcol($curtab)  $numcol
      }     

      #reconfigure the label
      set childsite [$parent6 component childsite]
      $childsite.lbl$labelin configure \
                  -text [msgcat::mc "Gasket Nonlinear Unloading\
                       for Material Number $matlabel: Curve number $curtab/$numtab"]

   }


   #ADD 3 COLUMNS TO THE TABLE# 
   proc addcolumn {} {
        
        variable parent6
        variable tableName
        variable tbdata
        variable labelin
        variable numcol
        variable numrow
        variable realcol
        variable actrow
        variable colmax
        variable treeChildsite
       

        if {$numcol >= $colmax} {
             tk_messageBox -icon warning \
                  -title [msgcat::mc "Maximum Number of columns"] \
                  -type ok \
                  -message [msgcat::mc " This table\
                           allows only $colmax temperatures."]\
                  -parent $parent6
        } else {
        #temp cells are now available
        $tableName tag cell normaltitle -1,0
        $tableName tag cell sunken -1,1

        # curColumn is the column having the focus in (cursor)
        if {[catch {$tableName index active col} curColumn]} {
           set curColumn 0
        }
        # you want to set Curcolumn = 3*N+2 
        for {set i 1} {$i <= $numcol} {incr i 1} {
                set toto [expr ($i-1) * 3]
                set tata [expr (($i -1) * 3)+1]
                if {$curColumn == $toto} {
                   set curColumn [expr $curColumn +2]
                }  elseif {$curColumn == $tata} {
                   set curColumn [expr $curColumn + 1]
                }
        }
       
        # Insert 3 columns after curColumn
            
        $tableName insert col -keeptitles -- $curColumn 3

        # Move the view to see added column
        $tableName xview scroll 1 unit

        incr numcol 1

        
        #reorganize actrow table
        set h [expr int($curColumn/3 +1)]
        for {set i $numcol} {$i > [expr $h+1]} {incr i -1} {
                 set actrow($i) $actrow([expr $i-1])
            }
        set actrow([expr $h+1]) 1
        
         #create all the flat cells for th cols that have been moved
        
        for {set i $numcol} {$i > [expr $h+1]} {incr i -1} {
           
            for {set b [expr $actrow($i)+1]} {$b <= $numrow} {incr b 1} {
                set z [expr $i*3 -3]
                catch {label  $tableName.dum$b{-}$z}
                $tableName window configure $b,$z\
                              -window $tableName.dum$b{-}$z\
                              -sticky news
                $tableName tag cell disab $b,$z
                catch {label  $tableName.dum$b{-}[expr $z+1]}
                $tableName window configure $b,[expr $z+1]\
                              -window $tableName.dum$b{-}[expr $z+1]\
                              -sticky news
                $tableName tag cell disab $b,[expr $z+1]
            } 
            for {set b 1} {$b <= $numrow} {incr b 1} {
                set z [expr $i*3 -3]
                catch {label  $tableName.dum$b{-}[expr $z+2]}
                $tableName window configure $b,[expr $z+2]\
                              -window $tableName.dum$b{-}[expr $z+2]\
                              -sticky news 
                $tableName tag cell disab $b,[expr $z+2]   
            }                
        }

        # make the cells in the new column flat (except the 2 first)
        for {set i 2} {$i <=$numrow} {incr i 1} {
            catch {label  $tableName.dum$i{-}[expr $curColumn +1]}
            $tableName window configure $i,[expr $curColumn +1]\
                              -window $tableName.dum$i{-}[expr $curColumn +1]\
                              -sticky news
            $tableName tag cell disab $i,[expr $curColumn +1]
            catch {label  $tableName.dum$i{-}[expr $curColumn +2]}
            $tableName window configure $i,[expr $curColumn +2]\
                              -window $tableName.dum$i{-}[expr $curColumn +2]\
                              -sticky news
            $tableName tag cell disab $i,[expr $curColumn +2]
            catch {label  $tableName.dum$i{-}[expr $curColumn +3]}
            $tableName window configure $i,[expr $curColumn +3]\
                              -window $tableName.dum$i{-}[expr $curColumn +3]\
                              -sticky news
            $tableName tag cell disab $i,[expr $curColumn +3]
           
        }
       

        # Label this new column
        set tbdata(-1,$realcol) "T$numcol"
        switch -exact -- $labelin { 
         GASKNUNL {
                  set tbdata(0,$realcol) CLOSURE
                  set tbdata(0,[expr $realcol +1]) PRESSURE
         }
         default {
                  set tbdata(0,$realcol) STRAIN
                  set tbdata(0,[expr $realcol +1]) STRESS
         }     
        }
        $tableName tag cell sunken -1,[expr $realcol +1]
        catch {label $tableName.dum1{-}[expr $curColumn +3]}
        $tableName window configure 1,[expr $curColumn +3]\
                  -window $tableName.dum1{-}[expr $curColumn +3]\
                  -sticky news
        $tableName tag cell disab 1,[expr $curColumn +3]
        $tableName width [expr $curColumn +3] 5
        
        #update realcol
        incr realcol 3 

        #Move the temperature data
        for {set i [expr $realcol -2]} {$i > [expr $curColumn +3]} {incr i -3} {
             if {[catch {set tbdata(-1,$i) $tbdata(-1,[expr $i-3])}]} {
                         set tbdata(-1,$i) ""
                }
        }
        #set the new temp data to blank
        set tbdata(-1,[expr $curColumn +2]) ""
       
  
        update
        #activate the new column
        $tableName selection activate -1,[expr $curColumn +2]
        $tableName see active
        }

   }


   #ADD A ROW IN THE TABLE#
   proc addrow {} {
        
        variable parent6
        variable tableName
        variable tbdata
        variable labelin
        variable numrow
        variable numcol
        variable realcol
        variable actrow
        variable rowmax
        variable treeChildsite

        if {$numrow >= $rowmax} {
             tk_messageBox -icon warning \
                  -title [msgcat::mc "Maximum Number of points"] \
                  -parent $parent6 \
                  -type ok \
                  -message [msgcat::mc " This table \
                        allows only $rowmax points."]
        } else {

       
         # curRow is the column having the focus in (cursor)
        if {[catch {$tableName index active row} curRow]} {
           set curRow 1
        }
        if {$curRow <= 0} {
           set curRow 1
        }
        if {[catch {$tableName index active col} curColumn]} {
           set curColumn 0
        }
        if {$curColumn < 0 } {
           set curColumn 0
        }
       

        #h is the temperature index...h has values between 1 and numcol
        set h [expr int($curColumn/3 +1)]

        # Insert a row after the currently selected one if actrow(h) = numrow
        # in this case you have to create a new row
        # if actrow(h) < numrow you just want to sunken 2 cells

        if {$actrow($h) == $numrow && $curRow > 0} {
           
            #insert a row at the end of the table   
            $tableName insert row -keeptitles -- $actrow($h) 1

            # Move the view to see added row
            #$tableName yview scroll 1 unit

            incr numrow

            # Label this new row
            set tbdata($numrow,-1) $numrow

            #make flat all the new cells in the new row
            for {set w 0} {$w < $realcol} {incr w 1} {
               catch {label $tableName.dum$numrow{-}$w}
               $tableName window configure $numrow,$w\
                  -window $tableName.dum$numrow{-}$w\
                  -sticky news
               $tableName tag cell disab $numrow,$w
            }

            #set curColumn = 3N+1
            for {set i 1} {$i <= $numcol} {incr i 1} {
                set toto [expr ($i-1) * 3]
                set tata [expr (($i -1) * 3)+2]
                if {$curColumn == $toto} {
                   set curColumn [expr $curColumn +1]
                }  elseif {$curColumn == $tata} {
                   set curColumn [expr $curColumn - 1]
                }               
            }
           
            #update the number of active rows for this column
            set actrow($h) [expr $actrow($h) +1]
           
            #make the two cells sunken in the right columns
            destroy $tableName.dum$numrow{-}[expr $curColumn -1]
            destroy $tableName.dum$numrow{-}$curColumn
            $tableName tag cell sunken $numrow,[expr $curColumn -1]
            $tableName tag cell sunken $numrow,$curColumn 

            #move the data if necessary
            for {set i $actrow($h)} {$i > $curRow} {incr i -1} {
               if {[catch {set tbdata($i,$curColumn) \
                            $tbdata([expr $i-1],$curColumn)}]} {
                   set  tbdata($i,$curColumn) ""
               }
               if {[catch {set tbdata($i,[expr $curColumn -1]) \
                            $tbdata([expr $i-1],[expr $curColumn -1])}]} {
                   set tbdata($i,[expr $curColumn -1]) ""
               }
            }
            set tbdata([expr $curRow +1],$curColumn) ""
            set tbdata([expr $curRow +1],[expr $curColumn -1]) ""

        
        } elseif {$actrow($h) < $numrow && $curRow > 0} {
            # in this case you just want to sunken 2 cells
           
            # Move the view to see added row
            #$tableName yview scroll 1 unit

            #set curColumn = 3N+1
            for {set i 1} {$i <= $numcol} {incr i 1} {
                set toto [expr ($i-1) * 3]
                set tata [expr (($i -1) * 3)+2]
                if {$curColumn == $toto} {
                   set curColumn [expr $curColumn +1]
                }  elseif {$curColumn == $tata} {
                   set curColumn [expr $curColumn - 1]
                }
            }

            #update the number of active rows for this column
            set actrow($h) [expr $actrow($h) +1]
            destroy $tableName.dum[expr $actrow($h)]{-}[expr $curColumn -1]
            destroy $tableName.dum[expr $actrow($h)]{-}$curColumn
            $tableName tag cell sunken [expr $actrow($h)],[expr $curColumn -1]
            $tableName tag cell sunken [expr $actrow($h)],$curColumn 

            #Only move the data - no adding rows
            for {set i $actrow($h)} {$i > $curRow} {incr i -1} {
                
               if {[catch {set tbdata($i,$curColumn) \
                            $tbdata([expr $i-1],$curColumn)}]} {
                   set  tbdata($i,$curColumn) ""
               }
               if {[catch {set tbdata($i,[expr $curColumn -1]) \
                            $tbdata([expr $i-1],[expr $curColumn -1])}]} {
                   set tbdata($i,[expr $curColumn -1]) ""
               }
            }
            set tbdata([expr $curRow +1],$curColumn) ""
            set tbdata([expr $curRow +1],[expr $curColumn -1]) ""
       } 
       update
       #activate the new row
       $tableName selection activate [expr $curRow +1],$curColumn
       $tableName see active
       }  
            
   }

    #Check the rows selected and call delrow for each of them#
    #default to the last one created#

    proc rowselect {} {

        variable parent6
        variable tableName
        variable treeChildsite

        #create a list of sorted selected cells format {0,0 0,1 ....}
        set listcell [$tableName curselection]
        set length [llength $listcell]

        #get the first cell and the last cell selected
        set first [lindex  $listcell 0]
        set lastind [expr $length -1]
        set last [lindex  $listcell $lastind]
        
        #get the first and the last row 
        set firstlis [split $first ,]
        set firstrow  [lindex  $firstlis 0]
       
        catch {$tableName index active col} curColumn
        catch {$tableName index active row} curRow
       
        set lastlis [split $last ,]
        set lastrow  [lindex  $lastlis 0]
       
       
        if {$length == 0} {
            
             if {[catch {$tableName index active row} firstrow]} {
               set firstrow 2
             }
             set lastrow $firstrow
        }
 
        #Delete all the rows selected
        if { $curColumn < 0 && $curRow < 1 } {
           tk_messageBox -icon warning \
               -message [msgcat::mc "Cannot delete entire table.  You must select a point first"] \
               -parent $parent6
        } elseif { $curColumn < 0 } {
           tk_messageBox -icon warning \
               -message [msgcat::mc "Cannot delete entire row.  You must select a point first"] \
               -parent $parent6
        } elseif { $curRow < 1 } {
           tk_messageBox -icon warning \
               -message [msgcat::mc "Cannot delete entire column.  You must select a point first"] \
               -parent $parent6
        } else {
           for {set i $firstrow} {$i <= $lastrow} {incr i 1} {
              delrow $firstrow
           }
        }

   }
    
    #Check the cols selected and call delcolumn for each of them#
    #default to the last one created#

    proc colselect {} {

        variable tableName
        variable numcol
        

        #create a list of sorted selected cells format {0,0 0,1 ....}
        set listcell [$tableName curselection]
        set length [llength $listcell]

        #get the first cell and the last cell selected
        set first [lindex  $listcell 0]
        set lastind [expr $length -1]
        set last [lindex  $listcell $lastind]

        #get the first and the last columns
        set firstlis [split $first ,]
        set firstcol [lindex  $firstlis 1]
       
        set lastlis [split $last ,]
        set lastcol  [lindex  $lastlis 1]
       
        if {$length == 0} {
            
             if {[catch {$tableName index active col} firstcol]} {
               set firstcol 3
             }
             set lastcol $firstcol
        }
        #convert firstcol & lastcol = 3N
        for {set i 1} {$i <= $numcol} {incr i 1} {
               set toto [expr (($i-1) * 3)+1]
               set tata [expr (($i -1) * 3)+2]
               if {$firstcol == $toto} {
                   set firstcol [expr $firstcol -1]
               }  elseif {$firstcol == $tata} {
                   set firstcol [expr $firstcol - 2]
               }
               if {$lastcol == $toto} {
                   set lastcol [expr $lastcol -1]
               }  elseif {$lastcol == $tata} {
                   set lastcol [expr $lastcol - 2]
               }
        }
        #Delete all the columns selected
        for {set i $firstcol} {$i <= $lastcol} {incr i 3} {
            delcolumn $firstcol
        }
        
   }
    #DELETE A COLUMN IN THE TABLE#

    proc delcolumn { curColumn } {

        variable parent6
        variable tableName
        variable labelin
        variable tbdata
        variable numcol
        variable numrow
        variable actrow
        variable realcol
        variable treeChildsite
        variable tbdata

       
        
        if {$numcol >= 2} {
            #if {[catch {$tableName index active col} curColumn]} {
            #   set curColumn 3
            #}
            #set curColumn = 3N
            #for {set i 1} {$i <= $numcol} {incr i 1} {
            #   set toto [expr (($i-1) * 3)+1]
            #   set tata [expr (($i -1) * 3)+2]
            #   if {$curColumn == $toto} {
            #       set curColumn [expr $curColumn -1]
            #   }  elseif {$curColumn == $tata} {
            #       set curColumn [expr $curColumn - 2]
            #   }
            #}

           

            #reorganize actrow table
            set h [expr int($curColumn/3 +1)]
            for {set i $h} {$i < $numcol} {incr i 1} {
                 set actrow($i) $actrow([expr $i+1])
            }
            set actrow($numcol) 0
            
            #update numcol & realcol
            set numcol [expr $numcol - 1]
            set realcol [expr $realcol - 3]

            #Move the temperature data

            for {set i [expr $curColumn +1]} {$i < [expr $realcol +1]} {incr i 3} {
                   set tbdata(-1,$i) $tbdata(-1,[expr $i+3])
            }
            set tbdata(-1,[expr $realcol +1]) 0 

           
            #delete 3 columns after CurColumn
            $tableName delete cols -keeptitles -- $curColumn 3
         
            #deactivate the temp cells if only one
            if {$numcol < 2} {
               $tableName tag cell disabledtitle -1,0
               $tableName tag cell disabledsunken -1,1
      
            }

            #delete some rows if the biggest column is destroyed
          
            set store  $numrow
            set numrow  $actrow(1)
           
            #recalculate numrow = max actrow(x)
            for {set i 2} {$i <= $numcol} {incr i 1} {
                if {$actrow($i) >= $numrow} {
                   set numrow $actrow($i)
                }
             }
            set number [expr $store - $numrow]
            #delete the unused row
            $tableName delete row -keeptitles -- [expr $numrow+1] $number

             #create all the flat cells for the cols that have been moved
 
            for {set i $numcol} {$i >= $h} {incr i -1} {
                for {set b [expr $actrow($i)+1]} {$b <= $numrow} {incr b 1} {
                   set z [expr $i*3 -3]
                   catch {label  $tableName.dum$b{-}$z}
                   $tableName window configure $b,$z\
                              -window $tableName.dum$b{-}$z\
                              -sticky news
                   $tableName tag cell disab $b,$z
                   catch {label  $tableName.dum$b{-}[expr $z+1]}
                   $tableName window configure $b,[expr $z+1]\
                              -window $tableName.dum$b{-}[expr $z+1]\
                              -sticky news
                   $tableName tag cell disab $b,[expr $z+1]
                } 
                for {set b 1} {$b <= $numrow} {incr b 1} {
                   set z [expr $i*3 -3]
                   catch {label  $tableName.dum$b{-}[expr $z+2]}
                   $tableName window configure $b,[expr $z+2]\
                              -window $tableName.dum$b{-}[expr $z+2]\
                              -sticky news 
                   $tableName tag cell disab $b,[expr $z+2]   
               }                
           }            

        } else {
           tk_messageBox -icon warning \
               -message [msgcat::mc "Cannot remove any more columns"] \
               -parent $parent6
        }
        
   }
   #DELETE A ROW IN THE TABLE#

   proc delrow {curRow} {
        
        variable parent6
        variable tableName
        variable labelin
        variable numrow
        variable numcol
        variable realcol
        variable actrow

        variable treeChildsite
        variable tbdata

        #Procedure: 1-make the 2 last cells flat and move the data
        #           2-if the last row is unused, delete it

        if {[catch {$tableName index active col} curColumn]} {
           set curColumn 1
        }
        set h [expr int($curColumn/3 +1)]
       
        if {$actrow($h) > 1} {
            
         
           #if {[catch {$tableName index active row} curRow]} {
           #   set curRow 1
           #}
              

           #set curColumn = 3N+1
           for {set i 1} {$i <= $numcol} {incr i 1} {
                set toto [expr ($i-1) * 3]
                set tata [expr (($i -1) * 3)+2]
                if {$curColumn == $toto} {
                   set curColumn [expr $curColumn +1]
                }  elseif {$curColumn == $tata} {
                   set curColumn [expr $curColumn - 1]
                }               
           }
           
           #make the 2 last cells flat
          
           label $tableName.dum$actrow($h){-}[expr $curColumn -1]
           $tableName window configure $actrow($h),[expr $curColumn -1]\
                              -window $tableName.dum$actrow($h){-}[expr $curColumn -1]\
                              -sticky news
           $tableName tag cell disab $actrow($h),[expr $curColumn -1]
           label $tableName.dum$actrow($h){-}$curColumn
           $tableName window configure $actrow($h),$curColumn\
                              -window $tableName.dum$actrow($h){-}$curColumn\
                              -sticky news
           $tableName tag cell disab $actrow($h),$curColumn

           #move the data if necessary
           for {set i $curRow} {$i < $actrow($h)} {incr i 1} {
               if {[catch {set tbdata($i,$curColumn) \
                            $tbdata([expr $i+1],$curColumn)}]} {
                   set  tbdata($i,$curColumn) ""
               }
               if {[catch {set tbdata($i,[expr $curColumn -1]) \
                            $tbdata([expr $i+1],[expr $curColumn -1])}]} {
                   set tbdata($i,[expr $curColumn -1]) ""
               }
           }
           set tbdata($actrow($h),$curColumn) ""
           set tbdata($actrow($h),[expr $curColumn -1]) ""

           #update the number of active rows for this column
           set actrow($h) [expr $actrow($h) -1]

           #if all the cells are flat in the last row , delete it !
           
           set flag 0
           for {set i 1} {$i <= $numcol} {incr i 1} {
              if {$actrow($i) == $numrow} {
                  set flag 888
              }
           }
           if {$flag != 888} {          
                $tableName delete row -keeptitles -- $numrow 1
                set numrow [expr $numrow -1]
           }

        } else {
            tk_messageBox -icon warning \
               -message [msgcat::mc "Cannot remove any more rows"] \
               -parent $parent6
        }                        
   }

    proc graph { graBH } {

      variable ::euidl::material::ModelControl::matModelArr

      variable labelin
      variable grpher

      set grpher 0

      # Lower the windows so that the graph isn't obscurred in 3D
      lower $matModelArr(parent)
      update

      #set a dummy mat ID

      set matgr [ans_evalexpr mpinqr(0,0,14)]
      set matgr [expr $matgr +1]

      #call  matOpts_Ok with flag on
      set next 0
      if {$graBH == "Current"} {
         set next "Current"
      }
      matOpts_Ok 777 $matgr $next

      set def [ans_evalexpr mpinqr($matgr,0,1)]
      if {$def == 0} {
          return
      }
      if {$grpher != 999} {
        if {$labelin == "BH"} {
           catch {ans_sendcommand \
              )TBPL,$graBH,$matgr,,,,,,,PREV} 
        } else {
           catch {ans_sendcommand \
              )TBPL,$labelin,$matgr,,,,,,,PREV}                 
        }
      }
      ans_sendcommand )/NOPR
      catch {ans_sendcommand )TBDE,$labelin,$matgr}
      ans_sendcommand )/GO


      after 1000 [list raise $matModelArr(parent)]
   }

   proc matOpts_Ok {flag mat next} {
   
      variable parent6
      variable labelin
      variable numcol
      variable allnumcol
      variable numrow
      variable allnumrow
      variable realcol
      variable actrow
      variable tbdata
      variable maxntb
      for { set ntb 1 } { $ntb <= $maxntb } { incr ntb 1 } {
         variable tbdata$ntb
         variable actrow$ntb
      }
      variable treeChildsite
      variable tableName
      variable grpher
      variable tbopt
      variable numtab
      variable curtab

      # Indicate that a material has changed its values
      variable ::euidl::material::ModelControl::localMatlInfoArr
      if {[info exists localMatlInfoArr]} {
         set localMatlInfoArr(matl,$mat,chng) 1
      }
      
      # set this for partial table deletion
      set tboptcmd "    "

      switch -glob -- $labelin {
         GASK* {
            set tboptcmd $tbopt
         }
      }


      # move table that is currently being editted
      catch { unset actrow$curtab }
      catch { unset tbdata$curtab }
      array set tbdata$curtab [array get tbdata]
      array set actrow$curtab [array get actrow]
      set allnumcol($curtab) $numcol
      set allnumrow($curtab) $numrow
      

     #TB command
     ans_sendcommand )/NOPR

     set tb [ans_getvalue $labelin,$mat,EXIS,,,,$tboptcmd]

     set beginloop 1
     set endloop $numtab

     if { $next == "Current" } {
        set beginloop $curtab
        set endloop $curtab
        set next 0
     }

     for {set icurve $beginloop} {$icurve<[expr $endloop +1]} {incr icurve 1} {

      catch { unset tempData }
      catch { unset tempSort }
      catch { unset tempData2}
      catch { unset tl}
      catch { unset tbdata}
      catch { unset actrow}


      array set tbdata [array get tbdata$icurve]
      array set actrow [array get actrow$icurve]
      set numcol $allnumcol($icurve)
      set numrow $allnumrow($icurve)

      #Reorder TEMPERATURE - Create a list 
      for {set i 1} {$i<[expr $numcol*3 +1]} {incr i 3} {

         if { [info exists tbdata(-1,$i)] } {
            if {  $tbdata(-1,$i) == "" } {
                   set tbdata(-1,$i) 0
            }
         } else {
            set tbdata(-1,$i) 0
         }

         if {[catch {lappend tempData $tbdata(-1,$i)}]} {
              set tbdata(-1,$i) 0
              lappend tempData $tbdata(-1,$i)
         }
      }
     

      # Sort the temperatures into a list
      if {[catch {set tempSort [lsort -real -unique $tempData]}]} {
         catch {unset tempData2}
         foreach junktemp $tempData {
            regsub -all { } $junktemp {} junktemp
            if {[catch {ans_evalexpr $junktemp}]} {
               #set junktemp 0
                return
            } else {
               set junktemp [ans_evalexpr $junktemp]
            }
            lappend tempData2 $junktemp
         }
         set tempData $tempData2
         set tempSort [lsort -real -unique $tempData]
      }

      if {[llength $tempData] != [llength $tempSort]} {
         set tl {}
         set tempSort [lsort -real $tempData]
         set tl [lindex $tempSort 0]
         for {set i 1} {$i < [llength $tempSort]} {incr i} {
            if {[lindex $tempSort $i] == $tl} {    
               tk_messageBox -icon error \
                     -message [::msgcat::mc "There are multiple temperatures \
                        with value of $tl in Curve $icurve"] \
                     -parent $parent6
               break
            }
            set tl [lindex $tempSort $i]
         }
         return
      }


      # We have a valid sorted temperature list tempSort
      if { $tb == 1  && $icurve == 1 } {
         catch {ans_sendcommand TBDE,$labelin,$mat,,,$tboptcmd}
      }
      

      if {$flag != 777} {
          ans_sendcommand )/GO 
          if {[catch {ans_sendcommand \
                        TB,$labelin,$mat,$numcol,$numrow,$tbopt}]} {
#                        catch {ans_sendcommand TBDE,$labelin,$mat}
                        return
          }     
          
      } else {
          if {[catch {ans_sendcommand \
                        )TB,$labelin,$mat,$numcol,$numrow,$tbopt}]} {
                       set grpher 999 
                       return
          }
      }

      #TBTEMP-TBPT Command -Loop through the table

      foreach temp $tempSort {
         set i [lsearch $tempData $temp]
         if {$flag != 777} {
             catch {ans_sendcommand TBTEMP,$temp}
         } else {
             catch {ans_sendcommand )TBTEMP,$temp}
         }

         for {set j 1} {$j <= $actrow([expr $i+1])} {incr j 1} { 
               
               #if {[catch {ans_evalexpr $tbdata($j,[expr $i *3])}]} {
               #   set tbdata($j,[expr $i *3]) ""
               #}
               if {[catch {set c(1) $tbdata($j,[expr $i *3])}]} {
                  set c(1) ""
               }
               regsub -all { } $c(1) {} c(1) 
               #if {[catch {ans_evalexpr $tbdata($j,[expr $i *3 + 1])}]} {
               #   set tbdata($j,[expr $i *3 +1]) ""
               #}
               if {[catch {set c(2) $tbdata($j,[expr $i *3 +1])}]} {
                  set c(2) ""
               }
               regsub -all { } $c(2) {} c(2)
               if {$flag != 777} {
                  if {[catch {ans_sendcommand TBPT,,$c(1),$c(2)}]} {
                     ans_sendcommand )/NOPR
                     catch {ans_sendcommand TBDE,$labelin,$mat,,,$tboptcmd}
                     ans_sendcommand )/GO
                     return
                  }
               } else {
                  if {[catch {ans_sendcommand )TBPT,,$c(1),$c(2)}]} {
                     set grpher 999
                     ans_sendcommand )/GO
                     return
                  }
               }
         }
      }

   }
   # end of big do loop for each curve
      ans_sendcommand )/GO

   if {$flag != 777} {
     # Unset the variables to make sure the table table is clean
     # on reentry.

     catch { unset numcol }
     catch { unset realcol }
     catch { unset actrow }
     catch { unset numrow }
     catch {  unset tbdata }
     for {set i 1} {$i < 11} { incr i 1} {
        catch { unset tbdata$i }
        catch { unset actrow$i }
     }

     catch { destroy $parent6 }
     if {$next != 999} {
        #call next table and don't restart for combined models
        if {$next != 0} {
           euidl::material::ModelControl::table_choice $next $mat 0
        } else {
           euidl::material::ModelControl::matTable_State 1     
        }
     }

     catch { unset parent6 }
   }

   catch { unset actrow}
   catch { unset tbdata}
   array set tbdata [array get tbdata$curtab]
   array set actrow [array get actrow$curtab]
   set numcol $allnumcol($curtab)
   set numrow $allnumrow($curtab)
  }

 #end of ok proc

   proc matOpts_Cancel {} {
      variable parent6
      variable numcol
      variable allnumcol
      variable numrow
      variable allnumrow
      variable actrow
      variable realcol
      variable tbdata
      variable maxntb
      for { set ntb 1 } { $ntb <= $maxntb } { incr ntb 1 } {
         variable tbdata$ntb
         variable actrow$ntb
      }

      for {set i 1} {$i < 11} { incr i 1} {
         catch { unset tbdata$i }
         catch { unset actrow$i }
      }
      unset tbdata

      unset numcol
      unset numrow
      unset allnumcol
      unset allnumrow
      unset realcol
      unset actrow
      catch { destroy $parent6 }
      unset parent6

      euidl::material::ModelControl::matTable_State 1
   }

}

   #############################################################
   #
   #  FAVORITES
   #
   #############################################################

namespace eval ::euidl::material::favorites {

     proc create {} {

        variable favoritesList
        variable numFavorites

        if {![info exists numFavorites]} {
           set numFavorites 0
        }

        set numFavorites [expr $numFavorites + 1]

        if {![info exists favoritesList]} {
           set favoritesList(root) [ list ]
        }

        lappend favoritesList(root) {fav$numFavorites "sdfasdf"}

     }

##########################################################
# According to 4 character labels, create favorite list
#
##########################################################
     proc create2 {descriptiveLabel charList} {

        variable favoritesList
        variable numFavorites

        set errflag 0

        if {![info exists numFavorites]} {
           set numFavorites 0
        }

        set descriptiveLabel [string trim $descriptiveLabel]

        # error check for reserved characters
        set labLen [string length $descriptiveLabel]
        for {set i 0} {$i < $labLen} {incr i} {
           set thisChar [string index $descriptiveLabel $i]
           # this cryptic scan statement looks for brackets and braces
           set numfound [ scan $thisChar {%[]{}[]} ]
           if {$numfound != "{}"} {
              ans_senderror 3 "A Favorite name cannot contain special character [string index $numfound 1].  Please use a new name."
              set errflag 1
              return $errflag
           }
        }

        # error check for duplicate favorite name
        if {[string match $descriptiveLabel "Linear Static"]} {
           ans_senderror 3 "A Favorite named $descriptiveLabel already exists.  Please use a new name."
           set errflag 1
           return $errflag
        }

        for {set i 0} {$i < $numFavorites} {incr i} {
           set j [expr $i + 1]
           if {[string match $descriptiveLabel $favoritesList($j,label)]} {
              ans_senderror 3 "A Favorite named $descriptiveLabel already exists.  Please use a new name."
              set errflag 1
              return $errflag
           }
        }

        set thisList [split $charList _]

        if {[llength $thisList] < 1} {
           ans_senderror 3 "A Favorite cannot be created for this material.  No properties are defined."
           set errflag 1
           return $errflag

        } else {
           set numFavorites [expr $numFavorites + 1]
           set favoritesList($numFavorites,label) $descriptiveLabel

           for {set i 0} {$i < [llength $thisList]} {incr i} {

              set thisDBLabel [lindex $thisList $i]

              set lsdyna [ans_getvalue active,,keyw,,lsdyna]

              if {$lsdyna == 0} {
                 set thisLabel [getFancyLabel $thisDBLabel]
              } else {
                 set thisLabel [getDynaFancyLabel $thisDBLabel]
              }

              if {![string match $thisLabel ""]} {
                 lappend favoritesList($numFavorites) $thisDBLabel "$thisLabel"
              }
           }
        }

        return $errflag
     }

     proc delete {descriptiveLabel} {

        variable favoritesList
        variable numFavorites

        # This procedure delete a Favorite by the user defined label

        if {![info exists numFavorites]} {
           set numFavorites 0
        }

        set thisNumFavorites 0
        set thisFavList [ list ]

        for {set i 0} {$i < $numFavorites} {incr i} {

           set j [expr $i + 1]

           if {![string match $descriptiveLabel $favoritesList($j,label)]} {
              set thisNumFavorites [expr $thisNumFavorites + 1]

              set favoritesList($thisNumFavorites,label) $favoritesList($j,label) 
              set favoritesList($thisNumFavorites) $favoritesList($j)

           }
        }

        # Unset the extras at the end
        for {set i $thisNumFavorites} {$i < $numFavorites} {incr i} {
           set j [expr $i + 1]
           unset favoritesList($j,label)
           unset favoritesList($j)
        }
        set numFavorites $thisNumFavorites
     }

     proc save {} {

        global ansysRevDot
        # may have to re-initialize and save new, like the delete proc

        # this procedure saves the favorites to the global set

        variable favoritesList
        variable numFavorites

        # Each favorite content
        # if defined before delete the list from registry file
        if {![catch {ansys::registry keys \
            "HKEY_CURRENT_USER\\Software\\ANSYS, Inc.\\ANSYS\\ANSYS $ansysRevDot\\GUI\\Material\\Favorites"} err]} {
           ansys::registry delete \
           "HKEY_CURRENT_USER\\Software\\ANSYS, Inc.\\ANSYS\\ANSYS $ansysRevDot\\GUI\\Material\\Favorites"
        }
        set i 1
        for {set i 1} {$i <= $numFavorites} {incr i 1} {

            set favlist [ list ]
            foreach {stuff tag} $favoritesList($i) {
               append favlist "_" $stuff
            }
            ansys::registry set \
            "HKEY_CURRENT_USER\\Software\\ANSYS, Inc.\\ANSYS\\ANSYS $ansysRevDot\\GUI\\Material\\Favorites" \
            $i "{$favoritesList($i,label)} $favlist"
            unset favoritesList($i,label)
            unset favoritesList($i)
        }
        set numFavorites 0
     }

     proc savedyna {} {

        global ansysRevDot
        # may have to re-initialize and save new, like the delete proc

        # this procedure saves the favorites to the global set

        variable favoritesList
        variable numFavorites

        # Each favorite content
        # if defined before delete the list from registry file
        if {![catch {ansys::registry keys \
            "HKEY_CURRENT_USER\\Software\\ANSYS, Inc.\\ANSYS\\ANSYS $ansysRevDot\\GUI\\DynaMaterial\\Favorites"} err]} {
           ansys::registry delete \
           "HKEY_CURRENT_USER\\Software\\ANSYS, Inc.\\ANSYS\\ANSYS $ansysRevDot\\GUI\\DynaMaterial\\Favorites"
        }
        set i 1
        for {set i 1} {$i <= $numFavorites} {incr i 1} {

            set favlist [ list ]
            foreach {stuff tag} $favoritesList($i) {
               append favlist "_" $stuff
            }
            ansys::registry set \
            "HKEY_CURRENT_USER\\Software\\ANSYS, Inc.\\ANSYS\\ANSYS $ansysRevDot\\GUI\\DynaMaterial\\Favorites" \
            $i "{$favoritesList($i,label)} $favlist"
            unset favoritesList($i,label)
            unset favoritesList($i)
        }
        set numFavorites 0
     }

     proc resume {} {

        global ansysRevDot
        # this procedure resumes the favorites from the global set

        variable favoritesList
        variable numFavorites

        set favoritesList(root) [ list ]

        # if defined before set the list from registry file
        if {![catch {ansys::registry keys \
            "HKEY_CURRENT_USER\\Software\\ANSYS, Inc.\\ANSYS\\ANSYS $ansysRevDot\\GUI\\Material\\Favorites"} err]} {

         set favList [ansys::registry values \
            "HKEY_CURRENT_USER\\Software\\ANSYS, Inc.\\ANSYS\\ANSYS $ansysRevDot\\GUI\\Material\\Favorites"]
         foreach favItem $favList {
            set thisFavList "[ ansys::registry get \
               "HKEY_CURRENT_USER\\Software\\ANSYS, Inc.\\ANSYS\\ANSYS $ansysRevDot\\GUI\\Material\\Favorites" \
                $favItem ] "
             foreach {stuff tag} $thisFavList {
                create2 $stuff $tag
             }
          }

        }
     }

    proc resumedyna {} {

        global ansysRevDot
        # this procedure resumes the favorites from the global set

        variable favoritesList
        variable numFavorites

        set favoritesList(root) [ list ]

        # if defined before set the list from registry file
        if {![catch {ansys::registry keys \
            "HKEY_CURRENT_USER\\Software\\ANSYS, Inc.\\ANSYS\\ANSYS $ansysRevDot\\GUI\\DynaMaterial\\Favorites"} err]} {

         set favList [ansys::registry values \
            "HKEY_CURRENT_USER\\Software\\ANSYS, Inc.\\ANSYS\\ANSYS $ansysRevDot\\GUI\\DynaMaterial\\Favorites"]
         foreach favItem $favList {
            set thisFavList "[ ansys::registry get \
               "HKEY_CURRENT_USER\\Software\\ANSYS, Inc.\\ANSYS\\ANSYS $ansysRevDot\\GUI\\DynaMaterial\\Favorites" \
             $favItem ] "
             foreach {stuff tag} $thisFavList {
                create2 $stuff $tag
             }
          }

        }
     }

     proc getNumberOfFavorites {} {

        variable numFavorites

        if {![info exists numFavorites]} {
           set numFavorites 0
        }

        return $numFavorites
     }

     proc getFavoriteLabel {number} {

        variable favoritesList

        return $favoritesList($number,label)

     }

     proc getFavorite {number} {

        variable favoritesList

        return $favoritesList($number)

     }

     proc getFancyLabel { charLabel } {

        set fancyLabel(DENS)       "Density"
        set fancyLabel(MUAC)       "Boundary Admittance"
        set fancyLabel(MU)         "Friction Coefficient"
        set fancyLabel(C)          "Specific Heat"
        set fancyLabel(ENTH)       "Enthalpy"
        set fancyLabel(EMIS)       "Emissivity"
        set fancyLabel(HF)         "Convection or Film Coef."
        set fancyLabel(QRAT)       "Heat Generation Rate"
        set fancyLabel(LSST)       "Loss Tangent"
        set fancyLabel(SONC)       "Sonic Velocity"
        set fancyLabel(VISC)       "Viscosity"
        set fancyLabel(DAMP)       "Damping (Constant)"
        set fancyLabel(ALPD)       "Damping (Mass)"
        set fancyLabel(BETD)       "Damping (Stiffness)"
        set fancyLabel(DMPR)       "Damping (Freq Indep)"
        set fancyLabel(ISOT)       "Linear Isotropic"
        set fancyLabel(ORTH)       "Linear Orthotropic"
        set fancyLabel(ALPI)       "Thermal Expansion (secant-iso)"
        set fancyLabel(ALPO)       "Thermal Expansion (secant-ortho)"
        set fancyLabel(CTEI)       "Thermal Expansion (instant-iso)"
        set fancyLabel(CTEO)       "Thermal Expansion (instant-ortho)"
        set fancyLabel(THSI)       "Thermal Expansion (strain-iso)"
        set fancyLabel(THSO)       "Thermal Expansion (strain-ortho)"
        set fancyLabel(KXX)        "Thermal conduct. (iso)"
        set fancyLabel(KORT)       "Thermal conduct. (ortho)"
        set fancyLabel(DXX)        "Diffusivity (iso)"
        set fancyLabel(DORT)       "Diffusivity (ortho)"
        set fancyLabel(BETI)       "Diffusion Expansion (iso)"
        set fancyLabel(BETO)       "Diffusion Expansion (ortho)"
        set fancyLabel(CSAT)       "Saturated Concentration"
        set fancyLabel(MURX)       "Permeability (constant) "
        set fancyLabel(MURO)       "Permeability (ortho)"
        set fancyLabel(MGXX)       "Coercive force (const)"
        set fancyLabel(MGOR)       "Coercive force (ortho)"
        set fancyLabel(PERX)       "Permittivity (constant)"
        set fancyLabel(PERO)       "Permittivity (ortho)"
        set fancyLabel(DPER)       "Permittivity (aniso)"
        set fancyLabel(RSVX)       "Resistivity (constant)"
        set fancyLabel(RSVO)       "Resistivity (ortho)"
        set fancyLabel(HYPEmo2)    "Mooney-Rivlin (2 parameters)"
        set fancyLabel(HYPEmo3)    "Mooney-Rivlin (3 parameters)"
        set fancyLabel(HYPEmo5)    "Mooney-Rivlin (5 parameters)"
        set fancyLabel(HYPEmo9)    "Mooney-Rivlin (9 parameters)"
        set fancyLabel(HYPEog1)    "Ogden (1 terms)"
        set fancyLabel(HYPEog2)    "Ogden (2 terms)"
        set fancyLabel(HYPEog3)    "Ogden (3 terms)"
        set fancyLabel(HYPEog4)    "Ogden (4 terms)"
        set fancyLabel(HYPEog5)    "Ogden (5 terms)"
        set fancyLabel(HYPEogG)    "Ogden (General)"
        set fancyLabel(CREE)       "Creep: Explicit"
        set fancyLabel(CREE1)      "Creep: Implicit (1:Strain Hard-P)"
        set fancyLabel(CREE2)      "Creep: Implicit (2:Time Hard-P)"
        set fancyLabel(CREE3)      "Creep: Implicit (3:Gen Exp-P)"
        set fancyLabel(CREE4)      "Creep: Implicit (4:Gen Graham-P)"
        set fancyLabel(CREE5)      "Creep: Implicit (5:Gen Blackburn-P)"
        set fancyLabel(CREE6)      "Creep: Implicit (6:Mod Time Hard-P)"
        set fancyLabel(CREE7)      "Creep: Implicit (7:Mod Strain Hard-P)"
        set fancyLabel(CREE8)      "Creep: Implicit (8:Gen Garofalo-S)"
        set fancyLabel(CREE9)      "Creep: Implicit (9:Exp Form-S)"
        set fancyLabel(CREE10)     "Creep: Implicit (10:Norton-S)"
        set fancyLabel(CREE11)     "Creep: Implicit (11:Time Hard-P+S)"
        set fancyLabel(CREE12)     "Creep: Implicit (12:Rational Poly-P+S)"
        set fancyLabel(CREE13)     "Creep: Implicit (13:Gen Time Hard-P)"
        set fancyLabel(CREE100)    "Creep: User Defined"
        set fancyLabel(NLIS)       "Nonlinear Isotropic"
        set fancyLabel(MELA)       "Multilinear Elastic"
        set fancyLabel(CHAB)       "Chaboche"
        set fancyLabel(MISO)       "Multilinear Isotropic"
        set fancyLabel(PLAS1)      "Multilinear Isotropic"
        set fancyLabel(BISO)       "Bilinear Isotropic"
        set fancyLabel(ANEL)       "Anisotropic Elastic"
        set fancyLabel(HILL)       "Hill"
        set fancyLabel(BKIN)       "Bilinear Kinematic"
        set fancyLabel(ANAN)       "Anand"
        set fancyLabel(ANIS)       "Anisotropic"
        set fancyLabel(DP1)        "Drucker-Prager"
        set fancyLabel(DP2)        "Drucker-Prager (Cap)"
        set fancyLabel(MKIN)       "Multilinear Kinematic(Fixed)"
        set fancyLabel(EVIS)       "Maxwell Viscoelastic"
        set fancyLabel(KINH)       "Multilinear Kinematic(General)"
        set fancyLabel(PLAS4)      "Multilinear Kinematic(General)"
        set fancyLabel(MOON)       "Mooney-Rivlin (TB,MOON)"
        set fancyLabel(USER)       "User Constants"
        set fancyLabel(RATE)       "Rate-Dependent"
        set fancyLabel(CONC)       "Concrete"
        set fancyLabel(SWEL)       "Swelling"
        set fancyLabel(FAIL)       "Failure Criteria"
        set fancyLabel(STAT)       "State Variables"
        set fancyLabel(HFLM)       "Film Coefficient"
        set fancyLabel(BH)         "B-H Curve"
        set fancyLabel(FCON)       "Fluid Conductance"
        set fancyLabel(WATE)       "Water Table"
        set fancyLabel(PIEZ)       "Piezoelectric matrix "
        set fancyLabel(PZRS)       "Piezoresistive matrix "
        set fancyLabel(HYPE3)      "Yeoh"
        set fancyLabel(HYPE4)      "Gent"
        set fancyLabel(HYPE5)      "Neo-Hookean"
        set fancyLabel(HYPE8)      "Arruda-Boyce"
        set fancyLabel(HYPE10)     "Blatz-Ko (Foam)"
        set fancyLabel(HYPE11)     "Ogden (Foam)"
        set fancyLabel(HYPE100)    "Hyper-Elas User def."
        set fancyLabel(HYPEpo1)    "Polynomial form (1 term)"
        set fancyLabel(HYPEpo2)    "Polynomial form (2 terms)"
        set fancyLabel(HYPEpo3)    "Polynomial form (3 terms)"
        set fancyLabel(HYPEpo4)    "Polynomial form (4 terms)"
        set fancyLabel(HYPEpo5)    "Polynomial form (5 terms)"
        set fancyLabel(HYPEpoG)    "Polynomial form (General)"
        set fancyLabel(CAST1)      "Cast-Iron: Isotropic Hardening"
        set fancyLabel(CAST2)      "Cast-Iron: Kinematic Hardening"
        set fancyLabel(GASKPARA)   "Gasket: General"
        set fancyLabel(GASKCOMP)   "Gasket: Compression"
        set fancyLabel(GASKLUNL)   "Gasket: Linear Unloading"
        set fancyLabel(GASKNUNL)   "Gasket: Nonlinear Unloading"
        set fancyLabel(GASKTSS)    "Gasket: Transverse Shear"
        set fancyLabel(UNIACOMP)   "Uniaxial: Compression"
        set fancyLabel(UNIATENS)   "Uniaxial: Tension"
        set fancyLabel(PRONYSHEAR) "Prony: Shear Response"
        set fancyLabel(PRONYBULK)  "Prony: Volumetric Response"
        set fancyLabel(SHIFT1)     "Shift Function: WLF"
        set fancyLabel(SHIFT2)     "Shift Function: TN"
        set fancyLabel(SHIFT100)   "Shift Function: USER"
        set fancyLabel(JOINTSTIF)  "Joint: Linear Stiffness"
        set fancyLabel(JOINTDAMP)  "Joint: Linear Damping"
        set fancyLabel(JOINTFRIC)  "Joint: Linear Friction"
        set fancyLabel(JOINTJNSA)  "Joint: Nonlinear Stiffness ALL"
        set fancyLabel(JOINTJNS4)  "Joint: Nonlinear Stiffness ROTX"
        set fancyLabel(JOINTJNS6)  "Joint: Nonlinear Stiffness ROTZ"
        set fancyLabel(JOINTDNSA)  "Joint: Nonlinear Damping ALL"
        set fancyLabel(JOINTDNS4)  "Joint: Nonlinear Damping ROTX"
        set fancyLabel(JOINTDNS6)  "Joint: Nonlinear Damping ROTZ"
        set fancyLabel(JOINTFNSA)  "Joint: Nonlinear Friction ALL"
        set fancyLabel(JOINTFNS4)  "Joint: Nonlinear Friction ROTX"
        set fancyLabel(JOINTFNS6)  "Joint: Nonlinear Friction ROTZ"
        set fancyLabel(SBKX)       "Seebeck Coefficients (constant) "
        set fancyLabel(SBKO)       "Seebeck Coefficients (ortho)"
        set fancyLabel(SDAM)       "Damping (Freq Dependent)"
        set fancyLabel(ELAS2)      "Freq-Dependent Elasticity (iso)"
        set fancyLabel(ELAS9)      "Freq-Dependent Elasticity (ortho)"
        set fancyLabel(ELAS21)     "Freq-Dependent Elasticity (aniso)"

        if { [catch {set returnLabel $fancyLabel($charLabel)} ] } {
           set returnLabel $charLabel
        }

        return $returnLabel
   }


     proc getDynaFancyLabel { charLabel } {

        # same labels as getDYNAstuff

        set fancyLabel(CABLdyn)    "Cable"
        set fancyLabel(RIGIdyn)    "Rigid"
        set fancyLabel(FLUIdyn)    "Fluid"
        set fancyLabel(ANELdyn)    "Anisotropic Elastic"
        set fancyLabel(MOONdyn)    "Mooney Rivlin"
        set fancyLabel(MOON1dyn)   "Mooney Rivlin"
        set fancyLabel(EVISC)      "Viscoelastic"
        set fancyLabel(BISOtmp)    "Temp Dependent BISO"
        set fancyLabel(BISOdyn)    "Bilinear Isotropic"
        set fancyLabel(ANISdyn)    "Transverse Anisotropic"
        set fancyLabel(ANISfld)    "Transverse Aniso FLD"
        set fancyLabel(KINEdyn)    "Plastic Kinematic"
        set fancyLabel(BAR3dyn)    "Barlat 3 Parm Anisotropic"
        set fancyLabel(BARLdyn)    "Barlat Anisotropic"
        set fancyLabel(SENSdyn)    "Rate Sensitive"
        set fancyLabel(DEPdyn)     "Rate Dependent"
        set fancyLabel(PLAWdyn)    "Power Law"
        set fancyLabel(LINRdyn)    "Standard Piecewise Linr"
        set fancyLabel(HYDRdyn)    "Hydrodynamic"
        set fancyLabel(LINR1dyn)   "Modified Piecewise Linr"
        set fancyLabel(THERMdyn)   "Elastic Visco Thermal"
        set fancyLabel(BKINdyn)    "Bilinear Kinematic"
        set fancyLabel(COMPdyn)    "Composite Damage"
        set fancyLabel(CONCdyn)    "Concrete Damage"
        set fancyLabel(GEOdyn)     "Geological Cap"
        set fancyLabel(CELLdyn)    "Closed Cell"
        set fancyLabel(VISCdyn)    "Viscous"
        set fancyLabel(DENSdyn)    "Low Density"
        set fancyLabel(CRSHdyn)    "Crushable"
        set fancyLabel(HONEdyn)    "Honeycomb"
        set fancyLabel(JOHN1dyn)   "Johnson-Cook Linear Poly."
        set fancyLabel(JOHN2dyn)   "Johnson-Cook Gruneisem"
        set fancyLabel(JOHN3dyn)   "Johnson-Cook Tabulated"
        set fancyLabel(NULL1dyn)   "Null Linear Poly."
        set fancyLabel(NULL2dyn)   "Null Gruneisem"
        set fancyLabel(NULL3dyn)   "Null Tabulated"
        set fancyLabel(ZERI1dyn)   "Zerilli-Armstrong Linear Poly."
        set fancyLabel(ZERI2dyn)   "Zerilli-Armstrong Gruneisem"
        set fancyLabel(ZERI3dyn)   "Zerilli-Armstrong Tabulated"
        set fancyLabel(STEN1dyn)   "Steinberg Linear Poly."
        set fancyLabel(STEN2dyn)   "Steinberg Gruneisem"
        set fancyLabel(STEN3dyn)   "Steinberg Tabulated"
        set fancyLabel(BAMMdyn)    "Bamman"
        set fancyLabel(SPNGdyn)    "Lin Elas Spring"
        set fancyLabel(NLSPdyn)    "General NL Spring"
        set fancyLabel(ELSPdyn)    "Elastoplast Spring"
        set fancyLabel(NLESdyn)    "NL Elastic  Spring"
        set fancyLabel(MAXSdyn)    "Maxwell Visc Sprng"
        set fancyLabel(INSPdyn)    "Inelastic Spring"
        set fancyLabel(LNVIdyn)    "Linear Viscosity"
        set fancyLabel(NLVIdyn)    "Nonlinear Visco"
        set fancyLabel(BLAT)       "Blatz-KO Rubber"
        set fancyLabel(ISOTdyn)    "Linear Isotropic"
        set fancyLabel(ORTHdyn)    "Linear Orthotropic"

        if { [catch {set returnLabel $fancyLabel($charLabel)} ] } {
           set returnLabel $charLabel
        }

        return $returnLabel
   }
}

# ============================================================================
# File Name:     table7.eui
# Description:   TB Dialog box for the following labels
#                SDAM, ELAS
#                All these tables are temperature dependent
#                Some of them (CHAB,USER,STAT) can also have a non-fixed number
#                 of rows (dim =2)
# ============================================================================

namespace eval ::euidl::material::mat7 {
   
   proc TABLE7 {label matid next} {

      variable ::euidl::material::ModelControl::matModelArr

      variable numcol
      variable numrow
      variable tbdata
      variable labelin
      variable tbopt
      variable npts
      variable colmax
      variable rowmax

      # colmax need a default
      set colmax 1000
      set rowmax 1000 
 
      set labelin $label

      set tboptcmd "    "
     
      variable parent7
      variable childsite
      variable tableName
      variable mat
      variable treeChildsite
      variable dim
      variable confirm
 
      set mat $matid
      set tbopt " "

      euidl::material::ModelControl::matTable_State 0

      if [winfo exists .dlgMatOpts] {
         # Set the display correctly
         $parent7 activate
         return
      }

      set parent7 [euidl::dialog .dlgMatOpts -class EUIDL \
            -master $matModelArr(parent) \
            ]

      set childsite [$parent7 component childsite]

      #SET WINDOW#

      wm minsize $parent7 650 350
    
  

      set tableName [euidl::table $childsite.tbl1 \
            -variable [scope tbdata] \
            -rowseparator \n \
            -colseparator \t \
            -validate focusout \
            -validatedata ansreal \
            
         ]

       # BUTTONS ADD & DELETE & GRAPH# 
   
      
      euidl::button $childsite.addaftc -text [msgcat::mc "Add Field"] \
            -command [code addcolumn ] 
      grid $childsite.addaftc -column 0 -row 3

      bind $childsite.addaftc <ButtonRelease-1> \
                  [code ::euidl::material::error::check %W]


      euidl::button $childsite.delcolumn -text [msgcat::mc "Delete Field"] \
            -command [code colselect ]
      grid $childsite.delcolumn -column 1 -row 3

      bind $childsite.delcolumn <ButtonRelease-1> \
                  [code ::euidl::material::error::check %W]

      euidl::button $childsite.addaftr -text [msgcat::mc "Add Row"] \
            -command [code addrow ]
      grid $childsite.addaftr -column 3 -row 3

      bind $childsite.addaftr <ButtonRelease-1> \
                  [code ::euidl::material::error::check %W]

      euidl::button $childsite.delrow -text [msgcat::mc "Delete Row"] \
            -command [code rowselect ]
      grid $childsite.delrow -column 4 -row 3

      bind $childsite.delrow <ButtonRelease-1> \
                  [code ::euidl::material::error::check %W]

      euidl::button $childsite.graph -text [msgcat::mc "Graph"] \
            -command [code graph]
      grid $childsite.graph -sticky e -column 6 -row 3

      bind $childsite.graph <ButtonRelease-1> \
                  [code ::euidl::material::error::check %W]

      grid columnconfigure $childsite 2 -minsize 50
      grid columnconfigure $childsite 5 -minsize 50
      grid columnconfigure $childsite 6 -weight 1

      $parent7 configure \
            -okcommand [code matOpts_Ok 0 $mat $next] \
            -cancelcommand [code matOpts_Cancel] \
            -helpcommand [list ans_loadhelp Hlp_UI_mat_dat]
      

      #COMMAND DESCRIPTION-HAVE TO CHANGE THE MESSAGE DEPENDING ON THE LABEL
      #1-set initial number of cols and rows as well as 
      #  colmax & rowmax depending on the label 
      #2-set dim =1 or 2 (dim = 1 : You can only add temperatures)
      #  (dim =2 : You can add temps & rows)
      #4- for ELASP the label passed in is CREE$npts

      switch -glob -- $labelin {
         SDAM {
             euidl::label $childsite.lbl$labelin -height 3 \
                  -anchor w \
                  -text [msgcat::mc "Frequency-Dependent Damping \
                        for Material Number $mat"]
             wm title $parent7 [msgcat::mc "Frequency-Dependent Damping\
                  for Material Number $mat"]
             set numcol 1
             set numrow 1
             set dim 1
             set tbdata(1,-1) "Coeff"
             wm minsize $parent7 650 270

             $tableName config -colmax 99
             set colmax 99
             $childsite.addaftr configure -state disabled     
             $childsite.delrow configure  -state disabled
             $childsite.graph configure -state disabled
             $parent7 configure  -helpcommand [list ans_loadhelp Hlp_E_CH2sdam]
         }
         ELAS* {
            #Depending on the value of NPTS, the ELAS table is different
            foreach num {2 9 21} {
                if {$labelin == "ELAS$num"} {
                     set npts $num
                     break
                }
            }                    
            set labelin ELAS
            switch -exact -- $npts {
                     2 {set numrow 2
                        set tbdata(1,-1) "EX"
                        set tbdata(2,-1) "NUXY"
                        set text "Isotropic"}
                     9 {set numrow 9
                        set tbdata(1,-1) "EX"
                        set tbdata(2,-1) "EY"
                        set tbdata(3,-1) "EZ"
                        set tbdata(4,-1) "GXY"
                        set tbdata(5,-1) "GYZ"
                        set tbdata(6,-1) "GXZ"
                        set tbdata(7,-1) "NUXY"
                        set tbdata(8,-1) "NUYZ"
                        set tbdata(9,-1) "NUXZ"
                        set text "Orthotropic"}
                     21 {set numrow 21
                        set tbdata(1,-1) "D11"
                        set tbdata(2,-1) "D21"
                        set tbdata(3,-1) "D31"
                        set tbdata(4,-1) "D41"
                        set tbdata(5,-1) "D51"
                        set tbdata(6,-1) "D61"
                        set tbdata(7,-1) "D22"
                        set tbdata(8,-1) "D32"
                        set tbdata(9,-1) "D42"
                        set tbdata(10,-1) "D52"
                        set tbdata(11,-1) "D62"
                        set tbdata(12,-1) "D33"
                        set tbdata(13,-1) "D43"
                        set tbdata(14,-1) "D53"
                        set tbdata(15,-1) "D63"
                        set tbdata(16,-1) "D44"
                        set tbdata(17,-1) "D54"
                        set tbdata(18,-1) "D64"
                        set tbdata(19,-1) "D55"
                        set tbdata(20,-1) "D65"
                        set tbdata(21,-1) "D66"
                        set text "Anisotropic"}                           
            }
            euidl::label $childsite.lbl$labelin -height 3 \
                 -anchor w\
                 -text [msgcat::mc "Frequency-Dependent Elasticity\
                                    Table for Material Number $mat - $text"]
            wm title $parent7 [msgcat::mc "Frequency-Dependent Elasticity Table"]
            set numcol 1
            set dim 1
            $tableName config -rowmax [expr $numrow +1]

            $childsite.addaftr configure -state disabled     
            $childsite.delrow configure  -state disabled
            $childsite.graph configure -state disabled
            $parent7 configure  -helpcommand [list ans_loadhelp Hlp_E_CH2elas]
         }
      }

      grid $childsite.lbl$labelin -sticky new -column 0 -row 0 \
            -columnspan 7

     # FILL THE TABLE WITH EXISTING DATA IF TABLE EXISTS
      
      set tb 0
      set tb [ans_getvalue $labelin,$mat,EXIS,,,,$tboptcmd]
      if {$tb == 1} {

          #HYPER CASE - CHECK TBOPT#
          if {$labelin == "ELAS" } {
             set tbchk  [ans_getvalue $labelin,$mat,NCON]           
             if {$tbchk == $npts} { 
                   filltable 
             } else {
                 initable
                 warning elas
             }
          } else {
             filltable
          } 

      #if table does not exist, set the default
      } else {         
          initable 
      }

      grid $tableName -sticky news -column 0 -row 2 -columnspan 8
      grid rowconfigure $childsite 2 -weight 1

      # Set the max view height for the table
      grid rowconfigure $childsite 2 -minsize 50

      update idletasks
      wm minsize $parent7 [winfo reqwidth $parent7] \
                          [expr [winfo reqheight $parent7] + 50]
     
      grid propagate $childsite 0
      
      
      #$parent7 activate
    
      set treeChildsite $childsite
      
      $tableName selection set 1,0
      $tableName activate 1,0
      $tableName selection anchor 1,0
      $tableName see active
  
      if [winfo exists .conf] {
         $confirm activate
         raise $confirm
      } else {
        $parent7 activate
      }
   }

   proc warning {which} {
      variable ::euidl::material::ModelControl::matModelArr
 
   
      variable confirm

       
      if {$which == "elas"} {
          set text "A Frequency-Dependent Elasticity model has already \n
                    been defined for this material model number.       \n\
                    Do you want to overwrite it?"
      } 

      set confirm [::euidl::dialog .conf -class EUIDL \
             -master $matModelArr(parent) \
             -okbutton 0 -helpbutton 0 -cancelbutton 0 ]

     
      set childsi [$confirm component childsite]
      wm title $confirm [msgcat::mc "Warning"]
  
      euidl::label $childsi.lbl -text [msgcat::mc $text] 
      grid $childsi.lbl -row 0 -column 0 -columnspan 2
      euidl::button $childsi.yes -height 1 -text [msgcat::mc "Yes"] \
                       -command [code updatechoice 1]
      grid $childsi.yes -row 1 -column 0 
      euidl::button $childsi.no -height 1 -text [msgcat::mc "No"] \
            -command [code updatechoice 0]
      grid $childsi.no -row 1 -column 1
     
    
      update idletasks
    
   }

   proc updatechoice {val} {
      
       variable confirm
       variable parent7
       
       
       if {$val == 1} {
           destroy $confirm
           $parent7 activate
       } elseif { $val == 0 } {
           destroy $confirm
           destroy $parent7
           euidl::material::ModelControl::matTable_State 1
       }
       
   }
      
   proc initable {} {

       variable tbdata
       variable tableName
       variable numcol
       variable numrow

       set tbdata(-1,0) T1
       set tbdata(0,-1) Temperature
       $tableName configure -rows [expr $numrow +2] -cols  [expr $numcol +1]
       $tableName tag cell disabledtitle 0,-1
       $tableName tag cell disabled 0,0
   }

   proc filltable {} {

          variable labelin
          variable mat
          variable tbdata
          variable tableName
          variable numcol
          variable numrow
          variable npts
          variable tboptcmd
          variable dim

          set nptscmd "    "
          set tboptcmd "    "
          switch -glob -- $labelin {
             ELAS* {
                 set nptscmd $npts
             }
             SDAM* {
                 set nptscmd 1
             }
          }

          set tbdata(0,-2) Frequency
          set tbdata(0,-1) Temperature
          set numcol [expr int([ans_getvalue $labelin,$mat,NPTS,,,,$tboptcmd])]
          # Get the values of each temperature TVAL
          for {set i 1} {$i<=$numcol} {incr i 1} {
             set tbdata(-2,[expr $i - 1]) "T$i"
             set tbdata(-1,[expr $i - 1]) [ans_getvalue $labelin,$mat,TVAL,$i,,,$tboptcmd]
             set tbdata(0,[expr $i - 1]) [ans_getvalue $labelin,$mat,FVAL,$i,,,$tboptcmd]
          }

          #If more than one temp, check if some temp are identical 
          #That's what would happen if for example tb,bkin is issued
#          if {$numcol >1} {
#              #Create a list
#              for {set i 0} {$i<$numcol} {incr i 1} {
#                  lappend Templis $tbdata(0,$i)
#              }
#              set Tempsort [lsort -real -unique $Templis]
#              set length [llength $Tempsort]
#              if {$length < $numcol} {
#                  set numcol $length
#              }
#          }

          # Get the value of NPTS if necessary
          set npts 1
          if {$labelin == "ELAS"} {
              set npts  [ans_getvalue $labelin,$mat,NCON]
          }
          set numrow $npts

          # Loop through data for each temperature
          for {set i 1} {$i<=$numcol} {incr i 1} {
              for {set j 1} {$j<=$numrow} {incr j 1} {
                 catch {set tbdata($j,[expr $i - 1]) \
                     [ans_getvalue $labelin,$mat,TEMP,$tbdata(0,[expr $i - 1]),CONST,$j,$tboptcmd] }
                     catch {set tbdata($j,[expr $i - 1]) \
                         [format "%-12.5G" $tbdata($j,[expr $i - 1])] }
                     catch {set tbdata($j,[expr $i - 1]) [string trimright $tbdata($j,[expr $i - 1])] }
              }
          }
          # now format temperature data
          for {set i 1} {$i<=$numcol} {incr i 1} {
             set tbdata(0,[expr $i - 1]) [format "%-12.5G" $tbdata(0,[expr $i - 1])]
             set tbdata(0,[expr $i - 1]) [string trimright $tbdata(0,[expr $i - 1])]
          }

          # Configure the tktable and disable temp cells if only one defined
          $tableName configure -rows [expr int($numrow) + 2] -cols [expr int($numcol) + 1]
          if {$numcol > 1} {
            $tableName tag cell normaltitle 0,-2
            $tableName tag cell normaltitle 0,-1
            $tableName tag cell normal 0,0
          } else {
            $tableName tag cell disabledtitle 0,-2
            $tableName tag cell disabledtitle 0,-1
            $tableName tag cell disabled 0,0
          }
   }

   #ADD A COLUMN TO THE TABLE# 
   proc addcolumn {} {
        
        variable parent7
        variable tableName
        variable tbdata
        variable labelin
        variable numrow
        variable numcol
        variable tbopt
        variable npts
        variable treeChildsite
        variable colmax
        
        if {$numcol >= $colmax} {
             tk_messageBox -icon warning \
                  -title [msgcat::mc "Maximum Number of columns"] \
                  -parent $parent7 \
                  -type ok \
                  -message [msgcat::mc " This table\
                        allows only $colmax temperatures."]
        } else {
        incr numcol

        $tableName tag cell normaltitle 0,-1
        $tableName tag cell normal 0,0

        
        # Insert a column after the currently selected one
        if {[catch {$tableName index active col} curColumn]} {
           set curColumn 0
        }
        $tableName insert col -keeptitles -- $curColumn 1

        # Move the view to see added column
        $tableName xview scroll 1 unit

        # Label this new column
        set tbdata(-1,[expr $numcol - 1]) "T$numcol"

        update
        $tableName selection activate 1,[expr $curColumn +1]
        $tableName see active
        }
   }

  
   #ADD A ROW IN THE TABLE#
     
   proc addrow {} {
        
        variable parent7
        variable tableName
        variable tbdata
        variable labelin
        variable numrow
        variable numcol
        variable tbopt
        variable npts
        variable treeChildsite
        variable rowmax

        if {$numrow >= $rowmax} {
             tk_messageBox -icon warning \
                  -title [msgcat::mc "Maximum Number of rows"] \
                  -parent $parent7 \
                  -type ok \
                  -message [msgcat::mc " This table\
                        allows only $rowmax rows."]
        }
        incr numrow

         # Insert a row after the currently selected one
         if {[catch {$tableName index active row} curRow]} {
            set curRow 1
         }
         $tableName insert row -keeptitles -- $curRow 1

         # Move the view to see added row
         $tableName yview scroll 1 unit

         # Label this new row
         set tbdata($numrow,-1) "C$numrow"

         update
         $tableName selection activate [expr $curRow +1],0
         $tableName see active
   }

    #Returns the rows and columns selected#
    #default to the last one created#

    proc rowselect {} {

        variable tableName

        #create a list of sorted selected cells format {0,0 0,1 ....}
        set listcell [$tableName curselection]
        set length [llength $listcell]

        #get the first cell and the last cell selected
        set first [lindex  $listcell 0]
        set lastind [expr $length -1]
        set last [lindex  $listcell $lastind]
        
        #get the first and the last row 
        set firstlis [split $first ,]
        set firstrow  [lindex  $firstlis 0]
       
       
        set lastlis [split $last ,]
        set lastrow  [lindex  $lastlis 0]
       
       
        if {$length == 0} {
            
             if {[catch {$tableName index active row} firstrow]} {
               set firstrow 2
             }
             set lastrow $firstrow
        }
       
        #Delete all the rows selected
        for {set i $firstrow} {$i <= $lastrow} {incr i 1} {
            delrow $firstrow
        }
        
   }


    proc colselect {} {

        variable tableName
        

        #create a list of sorted selected cells format {0,0 0,1 ....}
        set listcell [$tableName curselection]
        set length [llength $listcell]

        #get the first cell and the last cell selected
        set first [lindex  $listcell 0]
        set lastind [expr $length -1]
        set last [lindex  $listcell $lastind]
        
        #get the first and the last row 
        set firstlis [split $first ,]
        set firstcol [lindex  $firstlis 1]
       
        set lastlis [split $last ,]
        set lastcol  [lindex  $lastlis 1]
       
        if {$length == 0} {
             
             if {[catch {$tableName index active col} firstcol]} {
               set firstcol 2
             }
             set lastcol $firstcol
        }
       
        #Delete all the rows selected
        for {set i $firstcol} {$i <= $lastcol} {incr i 1} {
            delcolumn $firstcol
        }
        
   }

    #DELETE A COLUMN IN THE TABLE#

    proc delcolumn { curColumn } {

        variable parent7
        variable tableName
        variable labelin
        variable tbdata
        variable numcol
        variable treeChildsite
        
        if {$numcol >= 2} {
            # Delete the current column
            #if {[catch {$tableName index active col} curColumn]} {
            #   set curColumn 2
            #}
            $tableName delete cols -keeptitles -- $curColumn 1

          set numcol [expr $numcol - 1]
         
          if {$numcol < 2} {
               $tableName tag cell disabledtitle 0,-1
               $tableName tag cell disabled 0,0
          }

      } else {
         tk_messageBox -icon warning \
               -message [msgcat::mc "Cannot remove any more columns"]\
               -parent $parent7
      }
        
   }
   #DELETE A ROW IN THE TABLE#

    proc delrow { curRow } {

        variable parent7
        variable tableName
        variable labelin
        variable thiscol
        variable tbdata
        variable numrow
        variable treeChildsite
        
        
        if {$numrow > 1} {
            # Delete the current row
            #if {[catch {$tableName index active row} curRow]} {
            #   set curRow 2
            #}

              $tableName delete rows -keeptitles -- $curRow 1
              set numrow [expr $numrow - 1]
        } else {
           tk_messageBox -icon warning \
               -message [msgcat::mc "Cannot remove any more rows"]\
               -parent $parent7
        }
   }

    proc graph {} {

      variable ::euidl::material::ModelControl::matModelArr

      variable labelin
      variable mat
      variable grpher
      variable tbopt
 
      # Lower the windows so that the graph isn't obscurred in 3D
      lower $matModelArr(parent)
      update

      set tboptcmd "    "
     
      set grpher 0
     
      #set a dummy material ID
      set matgr [ans_evalexpr mpinqr(0,0,14)]
      set matgr [expr $matgr +1]
 
      # call matOpts_OK with flag on
    
      matOpts_Ok 777 $matgr 0


      set def [ans_evalexpr mpinqr($matgr,0,1)]
      if {$def == 0} {
          return
      }

      #plot and delete the table
      ans_sendcommand )/GO
      if {$grpher != 999} {
        if {[catch {ans_sendcommand \
              )TBPL,$labelin,$matgr,,,,,,,PREV}]} {
            ans_sendcommand )/NOPR
            catch {ans_sendcommand )TBDE,$labelin,$matgr,,,$tboptcmd}
            ans_sendcommand )/GO
            return
        }
      }
      ans_sendcommand )/NOPR
      catch {ans_sendcommand )TBDE,$labelin,$matgr,,,$tboptcmd}
      ans_sendcommand )/GO
      after 1000 [list raise $matModelArr(parent)]
   }

   proc matOpts_Ok { flag mat next} {
   
      variable parent7
      variable labelin
      variable numcol
      variable numrow
      variable tbdata
      variable tbopt
      variable treeChildsite
      variable tableName 
      variable grpher
      
      # Indicate that a material has changed its values
      variable ::euidl::material::ModelControl::localMatlInfoArr
      if {[info exists localMatlInfoArr]} {
         set localMatlInfoArr(matl,$mat,chng) 1
      }
      
      set tboptcmd "    "
     
      #Reorder TEMPERATURE - Create a list 
      for {set i 0} {$i<$numcol} {incr i 1} { 
         if {[catch {lappend tempData $tbdata(0,$i)}]} {
                     set tbdata(0,$i) 0
                     lappend tempData $tbdata(0,$i)
         }
      }
      # Sort the temperatures into a list
     
      if {[catch {set tempSort [lsort -real -unique $tempData]}]} {
         catch {unset tempData2}
         foreach junktemp $tempData {
            regsub -all { } $junktemp {} junktemp
            if {[catch {ans_evalexpr $junktemp}]} {
               #set junktemp 0
                return
            } else {
               set junktemp [ans_evalexpr $junktemp]
            }
            lappend tempData2 $junktemp
         }
         set tempData $tempData2
         set tempSort [lsort -real -unique $tempData]
      }
      if {[llength $tempData] != [llength $tempSort]} {
         set tl {}
         set tempSort [lsort -real $tempData]
         set tl [lindex $tempSort 0]
         for {set i 1} {$i < [llength $tempSort]} {incr i} {
            if {[lindex $tempSort $i] == $tl} {
               tk_messageBox -icon error \
                     -parent $parent7 \
                     -message [::msgcat::mc "There are multiple temperatures\
                                 with value of $tl"]
               break
            }
            set tl [lindex $tempSort $i]
         }
         return
      }

      # We have a valid sorted temperature list tempSort
      ans_sendcommand )/NOPR
      #TB command
      set tb [ans_getvalue $labelin,$mat,EXIS,,,,$tboptcmd]
      if {$tb == 1} {
         catch {ans_sendcommand TBDE,$labelin,$mat,,,$tboptcmd}
      }
      if {$flag != 777} {
          ans_sendcommand )/GO
      }
      if {$flag != 777} {
         if {[catch {ans_sendcommand \
                     TB,$labelin,$mat,$numcol,$numrow,$tbopt}]} {
#             catch {ans_sendcommand TBDE,$labelin,$mat}
             return
         }
      } else {
         if {[catch {ans_sendcommand \
                    )TB,$labelin,$mat,$numcol,$numrow,$tbopt}]} {
                    set grpher 999 
                    return
         }
      }

      #TBTEMP-TBFIELD Command -Loop through the table

      foreach temp $tempSort {
         set i [lsearch $tempData $temp]
         if {$flag != 777} {
             catch {ans_sendcommand TBTEMP,$temp}
         } else {
             catch {ans_sendcommand )TBTEMP,$temp}
         }
         for {set j 0} {$j < $numrow} {incr j 6} { 
            for {set k 1} {$k <= 6} {incr k} {
               #if {[catch {ans_evalexpr $tbdata([expr $j + $k],$i)}]} {
               #   set tbdata([expr $j + $k],$i) ""
               #}
               if {[catch {set c($k) $tbdata([expr $j + $k],$i)}]} {
                  set c($k) ""
               }
               regsub -all { } $c($k) {} c($k)
            }
            if {$flag != 777} {
               if {[catch {ans_sendcommand \
                    TBDATA,,$c(1),$c(2),$c(3),$c(4),$c(5),$c(6)}]} {
                        ans_sendcommand )/NOPR
                        catch {ans_sendcommand TBDE,$labelin,$mat}
                        ans_sendcommand )/GO
                        return
               }
            } else {
               if {[catch {ans_sendcommand \
                   )TBDATA,,$c(1),$c(2),$c(3),$c(4),$c(5),$c(6)}]} {
                   set grpher 999
                   ans_sendcommand )/GO
                   return
               }
            }
         }
      }
      ans_sendcommand )/GO

       #if flag = 777 you just want to graph and not exit the window

       if {$flag != 777} {
         # Unset the variables to make sure the table table is clean
         # on reentry.

         unset numcol
         unset numrow
         unset tbdata

         destroy $parent7
         unset parent7
        
         #call next table and don't restart for combined models
         if {$next != 999} {
           if {$next != 0} {
              euidl::material::ModelControl::table_choice $next $mat 0
              return
           } else {
              euidl::material::ModelControl::matTable_State 1
              return
           }
         }
       }
   }

   proc matOpts_Cancel {} {
      variable parent7
      variable numcol
      variable numrow
      variable tbdata

      unset tbdata
      unset numcol
      unset numrow
      destroy $parent7
      unset parent7
      
      euidl::material::ModelControl::matTable_State 1
   }

}

