> NBWarTabChange
if {$need_load == 1} {
toplevel .loadframe
wm title .loadframe $::version
wm withdraw .
# modified from the artistic analog clock by Wolf-Dieter Busch at http://wiki.tcl.tk/1011
set ::clockscale [expr {$::magnify * 0.42}]
set cheight 350
set cwidth 650
grid [canvas .loadframe.c -width [expr {$::magnify * $cwidth}] -height [expr {$::magnify * $cheight}] -highlightthickness 0] -padx [expr {$::clockscale * 20}] -pady [expr {$::clockscale * 20}]
set PI [expr {asin(1)*2}]
set sekundenzeigerlaenge [expr {$::clockscale * 85}]
set minutenzeigerlaenge [expr {$::clockscale * 75}]
set stundenzeigerlaenge [expr {$::clockscale * 60}]
drawClock
showTime
.loadframe.c create text [expr {$::magnify * $cwidth / 2}] [expr {$::clockscale * 100}] -anchor center -text "Updating USDA Nutrient Database"
ttk::style configure lf.Horizontal.TProgressbar -background "#006400"
for {set i 1} {$i < 9} {incr i} {
set ::pbar($i) 0.0
ttk::progressbar .loadframe.pbar${i} -style lf.Horizontal.TProgressbar -variable pbar($i) -orient horizontal -length [expr {$::magnify * 100}] -mode determinate
.loadframe.c create window [expr {$::clockscale * 150 + 0.38 * $i * $::clockscale * 200}] [expr {$::clockscale * 160 + 0.38 * $i * $::clockscale * 200}] -anchor w -height [expr {18.0 * $::magnify}] -window .loadframe.pbar${i}
set p_label_x($i) [expr {$::clockscale * 150 + 0.38 * $i * $::clockscale * 200 + $::magnify * 100 + $::clockscale * 20}]
set p_label_y($i) [expr {$::clockscale * 160 + 0.38 * $i * $::clockscale * 200}]
}
.loadframe.c create text $p_label_x(1) $p_label_y(1) -anchor w -text "Load Nutrient Definitions"
.loadframe.c create text $p_label_x(2) $p_label_y(2) -anchor w -text "Load Food Groups"
.loadframe.c create text $p_label_x(3) $p_label_y(3) -anchor w -text "Load Foods"
.loadframe.c create text $p_label_x(4) $p_label_y(4) -anchor w -text "Load Serving Sizes"
.loadframe.c create text $p_label_x(5) $p_label_y(5) -anchor w -text "Load Nutrient Values"
.loadframe.c create text $p_label_x(6) $p_label_y(6) -anchor w -text "Join Nutrient Values to Foods"
.loadframe.c create text $p_label_x(7) $p_label_y(7) -anchor w -text "Compute Derived Nutrient Values"
.loadframe.c create text $p_label_x(8) $p_label_y(8) -anchor w -text "Load Legacy Files and Write to Disk"
update
if {$::THREADS} {
thread::send -async $::SQL_THREAD {db eval {select code from tcl_code where name = 'InitialLoad_alt_GUI'} { } ; eval $code}
thread::release $::SQL_THREAD
set ::THREADS 0
} else {
db eval {select code from tcl_code where name = 'InitialLoad_alt_GUI'} { }
eval $code
}
} else {
set tablename [db eval {select name from sqlite_master where type='table' and name = "nutr_def"}]
if { $tablename == "" } {
tk_messageBox -type ok -title $::version -message "NUT requires the USDA Nutrient Database to be present initially in order to be loaded into SQLite. Download it in the full ascii version from \"http://www.ars.usda.gov/nutrientdata\" or from \"http://nut.sourceforge.net\" and unzip it in this directory, [pwd]." -detail "Follow this same procedure later when you want to upgrade the USDA database yet retain your personal data. After USDA files have been loaded into NUT they can be deleted.\n\nIf you really do want to reload a USDA database that you have already loaded, rename the file \"NUTR_DEF.txt.loaded\" to \"NUTR_DEF.txt\"."
rename unknown ""
rename _original_unknown unknown
destroy .
exit 0
} else {
db eval {select code from tcl_code where name = 'Start_NUT_alt_GUI'} { }
eval $code
}
}
#end Main_alt
}
set drawClock {
proc drawClock {} {
global PI
global sekundenzeigerlaenge
global minutenzeigerlaenge
global stundenzeigerlaenge
set aussenradius [expr {$::clockscale * 95.0}]
set innenradius [expr {$::clockscale * 83.0}]
# Ziffernblatt
.loadframe.c create rectangle 2 2 [expr {$::clockscale * 200 - 1}] [expr {$::clockscale * 200.0 - 1}] -fill "#C7C3C7" -outline ""
.loadframe.c create line 1 [expr {$::clockscale * 200}] [expr {$::clockscale * 200}] [expr {$::clockscale * 200}] [expr {$::clockscale * 200}] 1 -fill black
.loadframe.c create line 1 [expr {$::clockscale * 200 - 1}] [expr {$::clockscale * 200 - 1}] [expr {$::clockscale * 200 - 1}] [expr {$::clockscale * 200 - 1}] 1 -fill "#8E8A8E"
.loadframe.c create line 0 [expr {$::clockscale * 200}] 0 0 [expr {$::clockscale * 200}] 0 -fill "#F8F8F8"
.loadframe.c create line 1 [expr {$::clockscale * 200 - 2}] 1 1 [expr {$::clockscale * 200 - 2}] 1 -fill "#D7D7D7"
# Zeiger
.loadframe.c create line [expr {$::clockscale * 100}] [expr {$::clockscale * 100}] [expr {[expr {$::clockscale * 100}]+$stundenzeigerlaenge}] [expr {$::clockscale * 100}] -tag stundenschatten
.loadframe.c create line [expr {$::clockscale * 100}] [expr {$::clockscale * 100}] [expr {$::clockscale * 100}] [expr {[expr {$::clockscale * 100}]-$minutenzeigerlaenge}] -tag minutenschatten
.loadframe.c create line [expr {$::clockscale * 100}] [expr {$::clockscale * 100}] [expr {$::clockscale * 100}] [expr {[expr {$::clockscale * 100}]+$sekundenzeigerlaenge}] -tag sekundenschatten
.loadframe.c create line [expr {$::clockscale * 100}] [expr {$::clockscale * 100}] [expr {[expr {$::clockscale * 100}]+$stundenzeigerlaenge}] [expr {$::clockscale * 100}] -tag {stundenzeiger zeiger}
.loadframe.c create line [expr {$::clockscale * 100}] [expr {$::clockscale * 100}] [expr {$::clockscale * 100}] [expr {[expr {$::clockscale * 100}]-$minutenzeigerlaenge}] -tag {minutenzeiger zeiger}
.loadframe.c create line [expr {$::clockscale * 100}] [expr {$::clockscale * 100}] [expr {$::clockscale * 100}] [expr {[expr {$::clockscale * 100}]+$sekundenzeigerlaenge}] -tag {sekundenzeiger zeiger}
.loadframe.c itemconfigure stundenzeiger -width [expr {$::clockscale * 11}] -fill "#554444"
.loadframe.c itemconfigure minutenzeiger -width [expr {$::clockscale * 8}] -fill "#554444"
.loadframe.c itemconfigure sekundenzeiger -width [expr {$::clockscale * 4}] -fill "#FFFF00"
.loadframe.c itemconfigure stundenschatten -width [expr {$::clockscale * 11}] -fill "#B0B0B0"
.loadframe.c itemconfigure minutenschatten -width [expr {$::clockscale * 8}] -fill "#B0B0B0"
.loadframe.c itemconfigure sekundenschatten -width [expr {$::clockscale * 4}] -fill "#B0B0B0"
# Ziffern
for {set i 0} {$i < 60} {incr i} {
set r0 [expr {$innenradius + 5}]
set r1 [expr {$innenradius +10}]
set x0 [expr {sin($PI/30*(30-$i))*$r0+[expr {$::clockscale * 100}]}]
set y0 [expr {cos($PI/30*(30-$i))*$r0+[expr {$::clockscale * 100}]}]
set x1 [expr {sin($PI/30*(30-$i))*$r1+[expr {$::clockscale * 100}]}]
set y1 [expr {cos($PI/30*(30-$i))*$r1+[expr {$::clockscale * 100}]}]
if {[expr {$i%5}]} {
}
}
for {set i 0} {$i < 12} {incr i} {
set x [expr {sin($PI/6*(6-$i))*$innenradius+[expr {$::clockscale * 100}]}]
set y [expr {cos($PI/6*(6-$i))*$innenradius+[expr {$::clockscale * 100}]}]
.loadframe.c create text $x $y \
-text [expr {$i ? $i : 12}] \
-font TkSmallCaptionFont \
-fill #000000 \
-tag ziffer
}
}
#end drawClock
}
set stundenZeigerAuf {
proc stundenZeigerAuf {std} {
global PI
global stundenzeigerlaenge
set x0 [expr {$::clockscale * 100}]
set y0 [expr {$::clockscale * 100}]
set dx [expr {sin ($PI/6*(6-$std))*$stundenzeigerlaenge}]
set dy [expr {cos ($PI/6*(6-$std))*$stundenzeigerlaenge}]
set x1 [expr {$x0 + $dx}]
set y1 [expr {$y0 + $dy}]
.loadframe.c coords stundenzeiger $x0 $y0 $x1 $y1
set schattenabstand [expr {$::clockscale * 6}]
set x0s [expr {$x0 + $schattenabstand}]
set y0s [expr {$y0 + $schattenabstand}]
set x1s [expr {$x1 + $schattenabstand}]
set y1s [expr {$y1 + $schattenabstand}]
.loadframe.c coords stundenschatten $x0s $y0s $x1s $y1s
}
#end stundenZeigerAuf
}
set minutenZeigerAuf {
proc minutenZeigerAuf {min} {
global PI
global minutenzeigerlaenge
set x0 [expr {$::clockscale * 100}]
set y0 [expr {$::clockscale * 100}]
set dx [expr {sin ($PI/30*(30-$min))*$minutenzeigerlaenge}]
set dy [expr {cos ($PI/30*(30-$min))*$minutenzeigerlaenge}]
set x1 [expr {$x0 + $dx}]
set y1 [expr {$y0 + $dy}]
.loadframe.c coords minutenzeiger $x0 $y0 $x1 $y1
set schattenabstand [expr {$::clockscale * 8}]
set x0s [expr {$x0 + $schattenabstand}]
set y0s [expr {$y0 + $schattenabstand}]
set x1s [expr {$x1 + $schattenabstand}]
set y1s [expr {$y1 + $schattenabstand}]
.loadframe.c coords minutenschatten $x0s $y0s $x1s $y1s
}
#end minutenZeigerAuf
}
set sekundenZeigerAuf {
proc sekundenZeigerAuf {sec} {
global PI
global sekundenzeigerlaenge
set x0 [expr {$::clockscale * 100}]
set y0 [expr {$::clockscale * 100}]
set dx [expr {sin ($PI/30*(30-$sec))*$sekundenzeigerlaenge}]
set dy [expr {cos ($PI/30*(30-$sec))*$sekundenzeigerlaenge}]
set x1 [expr {$x0 + $dx}]
set y1 [expr {$y0 + $dy}]
.loadframe.c coords sekundenzeiger $x0 $y0 $x1 $y1
set schattenabstand [expr {$::clockscale * 10}]
set x0s [expr {$x0 + $schattenabstand}]
set y0s [expr {$y0 + $schattenabstand}]
set x1s [expr {$x1 + $schattenabstand}]
set y1s [expr {$y1 + $schattenabstand}]
.loadframe.c coords sekundenschatten $x0s $y0s $x1s $y1s
}
#end sekundenZeigerAuf
}
set showTime {
proc showTime {} {
after cancel showTime
after 1000 showTime
set secs [clock seconds]
set l [clock format $secs -format {%H %M %S} ]
set std [lindex $l 0]
set min [lindex $l 1]
set sec [lindex $l 2]
regsub ^0 $std "" std
regsub ^0 $min "" min
regsub ^0 $sec "" sec
set min [expr {$min + 1.0 * $sec/60}]
set std [expr {$std + 1.0 * $min/60}]
stundenZeigerAuf $std
minutenZeigerAuf $min
sekundenZeigerAuf $sec
}
#end showTime
}
set InitialLoad_alt_GUI {
sqlite3 dbmem :memory:
dbmem function n6hufa n6hufa
dbmem function setRefDesc setRefDesc
dbmem function format_meal_id format_meal_id
if {[catch {dbmem restore main $::DiskDB}]} {
# Duplicate the schema of appdata1.xyz into the in-memory db database
db eval {SELECT sql FROM sqlite_master WHERE sql NOT NULL and type = 'table' and name not like '%sqlite_%'} {
dbmem eval $sql
}
# Copy data content from appdata1.xyz into memory
dbmem eval {ATTACH $::DiskDB AS app}
dbmem eval {SELECT name FROM sqlite_master WHERE type='table'} {
dbmem eval "INSERT INTO $name SELECT * FROM app.$name"
}
dbmem eval {DETACH app}
}
dbmem eval {PRAGMA synchronous = 0}
if {$::THREADS} {
dbmem progress 1920 [list thread::send -async $::GUI_THREAD {pbprog_threaded 1 1.0 }]
} else {
dbmem progress 1920 {pbprog 1 1.0 }
}
load_nutr_def
if {$::THREADS} {
thread::send -async $::GUI_THREAD {set ::pbar(1) 100.0}
dbmem progress 10 [list thread::send -async $::GUI_THREAD {pbprog_threaded 2 1.0 }]
} else {
set ::pbar(1) 100.0
dbmem progress 10 {pbprog 2 1.0 }
}
load_fd_group
if {$::THREADS} {
thread::send -async $::GUI_THREAD {set ::pbar(2) 100.0}
dbmem progress 8000 [list thread::send -async $::GUI_THREAD {pbprog_threaded 3 1.0 }]
} else {
set ::pbar(2) 100.0
dbmem progress 8000 {pbprog 3 1.0 }
}
load_food_des1
dbmem eval {select count(*) as count from food_des} {
if {$count != 0} {
if {$::THREADS} {
dbmem progress 32000 [list thread::send -async $::GUI_THREAD {pbprog_threaded 3 1.0 }]
} else {
dbmem progress 32000 {pbprog 3 1.0 }
}
}
}
load_food_des2
if {$::THREADS} {
thread::send -async $::GUI_THREAD {set ::pbar(3) 100.0}
dbmem progress 9000 [list thread::send -async $::GUI_THREAD {pbprog_threaded 4 1.0 }]
} else {
set ::pbar(3) 100.0
dbmem progress 9000 {pbprog 4 1.0 }
}
load_weight
if {$::THREADS} {
thread::send -async $::GUI_THREAD {set ::pbar(4) 100.0 ; pbprog1_threaded}
dbmem progress 0 ""
} else {
set ::pbprog1counter 0
set ::pbar(4) 100.0
set ::pbar(5) 0.5
dbmem progress 26 {pbprog1}
}
load_nut_data1
if {$::THREADS} {
dbmem progress 300000 {thread::send -async $::GUI_THREAD {pbprog 5 1.0 }}
} else {
dbmem progress 300000 {pbprog 5 1.0 }
}
load_nut_data2
if {$::THREADS} {
thread::send -async $::GUI_THREAD {set ::pbar(5) 100.0}
dbmem progress 240000 {thread::send -async $::GUI_THREAD {pbprog 6 1.0 }}
} else {
set ::pbar(5) 100.0
dbmem progress 120000 {pbprog 6 0.5 }
}
dbmem eval $::foodjoin
if {$::THREADS} {
thread::send -async $::GUI_THREAD {set ::pbar(6) 100.0}
dbmem progress [expr {[dbmem eval {select count(NDB_No) from food_des}] * 120}] {thread::send -async $::GUI_THREAD {pbprog 7 1.0 }}
} else {
set ::pbar(6) 100.0
dbmem progress [expr {[dbmem eval {select count(NDB_No) from food_des}] * 60}] {pbprog 7 0.5 }
}
ComputeDerivedValues dbmem food_des
if {$::THREADS} {
thread::send -async $::GUI_THREAD {set ::pbar(7) 100.0 ; .loadframe.pbar8 configure -mode indeterminate ; .loadframe.pbar8 start}
dbmem progress 0 ""
} else {
set ::pbar(7) 100.0
dbmem progress 4000 {update}
.loadframe.pbar8 configure -mode indeterminate
.loadframe.pbar8 start
}
load_legacy
if {$::THREADS} {
thread::send -async $::GUI_THREAD {.loadframe.pbar8 stop ; .loadframe.pbar8 configure -mode determinate ; set ::pbar(8) 80.0}
dbmem progress 0 ""
} else {
dbmem progress 0 ""
.loadframe.pbar8 stop
.loadframe.pbar8 configure -mode determinate
set ::pbar(8) 80.0
update
}
dbmem eval {analyze main}
dbmem eval {PRAGMA synchronous = 2}
if {[catch {dbmem backup main $::DiskDB}]} {
# Duplicate the schema of appdata1.xyz from the in-memory db database
set sql_mast [db eval {SELECT name, type FROM sqlite_master where type != 'index'}]
foreach {name type} $sql_mast {
db eval "DROP $type if exists $name"
}
dbmem eval {SELECT sql FROM sqlite_master WHERE sql NOT NULL and type != 'trigger'} {
db eval $sql
}
# Copy data content into appdata1.xyz from memory
dbmem eval {ATTACH $::DiskDB AS app}
dbmem eval {SELECT name FROM sqlite_master WHERE type='table'} {
dbmem eval "INSERT INTO app.$name SELECT * FROM $name"
}
dbmem eval {SELECT sql FROM sqlite_master WHERE sql NOT NULL and type = 'trigger'} {
db eval $sql
}
dbmem eval {DETACH app}
}
dbmem close
if {$::THREADS} {
thread::send -async $::GUI_THREAD {set ::pbar(8) 90.0}
} else {
set ::pbar(8) 90.0
update
}
db eval {vacuum}
file rename -force "NUTR_DEF.txt" "NUTR_DEF.txt.loaded"
if {$::THREADS} {
thread::send -async $::GUI_THREAD {set ::pbar(8) 100.0}
} else {
set ::pbar(8) 100.0
update
}
if {$::THREADS} {
thread::send -async $::GUI_THREAD {wm deiconify . ; after cancel showTime ; destroy .loadframe ; db eval {select code from tcl_code where name = 'Start_NUT_alt_GUI'} { } ; eval $code}
} else {
wm deiconify .
after cancel showTime
destroy .loadframe
db eval {select code from tcl_code where name = 'Start_NUT_alt_GUI'} { }
eval $code
}
#end InitialLoad_alt_GUI
}
set pbprog_threaded {
proc pbprog_threaded {barnum bailey} {
set ::pbar($barnum) [expr {$::pbar($barnum) + $bailey}]
}
#end pbprog_threaded
}
set pbprog1_threaded {
proc pbprog1_threaded { } {
for {set i 0} {$i < 80} {incr i} {
after [expr {$i * 1000}] {set ::pbar(5) [expr {$::pbar(5) + 0.5}]}
}
}
#end pbprog1_threaded
}
set Start_NUT_alt_GUI {
db nullvalue "\[No Data\]"
db eval {select Tagname, NutrDesc, Units from nutr_def} {
set nut $Tagname
set ::${nut}b $NutrDesc
set ::${nut}u $Units
}
db eval {select count(meal_id) as "::mealcount", case when FAPU1 = 0.0 then 50.0 else FAPU1 end as "::FAPU1", defanal_am from meals, options} {
if {$defanal_am > 0} {
set ::meals_to_analyze_am [expr {$defanal_am > $::mealcount ? $::mealcount : $defanal_am}]
.nut.am.mealsb configure -from 1
} else {
set ::meals_to_analyze_am $::mealcount
if {$::mealcount > 0} {.nut.am.mealsb configure -from 1} else {
.nut.am.mealsb configure -from 0
}
}
if {$::mealcount > 0} {.nut.am.mealsb configure -to $::mealcount}
}
::trace add variable ::meals_to_analyze_am write SetDefanal
db eval {select Tagname from nutr_def where dv_default > 0.0} {
trace add variable ::${Tagname}opt write [list opt_change $Tagname]
trace add variable ::${Tagname}am write ::${Tagname}dv_change
trace add variable ::${Tagname}rm write ::${Tagname}new_rm
trace add variable ::${Tagname}vf write ::${Tagname}new_vf
trace add variable ::${Tagname}dv write ::${Tagname}new_dv
}
db eval {select grams as "::GRAMSopt" from options} { }
db eval {select * from nut_opts} { }
db eval {select * from dv_defaults} { }
db eval {select * from dv} { }
db eval {select * from am_zero; select * from rm_zero; select * from vf_zero} { }
if {$::mealcount > 0} {
update_am
}
SetMealBase
set ::rmMainPane .nut.rm.nbw
::trace add variable ::GRAMSopt write GO_change
set ::rankchoices { {Foods Ranked per 100 Grams} {Foods Ranked per 100 Calories} {Foods Ranked per one approximate Serving} {Foods Ranked per Daily Recorded Meals} }
set ::fdgroupchoices { {All Food Groups} }
db eval {select count(meal_id) as "::mealcount" from meals} { }
if {$::mealcount > 0} {
set ::rankchoice {Foods Ranked per Daily Recorded Meals}
} else {
set ::rankchoice {Foods Ranked per 100 Grams}
}
set ::fdgroupchoice {All Food Groups}
.nut.ts.rankchoice configure -textvariable ::rankchoice -values $::rankchoices
db eval {select FdGrp_Desc as fg from fd_group order by FdGrp_Desc} {
lappend ::fdgroupchoices $fg
}
.nut.ts.fdgroupchoice configure -values $::fdgroupchoices
trace add variable ::rankchoice write [list NewStoryLater NULL ts]
trace add variable ::fdgroupchoice write [list NewStoryLater NULL ts]
menu .nut.rm.setmpd.m -tearoff 0 -background "#FF9428"
if {$::meals_per_day != 1} {
.nut.rm.setmpd.m add command -label "Set 1 meal per day" -command [list SetMPD 1]
} else {
.nut.rm.setmpd.m add command -label "Set 1 meal per day" -command [list SetMPD 1] -state disabled
}
for {set i 2} {$i < 20} {incr i} {
if {$i != $::meals_per_day} {
.nut.rm.setmpd.m add command -label "Set $i meals per day" -command [list SetMPD $i]
} else {
.nut.rm.setmpd.m add command -label "Set $i meals per day" -command [list SetMPD $i] -state disabled
}
}
if {$::mealcount == 0} {
db eval {select FAPU1 as "::FAPU1" from options} { }
auto_cal
}
after 2000 InitializePersonalOptions
#end Start_NUT_alt_GUI
}
set opt_change {
proc opt_change {tag args} {
set var "::${tag}opt"
upvar #0 $var optvar
if {[string is double $optvar]} {
db eval {update nutr_def set nutopt = $optvar where Tagname = $tag}
auto_cal
}
if {$tag in {ENERC_KCAL CA FE MG P K NA ZN CU MN SE VITA_IU VITD VITC THIA RIBF NIA PANTAC VITB6A FOL VITB12 VITK1 VITE}} {
::${tag}dv_change
}
}
#end opt_change
}
set SetMealBase {
proc SetMealBase {args} {
db eval {select meals_per_day as "::meals_per_day" from options} { }
set ::mealnumbase_time [expr {int(([db eval {select julianday('now','localtime') + 0.5}] - [clock format [clock seconds] -format {%J}] + (1.0 / $::meals_per_day)) * $::meals_per_day)}]
set ::mealdatebase_time [clock format [clock seconds] -format {%Y%m%d}]
set ::mealbase_time [expr {$::mealdatebase_time * 100 + $::mealnumbase_time}]
if {$::mealcount > 0} {
db eval {select max(meal_id) / 100 as "::mealdatebase_max", max(meal_id) % 100 + 1 "::mealnumbase_max" from meals} { }
if {$::mealnumbase_max > $::meals_per_day} {
set ::mealnumbase_max [expr {$::mealnumbase_max - $::meals_per_day}]
set ::mealdatebase_max [expr {1 + [clock format [clock scan $::mealdatebase_max -format {%Y%m%d}] -format {%J}]}]
set ::mealdatebase_max [clock format [clock scan $::mealdatebase_max -format {%J}] -format {%Y%m%d}]
}
set ::mealbase_max [expr {$::mealdatebase_max * 100 + $::mealnumbase_max}]
} else {
set ::mealbase_max 0
}
if {$::mealbase_time >= $::mealbase_max} {
set ::mealbase $::mealbase_time
set ::mealchoice "Meal [format_meal_id $::mealbase_time]"
} else {
set ::mealbase $::mealbase_max
set ::mealchoice "Meal [format_meal_id $::mealbase_max]"
}
set ::currentmeal $::mealbase
db eval {update options set lastmeal_rm = $::currentmeal}
.nut.rm.scale configure -label $::mealchoice
}
#end SetMealBase
}
set GO_change {
proc GO_change {args} {
db eval {update options set grams = $::GRAMSopt}
RefreshMealfoodQuantities
set ::StoryIsStale 1
if {$::GRAMSopt == 1} {
for {set i 0} {$i < $::MealfoodSequence} {incr i} {
${::rmMenu}.menu.foodspin${i} configure -format {%0.0f} -from -9999 -to 9999 -increment 1
}
} elseif {$::GRAMSopt == 0} {
for {set i 0} {$i < $::MealfoodSequence} {incr i} {
${::rmMenu}.menu.foodspin${i} configure -format {%0.1f} -from -999.9 -to 999.9 -increment 0.1
}
}
}
#end GO_change
}
set get_procs_from_db {
proc get_procs_from_db {args} {
# Save the original one so we can chain to it
rename unknown _original_unknown
# Provide our own implementation
proc unknown args {
set pname [lindex $args 0]
set arglist [lrange $args 1 end]
set count [db eval {select count(*) from tcl_code where name = $pname}]
if {$count == 1} {
set pcode [db eval {select code from tcl_code where name = $pname}]
uplevel 1 {*}$pcode
$pname {*}$arglist
} else {
uplevel 1 [list _original_unknown {*}$args]
}
}
db function format_meal_id format_meal_id
db function n6hufa n6hufa
db function update_am update_am
db function setRefDesc setRefDesc
db function monoright monoright
}
#end get_procs_from_db
}
set ::PROCNTdv_change {
proc ::PROCNTdv_change {args} {
if {[string is double -strict $::PROCNTam]} {
set ::PROCNTamdv [expr {round(100.0 * $::PROCNTam / $::PROCNTdv)}]
} else { set ::PROCNTamdv "\[No Data\]"
}
}
#end ::PROCNTdv_change
}
set ::PROCNTnew_dv {
proc ::PROCNTnew_dv {args} {
if {[string is double -strict $::PROCNTam]} {
set ::PROCNTamdv [expr {round(100.0 * $::PROCNTam / $::PROCNTdv)}]
} else { set ::PROCNTamdv "\[No Data\]"
}
if {[string is double -strict $::PROCNTrm]} {
set ::PROCNTrmdv [expr {round(100.0 * $::PROCNTrm / $::PROCNTdv)}]
} else { set ::PROCNTrmdv "\[No Data\]"
}
if {[string is double -strict $::PROCNTvf]} {
set ::PROCNTvfdv [expr {round(100.0 * $::PROCNTvf / $::PROCNTdv)}]
} else { set ::PROCNTvfdv "\[No Data\]"
}
}
#end ::PROCNTnew_dv
}
set ::PROCNTnew_rm {
proc ::PROCNTnew_rm {args} {
if {[string is double -strict $::PROCNTrm]} {
set ::PROCNTrmdv [expr {round(100.0 * $::PROCNTrm / $::PROCNTdv)}]
} else { set ::PROCNTrmdv "\[No Data\]"
}
}
#end ::PROCNTnew_rm
}
set ::PROCNTnew_vf {
proc ::PROCNTnew_vf {args} {
if {[string is double -strict $::PROCNTvf]} {
set ::PROCNTvfdv [expr {round(100.0 * $::PROCNTvf / $::PROCNTdv)}]
} else { set ::PROCNTvfdv "\[No Data\]"
}
}
#end ::PROCNTnew_vf
}
set ::FATdv_change {
proc ::FATdv_change {args} {
if {[string is double -strict $::FATam]} {
set ::FATamdv [expr {round(100.0 * $::FATam / $::FATdv)}]
} else { set ::FATamdv "\[No Data\]"
}
}
#end ::FATdv_change
}
set ::FATnew_dv {
proc ::FATnew_dv {args} {
if {[string is double -strict $::FATam]} {
set ::FATamdv [expr {round(100.0 * $::FATam / $::FATdv)}]
} else { set ::FATamdv "\[No Data\]"
}
if {[string is double -strict $::FATrm]} {
set ::FATrmdv [expr {round(100.0 * $::FATrm / $::FATdv)}]
} else { set ::FATrmdv "\[No Data\]"
}
if {[string is double -strict $::FATvf]} {
set ::FATvfdv [expr {round(100.0 * $::FATvf / $::FATdv)}]
} else { set ::FATvfdv "\[No Data\]"
}
}
#end ::FATnew_dv
}
set ::FATnew_rm {
proc ::FATnew_rm {args} {
if {[string is double -strict $::FATrm]} {
set ::FATrmdv [expr {round(100.0 * $::FATrm / $::FATdv)}]
} else { set ::FATrmdv "\[No Data\]"
}
}
#end ::FATnew_rm
}
set ::FATnew_vf {
proc ::FATnew_vf {args} {
if {[string is double -strict $::FATvf]} {
set ::FATvfdv [expr {round(100.0 * $::FATvf / $::FATdv)}]
} else { set ::FATvfdv "\[No Data\]"
}
}
#end ::FATnew_vf
}
set ::CHOCDFdv_change {
proc ::CHOCDFdv_change {args} {
if {[string is double -strict $::CHOCDFam]} {
set ::CHOCDFamdv [expr {round(100.0 * $::CHOCDFam / $::CHOCDFdv)}]
} else { set ::CHOCDFamdv "\[No Data\]"
}
}
#end ::CHOCDFdv_change
}
set ::CHOCDFnew_dv {
proc ::CHOCDFnew_dv {args} {
if {[string is double -strict $::CHOCDFam]} {
set ::CHOCDFamdv [expr {round(100.0 * $::CHOCDFam / $::CHOCDFdv)}]
} else { set ::CHOCDFamdv "\[No Data\]"
}
if {[string is double -strict $::CHOCDFrm]} {
set ::CHOCDFrmdv [expr {round(100.0 * $::CHOCDFrm / $::CHOCDFdv)}]
} else { set ::CHOCDFrmdv "\[No Data\]"
}
if {[string is double -strict $::CHOCDFvf]} {
set ::CHOCDFvfdv [expr {round(100.0 * $::CHOCDFvf / $::CHOCDFdv)}]
} else { set ::CHOCDFvfdv "\[No Data\]"
}
}
#end ::CHOCDFnew_dv
}
set ::CHOCDFnew_rm {
proc ::CHOCDFnew_rm {args} {
if {[string is double -strict $::CHOCDFrm]} {
set ::CHOCDFrmdv [expr {round(100.0 * $::CHOCDFrm / $::CHOCDFdv)}]
} else { set ::CHOCDFrmdv "\[No Data\]"
}
}
#end ::CHOCDFnew_rm
}
set ::CHOCDFnew_vf {
proc ::CHOCDFnew_vf {args} {
if {[string is double -strict $::CHOCDFvf]} {
set ::CHOCDFvfdv [expr {round(100.0 * $::CHOCDFvf / $::CHOCDFdv)}]
} else { set ::CHOCDFvfdv "\[No Data\]"
}
}
#end ::CHOCDFnew_vf
}
set ::ENERC_KCALdv_change {
proc ::ENERC_KCALdv_change {args} {
if {$::ENERC_KCALopt == 0.0} {set newdv $::ENERC_KCALdv_default} elseif { $::ENERC_KCALopt > 0.0} {set newdv $::ENERC_KCALopt} else {set newdv $::ENERC_KCALam}
if {$newdv == 0.0} {set newdv $::ENERC_KCALdv_default}
set newdv [expr {round(10.0 * $newdv) / 10.0}]
if {$newdv != $::ENERC_KCALdv} { set ::ENERC_KCALdv $newdv }
if {[string is double -strict $::ENERC_KCALam]} {
set ::ENERC_KCALamdv [expr {round(100.0 * $::ENERC_KCALam / $::ENERC_KCALdv)}]
} else { set ::ENERC_KCALamdv "\[No Data\]" }
}
#end ::ENERC_KCALdv_change
}
set ::ENERC_KCALnew_dv {
proc ::ENERC_KCALnew_dv {args} {
set ::caloriebutton "Calories ([expr {round($::ENERC_KCALdv)}])"
if {[string is double -strict $::ENERC_KCALam]} {
set ::ENERC_KCALamdv [expr {round(100.0 * $::ENERC_KCALam / $::ENERC_KCALdv)}]
} else { set ::ENERC_KCALamdv "\[No Data\]"
}
if {[string is double -strict $::ENERC_KCALrm]} {
set ::ENERC_KCALrmdv [expr {round(100.0 * $::ENERC_KCALrm / $::ENERC_KCALdv)}]
} else { set ::ENERC_KCALrmdv "\[No Data\]"
}
if {[string is double -strict $::ENERC_KCALvf]} {
set ::ENERC_KCALvfdv [expr {round(100.0 * $::ENERC_KCALvf / $::ENERC_KCALdv)}]
} else { set ::ENERC_KCALvfdv "\[No Data\]"
}
}
#end ::ENERC_KCALnew_dv
}
set ::ENERC_KCALnew_rm {
proc ::ENERC_KCALnew_rm {args} {
if {[string is double -strict $::ENERC_KCALrm]} {
set ::ENERC_KCALrmdv [expr {round(100.0 * $::ENERC_KCALrm / $::ENERC_KCALdv)}]
} else { set ::ENERC_KCALrmdv "\[No Data\]"
}
}
#end ::ENERC_KCALnew_rm
}
set ::ENERC_KCALnew_vf {
proc ::ENERC_KCALnew_vf {args} {
if {[string is double -strict $::ENERC_KCALvf]} {
set ::ENERC_KCALvfdv [expr {round(100.0 * $::ENERC_KCALvf / $::ENERC_KCALdv)}]
} else { set ::ENERC_KCALvfdv "\[No Data\]"
}
}
#end ::ENERC_KCALnew_vf
}
set ::FIBTGdv_change {
proc ::FIBTGdv_change {args} {
if {[string is double -strict $::FIBTGam]} {
set ::FIBTGamdv [expr {round(100.0 * $::FIBTGam / $::FIBTGdv)}]
} else { set ::FIBTGamdv "\[No Data\]"
}
}
#end ::FIBTGdv_change
}
set ::FIBTGnew_dv {
proc ::FIBTGnew_dv {args} {
if {[string is double -strict $::FIBTGam]} {
set ::FIBTGamdv [expr {round(100.0 * $::FIBTGam / $::FIBTGdv)}]
} else { set ::FIBTGamdv "\[No Data\]"
}
if {[string is double -strict $::FIBTGrm]} {
set ::FIBTGrmdv [expr {round(100.0 * $::FIBTGrm / $::FIBTGdv)}]
} else { set ::FIBTGrmdv "\[No Data\]"
}
if {[string is double -strict $::FIBTGvf]} {
set ::FIBTGvfdv [expr {round(100.0 * $::FIBTGvf / $::FIBTGdv)}]
} else { set ::FIBTGvfdv "\[No Data\]"
}
}
#end ::FIBTGnew_dv
}
set ::FIBTGnew_rm {
proc ::FIBTGnew_rm {args} {
if {[string is double -strict $::FIBTGrm]} {
set ::FIBTGrmdv [expr {round(100.0 * $::FIBTGrm / $::FIBTGdv)}]
} else { set ::FIBTGrmdv "\[No Data\]"
}
}
#end ::FIBTGnew_rm
}
set ::FIBTGnew_vf {
proc ::FIBTGnew_vf {args} {
if {[string is double -strict $::FIBTGvf]} {
set ::FIBTGvfdv [expr {round(100.0 * $::FIBTGvf / $::FIBTGdv)}]
} else { set ::FIBTGvfdv "\[No Data\]"
}
}
#end ::FIBTGnew_vf
}
set ::CAdv_change {
proc ::CAdv_change {args} {
if {$::CAopt == 0.0} {set newdv $::CAdv_default} elseif { $::CAopt > 0.0} {set newdv $::CAopt} else {set newdv $::CAam}
if {$newdv == 0.0} {set newdv $::CAdv_default}
if {$newdv != $::CAdv} { set ::CAdv $newdv }
if {[string is double -strict $::CAam]} {
set ::CAamdv [expr {round(100.0 * $::CAam / $::CAdv)}]
} else { set ::CAamdv "\[No Data\]"
}
}
#end ::CAdv_change
}
set ::CAnew_dv {
proc ::CAnew_dv {args} {
if {[string is double -strict $::CAam]} {
set ::CAamdv [expr {round(100.0 * $::CAam / $::CAdv)}]
} else { set ::CAamdv "\[No Data\]"
}
if {[string is double -strict $::CArm]} {
set ::CArmdv [expr {round(100.0 * $::CArm / $::CAdv)}]
} else { set ::CArmdv "\[No Data\]"
}
if {[string is double -strict $::CAvf]} {
set ::CAvfdv [expr {round(100.0 * $::CAvf / $::CAdv)}]
} else { set ::CAvfdv "\[No Data\]"
}
}
#end ::CAnew_dv
}
set ::CAnew_rm {
proc ::CAnew_rm {args} {
if {[string is double -strict $::CArm]} {
set ::CArmdv [expr {round(100.0 * $::CArm / $::CAdv)}]
} else { set ::CArmdv "\[No Data\]"
}
}
#end ::CAnew_rm
}
set ::CAnew_vf {
proc ::CAnew_vf {args} {
if {[string is double -strict $::CAvf]} {
set ::CAvfdv [expr {round(100.0 * $::CAvf / $::CAdv)}]
} else { set ::CAvfdv "\[No Data\]"
}
}
#end ::CAnew_vf
}
set ::FEdv_change {
proc ::FEdv_change {args} {
if {$::FEopt == 0.0} {set newdv $::FEdv_default} elseif { $::FEopt > 0.0} {set newdv $::FEopt} else {set newdv $::FEam}
if {$newdv == 0.0} {set newdv $::FEdv_default}
if {$newdv != $::FEdv} { set ::FEdv $newdv }
if {[string is double -strict $::FEam]} {
set ::FEamdv [expr {round(100.0 * $::FEam / $::FEdv)}]
} else { set ::FEamdv "\[No Data\]"
}
}
#end ::FEdv_change
}
set ::FEnew_dv {
proc ::FEnew_dv {args} {
if {[string is double -strict $::FEam]} {
set ::FEamdv [expr {round(100.0 * $::FEam / $::FEdv)}]
} else { set ::FEamdv "\[No Data\]"
}
if {[string is double -strict $::FErm]} {
set ::FErmdv [expr {round(100.0 * $::FErm / $::FEdv)}]
} else { set ::FErmdv "\[No Data\]"
}
if {[string is double -strict $::FEvf]} {
set ::FEvfdv [expr {round(100.0 * $::FEvf / $::FEdv)}]
} else { set ::FEvfdv "\[No Data\]"
}
}
#end ::FEnew_dv
}
set ::FEnew_rm {
proc ::FEnew_rm {args} {
if {[string is double -strict $::FErm]} {
set ::FErmdv [expr {round(100.0 * $::FErm / $::FEdv)}]
} else { set ::FErmdv "\[No Data\]"
}
}
#end ::FEnew_rm
}
set ::FEnew_vf {
proc ::FEnew_vf {args} {
if {[string is double -strict $::FEvf]} {
set ::FEvfdv [expr {round(100.0 * $::FEvf / $::FEdv)}]
} else { set ::FEvfdv "\[No Data\]"
}
}
#end ::FEnew_vf
}
set ::MGdv_change {
proc ::MGdv_change {args} {
if {$::MGopt == 0.0} {set newdv $::MGdv_default} elseif { $::MGopt > 0.0} {set newdv $::MGopt} else {set newdv $::MGam}
if {$newdv == 0.0} {set newdv $::MGdv_default}
if {$newdv != $::MGdv} { set ::MGdv $newdv }
if {[string is double -strict $::MGam]} {
set ::MGamdv [expr {round(100.0 * $::MGam / $::MGdv)}]
} else { set ::MGamdv "\[No Data\]"
}
}
#end ::MGdv_change
}
set ::MGnew_dv {
proc ::MGnew_dv {args} {
if {[string is double -strict $::MGam]} {
set ::MGamdv [expr {round(100.0 * $::MGam / $::MGdv)}]
} else { set ::MGamdv "\[No Data\]"
}
if {[string is double -strict $::MGrm]} {
set ::MGrmdv [expr {round(100.0 * $::MGrm / $::MGdv)}]
} else { set ::MGrmdv "\[No Data\]"
}
if {[string is double -strict $::MGvf]} {
set ::MGvfdv [expr {round(100.0 * $::MGvf / $::MGdv)}]
} else { set ::MGvfdv "\[No Data\]"
}
}
#end ::MGnew_dv
}
set ::MGnew_rm {
proc ::MGnew_rm {args} {
if {[string is double -strict $::MGrm]} {
set ::MGrmdv [expr {round(100.0 * $::MGrm / $::MGdv)}]
} else { set ::MGrmdv "\[No Data\]"
}
}
#end ::MGnew_rm
}
set ::MGnew_vf {
proc ::MGnew_vf {args} {
if {[string is double -strict $::MGvf]} {
set ::MGvfdv [expr {round(100.0 * $::MGvf / $::MGdv)}]
} else { set ::MGvfdv "\[No Data\]"
}
}
#end ::MGnew_vf
}
set ::Pdv_change {
proc ::Pdv_change {args} {
if {$::Popt == 0.0} {set newdv $::Pdv_default} elseif { $::Popt > 0.0} {set newdv $::Popt} else {set newdv $::Pam}
if {$newdv == 0.0} {set newdv $::Pdv_default}
if {$newdv != $::Pdv} { set ::Pdv $newdv }
if {[string is double -strict $::Pam]} {
set ::Pamdv [expr {round(100.0 * $::Pam / $::Pdv)}]
} else { set ::Pamdv "\[No Data\]"
}
}
#end ::Pdv_change
}
set ::Pnew_dv {
proc ::Pnew_dv {args} {
if {[string is double -strict $::Pam]} {
set ::Pamdv [expr {round(100.0 * $::Pam / $::Pdv)}]
} else { set ::Pamdv "\[No Data\]"
}
if {[string is double -strict $::Prm]} {
set ::Prmdv [expr {round(100.0 * $::Prm / $::Pdv)}]
} else { set ::Prmdv "\[No Data\]"
}
if {[string is double -strict $::Pvf]} {
set ::Pvfdv [expr {round(100.0 * $::Pvf / $::Pdv)}]
} else { set ::Pvfdv "\[No Data\]"
}
}
#end ::Pnew_dv
}
set ::Pnew_rm {
proc ::Pnew_rm {args} {
if {[string is double -strict $::Prm]} {
set ::Prmdv [expr {round(100.0 * $::Prm / $::Pdv)}]
} else { set ::Prmdv "\[No Data\]"
}
}
#end ::Pnew_rm
}
set ::Pnew_vf {
proc ::Pnew_vf {args} {
if {[string is double -strict $::Pvf]} {
set ::Pvfdv [expr {round(100.0 * $::Pvf / $::Pdv)}]
} else { set ::Pvfdv "\[No Data\]"
}
}
#end ::Pnew_vf
}
set ::Kdv_change {
proc ::Kdv_change {args} {
if {$::Kopt == 0.0} {set newdv $::Kdv_default} elseif { $::Kopt > 0.0} {set newdv $::Kopt} else {set newdv $::Kam}
if {$newdv == 0.0} {set newdv $::Kdv_default}
if {$newdv != $::Kdv} { set ::Kdv $newdv }
if {[string is double -strict $::Kam]} {
set ::Kamdv [expr {round(100.0 * $::Kam / $::Kdv)}]
} else { set ::Kamdv "\[No Data\]"
}
}
#end ::Kdv_change
}
set ::Knew_dv {
proc ::Knew_dv {args} {
if {[string is double -strict $::Kam]} {
set ::Kamdv [expr {round(100.0 * $::Kam / $::Kdv)}]
} else { set ::Kamdv "\[No Data\]"
}
if {[string is double -strict $::Krm]} {
set ::Krmdv [expr {round(100.0 * $::Krm / $::Kdv)}]
} else { set ::Krmdv "\[No Data\]"
}
if {[string is double -strict $::Kvf]} {
set ::Kvfdv [expr {round(100.0 * $::Kvf / $::Kdv)}]
} else { set ::Kvfdv "\[No Data\]"
}
}
#end ::Knew_dv
}
set ::Knew_rm {
proc ::Knew_rm {args} {
if {[string is double -strict $::Krm]} {
set ::Krmdv [expr {round(100.0 * $::Krm / $::Kdv)}]
} else { set ::Krmdv "\[No Data\]"
}
}
#end ::Knew_rm
}
set ::Knew_vf {
proc ::Knew_vf {args} {
if {[string is double -strict $::Kvf]} {
set ::Kvfdv [expr {round(100.0 * $::Kvf / $::Kdv)}]
} else { set ::Kvfdv "\[No Data\]"
}
}
#end ::Knew_vf
}
set ::NAdv_change {
proc ::NAdv_change {args} {
if {$::NAopt == 0.0} {set newdv $::NAdv_default} elseif { $::NAopt > 0.0} {set newdv $::NAopt} else {set newdv $::NAam}
if {$newdv == 0.0} {set newdv $::NAdv_default}
if {$newdv != $::NAdv} { set ::NAdv $newdv }
if {[string is double -strict $::NAam]} {
set ::NAamdv [expr {round(100.0 * $::NAam / $::NAdv)}]
} else { set ::NAamdv "\[No Data\]"
}
}
#end ::NAdv_change
}
set ::NAnew_dv {
proc ::NAnew_dv {args} {
if {[string is double -strict $::NAam]} {
set ::NAamdv [expr {round(100.0 * $::NAam / $::NAdv)}]
} else { set ::NAamdv "\[No Data\]"
}
if {[string is double -strict $::NArm]} {
set ::NArmdv [expr {round(100.0 * $::NArm / $::NAdv)}]
} else { set ::NArmdv "\[No Data\]"
}
if {[string is double -strict $::NAvf]} {
set ::NAvfdv [expr {round(100.0 * $::NAvf / $::NAdv)}]
} else { set ::NAvfdv "\[No Data\]"
}
}
#end ::NAnew_dv
}
set ::NAnew_rm {
proc ::NAnew_rm {args} {
if {[string is double -strict $::NArm]} {
set ::NArmdv [expr {round(100.0 * $::NArm / $::NAdv)}]
} else { set ::NArmdv "\[No Data\]"
}
}
#end ::NAnew_rm
}
set ::NAnew_vf {
proc ::NAnew_vf {args} {
if {[string is double -strict $::NAvf]} {
set ::NAvfdv [expr {round(100.0 * $::NAvf / $::NAdv)}]
} else { set ::NAvfdv "\[No Data\]"
}
}
#end ::NAnew_vf
}
set ::ZNdv_change {
proc ::ZNdv_change {args} {
if {$::ZNopt == 0.0} {set newdv $::ZNdv_default} elseif { $::ZNopt > 0.0} {set newdv $::ZNopt} else {set newdv $::ZNam}
if {$newdv == 0.0} {set newdv $::ZNdv_default}
if {$newdv != $::ZNdv} { set ::ZNdv $newdv }
if {[string is double -strict $::ZNam]} {
set ::ZNamdv [expr {round(100.0 * $::ZNam / $::ZNdv)}]
} else { set ::ZNamdv "\[No Data\]"
}
}
#end ::ZNdv_change
}
set ::ZNnew_dv {
proc ::ZNnew_dv {args} {
if {[string is double -strict $::ZNam]} {
set ::ZNamdv [expr {round(100.0 * $::ZNam / $::ZNdv)}]
} else { set ::ZNamdv "\[No Data\]"
}
if {[string is double -strict $::ZNrm]} {
set ::ZNrmdv [expr {round(100.0 * $::ZNrm / $::ZNdv)}]
} else { set ::ZNrmdv "\[No Data\]"
}
if {[string is double -strict $::ZNvf]} {
set ::ZNvfdv [expr {round(100.0 * $::ZNvf / $::ZNdv)}]
} else { set ::ZNvfdv "\[No Data\]"
}
}
#end ::ZNnew_dv
}
set ::ZNnew_rm {
proc ::ZNnew_rm {args} {
if {[string is double -strict $::ZNrm]} {
set ::ZNrmdv [expr {round(100.0 * $::ZNrm / $::ZNdv)}]
} else { set ::ZNrmdv "\[No Data\]"
}
}
#end ::ZNnew_rm
}
set ::ZNnew_vf {
proc ::ZNnew_vf {args} {
if {[string is double -strict $::ZNvf]} {
set ::ZNvfdv [expr {round(100.0 * $::ZNvf / $::ZNdv)}]
} else { set ::ZNvfdv "\[No Data\]"
}
}
#end ::ZNnew_vf
}
set ::CUdv_change {
proc ::CUdv_change {args} {
if {$::CUopt == 0.0} {set newdv $::CUdv_default} elseif { $::CUopt > 0.0} {set newdv $::CUopt} else {set newdv $::CUam}
if {$newdv == 0.0} {set newdv $::CUdv_default}
if {$newdv != $::CUdv} { set ::CUdv $newdv }
if {[string is double -strict $::CUam]} {
set ::CUamdv [expr {round(100.0 * $::CUam / $::CUdv)}]
} else { set ::CUamdv "\[No Data\]"
}
}
#end ::CUdv_change
}
set ::CUnew_dv {
proc ::CUnew_dv {args} {
if {[string is double -strict $::CUam]} {
set ::CUamdv [expr {round(100.0 * $::CUam / $::CUdv)}]
} else { set ::CUamdv "\[No Data\]"
}
if {[string is double -strict $::CUrm]} {
set ::CUrmdv [expr {round(100.0 * $::CUrm / $::CUdv)}]
} else { set ::CUrmdv "\[No Data\]"
}
if {[string is double -strict $::CUvf]} {
set ::CUvfdv [expr {round(100.0 * $::CUvf / $::CUdv)}]
} else { set ::CUvfdv "\[No Data\]"
}
}
#end ::CUnew_dv
}
set ::CUnew_rm {
proc ::CUnew_rm {args} {
if {[string is double -strict $::CUrm]} {
set ::CUrmdv [expr {round(100.0 * $::CUrm / $::CUdv)}]
} else { set ::CUrmdv "\[No Data\]"
}
}
#end ::CUnew_rm
}
set ::CUnew_vf {
proc ::CUnew_vf {args} {
if {[string is double -strict $::CUvf]} {
set ::CUvfdv [expr {round(100.0 * $::CUvf / $::CUdv)}]
} else { set ::CUvfdv "\[No Data\]"
}
}
#end ::CUnew_vf
}
set ::MNdv_change {
proc ::MNdv_change {args} {
if {$::MNopt == 0.0} {set newdv $::MNdv_default} elseif { $::MNopt > 0.0} {set newdv $::MNopt} else {set newdv $::MNam}
if {$newdv == 0.0} {set newdv $::MNdv_default}
if {$newdv != $::MNdv} { set ::MNdv $newdv }
if {[string is double -strict $::MNam]} {
set ::MNamdv [expr {round(100.0 * $::MNam / $::MNdv)}]
} else { set ::MNamdv "\[No Data\]"
}
}
#end ::MNdv_change
}
set ::MNnew_dv {
proc ::MNnew_dv {args} {
if {[string is double -strict $::MNam]} {
set ::MNamdv [expr {round(100.0 * $::MNam / $::MNdv)}]
} else { set ::MNamdv "\[No Data\]"
}
if {[string is double -strict $::MNrm]} {
set ::MNrmdv [expr {round(100.0 * $::MNrm / $::MNdv)}]
} else { set ::MNrmdv "\[No Data\]"
}
if {[string is double -strict $::MNvf]} {
set ::MNvfdv [expr {round(100.0 * $::MNvf / $::MNdv)}]
} else { set ::MNvfdv "\[No Data\]"
}
}
#end ::MNnew_dv
}
set ::MNnew_rm {
proc ::MNnew_rm {args} {
if {[string is double -strict $::MNrm]} {
set ::MNrmdv [expr {round(100.0 * $::MNrm / $::MNdv)}]
} else { set ::MNrmdv "\[No Data\]"
}
}
#end ::MNnew_rm
}
set ::MNnew_vf {
proc ::MNnew_vf {args} {
if {[string is double -strict $::MNvf]} {
set ::MNvfdv [expr {round(100.0 * $::MNvf / $::MNdv)}]
} else { set ::MNvfdv "\[No Data\]"
}
}
#end ::MNnew_vf
}
set ::SEdv_change {
proc ::SEdv_change {args} {
if {$::SEopt == 0.0} {set newdv $::SEdv_default} elseif { $::SEopt > 0.0} {set newdv $::SEopt} else {set newdv $::SEam}
if {$newdv == 0.0} {set newdv $::SEdv_default}
if {$newdv != $::SEdv} { set ::SEdv $newdv }
if {[string is double -strict $::SEam]} {
set ::SEamdv [expr {round(100.0 * $::SEam / $::SEdv)}]
} else { set ::SEamdv "\[No Data\]"
}
}
#end ::SEdv_change
}
set ::SEnew_dv {
proc ::SEnew_dv {args} {
if {[string is double -strict $::SEam]} {
set ::SEamdv [expr {round(100.0 * $::SEam / $::SEdv)}]
} else { set ::SEamdv "\[No Data\]"
}
if {[string is double -strict $::SErm]} {
set ::SErmdv [expr {round(100.0 * $::SErm / $::SEdv)}]
} else { set ::SErmdv "\[No Data\]"
}
if {[string is double -strict $::SEvf]} {
set ::SEvfdv [expr {round(100.0 * $::SEvf / $::SEdv)}]
} else { set ::SEvfdv "\[No Data\]"
}
}
#end ::SEnew_dv
}
set ::SEnew_rm {
proc ::SEnew_rm {args} {
if {[string is double -strict $::SErm]} {
set ::SErmdv [expr {round(100.0 * $::SErm / $::SEdv)}]
} else { set ::SErmdv "\[No Data\]"
}
}
#end ::SEnew_rm
}
set ::SEnew_vf {
proc ::SEnew_vf {args} {
if {[string is double -strict $::SEvf]} {
set ::SEvfdv [expr {round(100.0 * $::SEvf / $::SEdv)}]
} else { set ::SEvfdv "\[No Data\]"
}
}
#end ::SEnew_vf
}
set ::VITA_IUdv_change {
proc ::VITA_IUdv_change {args} {
if {$::VITA_IUopt == 0.0} {set newdv $::VITA_IUdv_default} elseif { $::VITA_IUopt > 0.0} {set newdv $::VITA_IUopt} else {set newdv $::VITA_IUam}
if {$newdv == 0.0} {set newdv $::VITA_IUdv_default}
if {$newdv != $::VITA_IUdv} { set ::VITA_IUdv $newdv }
if {[string is double -strict $::VITA_IUam]} {
set ::VITA_IUamdv [expr {round(100.0 * $::VITA_IUam / $::VITA_IUdv)}]
} else { set ::VITA_IUamdv "\[No Data\]"
}
}
#end ::VITA_IUdv_change
}
set ::VITA_IUnew_dv {
proc ::VITA_IUnew_dv {args} {
if {[string is double -strict $::VITA_IUam]} {
set ::VITA_IUamdv [expr {round(100.0 * $::VITA_IUam / $::VITA_IUdv)}]
} else { set ::VITA_IUamdv "\[No Data\]"
}
if {[string is double -strict $::VITA_IUrm]} {
set ::VITA_IUrmdv [expr {round(100.0 * $::VITA_IUrm / $::VITA_IUdv)}]
} else { set ::VITA_IUrmdv "\[No Data\]"
}
if {[string is double -strict $::VITA_IUvf]} {
set ::VITA_IUvfdv [expr {round(100.0 * $::VITA_IUvf / $::VITA_IUdv)}]
} else { set ::VITA_IUvfdv "\[No Data\]"
}
}
#end ::VITA_IUnew_dv
}
set ::VITA_IUnew_rm {
proc ::VITA_IUnew_rm {args} {
if {[string is double -strict $::VITA_IUrm]} {
set ::VITA_IUrmdv [expr {round(100.0 * $::VITA_IUrm / $::VITA_IUdv)}]
} else { set ::VITA_IUrmdv "\[No Data\]"
}
}
#end ::VITA_IUnew_rm
}
set ::VITA_IUnew_vf {
proc ::VITA_IUnew_vf {args} {
if {[string is double -strict $::VITA_IUvf]} {
set ::VITA_IUvfdv [expr {round(100.0 * $::VITA_IUvf / $::VITA_IUdv)}]
} else { set ::VITA_IUvfdv "\[No Data\]"
}
}
#end ::VITA_IUnew_vf
}
set ::VITDdv_change {
proc ::VITDdv_change {args} {
if {$::VITDopt == 0.0} {set newdv $::VITDdv_default} elseif { $::VITDopt > 0.0} {set newdv $::VITDopt} else {set newdv $::VITDam}
if {$newdv == 0.0} {set newdv $::VITDdv_default}
if {$newdv != $::VITDdv} { set ::VITDdv $newdv }
if {[string is double -strict $::VITDam]} {
set ::VITDamdv [expr {round(100.0 * $::VITDam / $::VITDdv)}]
} else { set ::VITDamdv "\[No Data\]"
}
}
#end ::VITDdv_change
}
set ::VITDnew_dv {
proc ::VITDnew_dv {args} {
if {[string is double -strict $::VITDam]} {
set ::VITDamdv [expr {round(100.0 * $::VITDam / $::VITDdv)}]
} else { set ::VITDamdv "\[No Data\]"
}
if {[string is double -strict $::VITDrm]} {
set ::VITDrmdv [expr {round(100.0 * $::VITDrm / $::VITDdv)}]
} else { set ::VITDrmdv "\[No Data\]"
}
if {[string is double -strict $::VITDvf]} {
set ::VITDvfdv [expr {round(100.0 * $::VITDvf / $::VITDdv)}]
} else { set ::VITDvfdv "\[No Data\]"
}
}
#end ::VITDnew_dv
}
set ::VITDnew_rm {
proc ::VITDnew_rm {args} {
if {[string is double -strict $::VITDrm]} {
set ::VITDrmdv [expr {round(100.0 * $::VITDrm / $::VITDdv)}]
} else { set ::VITDrmdv "\[No Data\]"
}
}
#end ::VITDnew_rm
}
set ::VITDnew_vf {
proc ::VITDnew_vf {args} {
if {[string is double -strict $::VITDvf]} {
set ::VITDvfdv [expr {round(100.0 * $::VITDvf / $::VITDdv)}]
} else { set ::VITDvfdv "\[No Data\]"
}
}
#end ::VITDnew_vf
}
set ::VITCdv_change {
proc ::VITCdv_change {args} {
if {$::VITCopt == 0.0} {set newdv $::VITCdv_default} elseif { $::VITCopt > 0.0} {set newdv $::VITCopt} else {set newdv $::VITCam}
if {$newdv == 0.0} {set newdv $::VITCdv_default}
if {$newdv != $::VITCdv} { set ::VITCdv $newdv }
if {[string is double -strict $::VITCam]} {
set ::VITCamdv [expr {round(100.0 * $::VITCam / $::VITCdv)}]
} else { set ::VITCamdv "\[No Data\]"
}
}
#end ::VITCdv_change
}
set ::VITCnew_dv {
proc ::VITCnew_dv {args} {
if {[string is double -strict $::VITCam]} {
set ::VITCamdv [expr {round(100.0 * $::VITCam / $::VITCdv)}]
} else { set ::VITCamdv "\[No Data\]"
}
if {[string is double -strict $::VITCrm]} {
set ::VITCrmdv [expr {round(100.0 * $::VITCrm / $::VITCdv)}]
} else { set ::VITCrmdv "\[No Data\]"
}
if {[string is double -strict $::VITCvf]} {
set ::VITCvfdv [expr {round(100.0 * $::VITCvf / $::VITCdv)}]
} else { set ::VITCvfdv "\[No Data\]"
}
}
#end ::VITCnew_dv
}
set ::VITCnew_rm {
proc ::VITCnew_rm {args} {
if {[string is double -strict $::VITCrm]} {
set ::VITCrmdv [expr {round(100.0 * $::VITCrm / $::VITCdv)}]
} else { set ::VITCrmdv "\[No Data\]"
}
}
#end ::VITCnew_rm
}
set ::VITCnew_vf {
proc ::VITCnew_vf {args} {
if {[string is double -strict $::VITCvf]} {
set ::VITCvfdv [expr {round(100.0 * $::VITCvf / $::VITCdv)}]
} else { set ::VITCvfdv "\[No Data\]"
}
}
#end ::VITCnew_vf
}
set ::THIAdv_change {
proc ::THIAdv_change {args} {
if {$::THIAopt == 0.0} {set newdv $::THIAdv_default} elseif { $::THIAopt > 0.0} {set newdv $::THIAopt} else {set newdv $::THIAam}
if {$newdv == 0.0} {set newdv $::THIAdv_default}
if {$newdv != $::THIAdv} { set ::THIAdv $newdv }
if {[string is double -strict $::THIAam]} {
set ::THIAamdv [expr {round(100.0 * $::THIAam / $::THIAdv)}]
} else { set ::THIAamdv "\[No Data\]"
}
}
#end ::THIAdv_change
}
set ::THIAnew_dv {
proc ::THIAnew_dv {args} {
if {[string is double -strict $::THIAam]} {
set ::THIAamdv [expr {round(100.0 * $::THIAam / $::THIAdv)}]
} else { set ::THIAamdv "\[No Data\]"
}
if {[string is double -strict $::THIArm]} {
set ::THIArmdv [expr {round(100.0 * $::THIArm / $::THIAdv)}]
} else { set ::THIArmdv "\[No Data\]"
}
if {[string is double -strict $::THIAvf]} {
set ::THIAvfdv [expr {round(100.0 * $::THIAvf / $::THIAdv)}]
} else { set ::THIAvfdv "\[No Data\]"
}
}
#end ::THIAnew_dv
}
set ::THIAnew_rm {
proc ::THIAnew_rm {args} {
if {[string is double -strict $::THIArm]} {
set ::THIArmdv [expr {round(100.0 * $::THIArm / $::THIAdv)}]
} else { set ::THIArmdv "\[No Data\]"
}
}
#end ::THIAnew_rm
}
set ::THIAnew_vf {
proc ::THIAnew_vf {args} {
if {[string is double -strict $::THIAvf]} {
set ::THIAvfdv [expr {round(100.0 * $::THIAvf / $::THIAdv)}]
} else { set ::THIAvfdv "\[No Data\]"
}
}
#end ::THIAnew_vf
}
set ::RIBFdv_change {
proc ::RIBFdv_change {args} {
if {$::RIBFopt == 0.0} {set newdv $::RIBFdv_default} elseif { $::RIBFopt > 0.0} {set newdv $::RIBFopt} else {set newdv $::RIBFam}
if {$newdv == 0.0} {set newdv $::RIBFdv_default}
if {$newdv != $::RIBFdv} { set ::RIBFdv $newdv }
if {[string is double -strict $::RIBFam]} {
set ::RIBFamdv [expr {round(100.0 * $::RIBFam / $::RIBFdv)}]
} else { set ::RIBFamdv "\[No Data\]"
}
}
#end ::RIBFdv_change
}
set ::RIBFnew_dv {
proc ::RIBFnew_dv {args} {
if {[string is double -strict $::RIBFam]} {
set ::RIBFamdv [expr {round(100.0 * $::RIBFam / $::RIBFdv)}]
} else { set ::RIBFamdv "\[No Data\]"
}
if {[string is double -strict $::RIBFrm]} {
set ::RIBFrmdv [expr {round(100.0 * $::RIBFrm / $::RIBFdv)}]
} else { set ::RIBFrmdv "\[No Data\]"
}
if {[string is double -strict $::RIBFvf]} {
set ::RIBFvfdv [expr {round(100.0 * $::RIBFvf / $::RIBFdv)}]
} else { set ::RIBFvfdv "\[No Data\]"
}
}
#end ::RIBFnew_dv
}
set ::RIBFnew_rm {
proc ::RIBFnew_rm {args} {
if {[string is double -strict $::RIBFrm]} {
set ::RIBFrmdv [expr {round(100.0 * $::RIBFrm / $::RIBFdv)}]
} else { set ::RIBFrmdv "\[No Data\]"
}
}
#end ::RIBFnew_rm
}
set ::RIBFnew_vf {
proc ::RIBFnew_vf {args} {
if {[string is double -strict $::RIBFvf]} {
set ::RIBFvfdv [expr {round(100.0 * $::RIBFvf / $::RIBFdv)}]
} else { set ::RIBFvfdv "\[No Data\]"
}
}
#end ::RIBFnew_vf
}
set ::NIAdv_change {
proc ::NIAdv_change {args} {
if {$::NIAopt == 0.0} {set newdv $::NIAdv_default} elseif { $::NIAopt > 0.0} {set newdv $::NIAopt} else {set newdv $::NIAam}
if {$newdv == 0.0} {set newdv $::NIAdv_default}
if {$newdv != $::NIAdv} { set ::NIAdv $newdv }
if {[string is double -strict $::NIAam]} {
set ::NIAamdv [expr {round(100.0 * $::NIAam / $::NIAdv)}]
} else { set ::NIAamdv "\[No Data\]"
}
}
#end ::NIAdv_change
}
set ::NIAnew_dv {
proc ::NIAnew_dv {args} {
if {[string is double -strict $::NIAam]} {
set ::NIAamdv [expr {round(100.0 * $::NIAam / $::NIAdv)}]
} else { set ::NIAamdv "\[No Data\]"
}
if {[string is double -strict $::NIArm]} {
set ::NIArmdv [expr {round(100.0 * $::NIArm / $::NIAdv)}]
} else { set ::NIArmdv "\[No Data\]"
}
if {[string is double -strict $::NIAvf]} {
set ::NIAvfdv [expr {round(100.0 * $::NIAvf / $::NIAdv)}]
} else { set ::NIAvfdv "\[No Data\]"
}
}
#end ::NIAnew_dv
}
set ::NIAnew_rm {
proc ::NIAnew_rm {args} {
if {[string is double -strict $::NIArm]} {
set ::NIArmdv [expr {round(100.0 * $::NIArm / $::NIAdv)}]
} else { set ::NIArmdv "\[No Data\]"
}
}
#end ::NIAnew_rm
}
set ::NIAnew_vf {
proc ::NIAnew_vf {args} {
if {[string is double -strict $::NIAvf]} {
set ::NIAvfdv [expr {round(100.0 * $::NIAvf / $::NIAdv)}]
} else { set ::NIAvfdv "\[No Data\]"
}
}
#end ::NIAnew_vf
}
set ::PANTACdv_change {
proc ::PANTACdv_change {args} {
if {$::PANTACopt == 0.0} {set newdv $::PANTACdv_default} elseif { $::PANTACopt > 0.0} {set newdv $::PANTACopt} else {set newdv $::PANTACam}
if {$newdv == 0.0} {set newdv $::PANTACdv_default}
if {$newdv != $::PANTACdv} { set ::PANTACdv $newdv }
if {[string is double -strict $::PANTACam]} {
set ::PANTACamdv [expr {round(100.0 * $::PANTACam / $::PANTACdv)}]
} else { set ::PANTACamdv "\[No Data\]"
}
}
#end ::PANTACdv_change
}
set ::PANTACnew_dv {
proc ::PANTACnew_dv {args} {
if {[string is double -strict $::PANTACam]} {
set ::PANTACamdv [expr {round(100.0 * $::PANTACam / $::PANTACdv)}]
} else { set ::PANTACamdv "\[No Data\]"
}
if {[string is double -strict $::PANTACrm]} {
set ::PANTACrmdv [expr {round(100.0 * $::PANTACrm / $::PANTACdv)}]
} else { set ::PANTACrmdv "\[No Data\]"
}
if {[string is double -strict $::PANTACvf]} {
set ::PANTACvfdv [expr {round(100.0 * $::PANTACvf / $::PANTACdv)}]
} else { set ::PANTACvfdv "\[No Data\]"
}
}
#end ::PANTACnew_dv
}
set ::PANTACnew_rm {
proc ::PANTACnew_rm {args} {
if {[string is double -strict $::PANTACrm]} {
set ::PANTACrmdv [expr {round(100.0 * $::PANTACrm / $::PANTACdv)}]
} else { set ::PANTACrmdv "\[No Data\]"
}
}
#end ::PANTACnew_rm
}
set ::PANTACnew_vf {
proc ::PANTACnew_vf {args} {
if {[string is double -strict $::PANTACvf]} {
set ::PANTACvfdv [expr {round(100.0 * $::PANTACvf / $::PANTACdv)}]
} else { set ::PANTACvfdv "\[No Data\]"
}
}
#end ::PANTACnew_vf
}
set ::VITB6Adv_change {
proc ::VITB6Adv_change {args} {
if {$::VITB6Aopt == 0.0} {set newdv $::VITB6Adv_default} elseif { $::VITB6Aopt > 0.0} {set newdv $::VITB6Aopt} else {set newdv $::VITB6Aam}
if {$newdv == 0.0} {set newdv $::VITB6Adv_default}
if {$newdv != $::VITB6Adv} { set ::VITB6Adv $newdv }
if {[string is double -strict $::VITB6Aam]} {
set ::VITB6Aamdv [expr {round(100.0 * $::VITB6Aam / $::VITB6Adv)}]
} else { set ::VITB6Aamdv "\[No Data\]"
}
}
#end ::VITB6Adv_change
}
set ::VITB6Anew_dv {
proc ::VITB6Anew_dv {args} {
if {[string is double -strict $::VITB6Aam]} {
set ::VITB6Aamdv [expr {round(100.0 * $::VITB6Aam / $::VITB6Adv)}]
} else { set ::VITB6Aamdv "\[No Data\]"
}
if {[string is double -strict $::VITB6Arm]} {
set ::VITB6Armdv [expr {round(100.0 * $::VITB6Arm / $::VITB6Adv)}]
} else { set ::VITB6Armdv "\[No Data\]"
}
if {[string is double -strict $::VITB6Avf]} {
set ::VITB6Avfdv [expr {round(100.0 * $::VITB6Avf / $::VITB6Adv)}]
} else { set ::VITB6Avfdv "\[No Data\]"
}
}
#end ::VITB6Anew_dv
}
set ::VITB6Anew_rm {
proc ::VITB6Anew_rm {args} {
if {[string is double -strict $::VITB6Arm]} {
set ::VITB6Armdv [expr {round(100.0 * $::VITB6Arm / $::VITB6Adv)}]
} else { set ::VITB6Armdv "\[No Data\]"
}
}
#end ::VITB6Anew_rm
}
set ::VITB6Anew_vf {
proc ::VITB6Anew_vf {args} {
if {[string is double -strict $::VITB6Avf]} {
set ::VITB6Avfdv [expr {round(100.0 * $::VITB6Avf / $::VITB6Adv)}]
} else { set ::VITB6Avfdv "\[No Data\]"
}
}
#end ::VITB6Anew_vf
}
set ::FOLdv_change {
proc ::FOLdv_change {args} {
if {$::FOLopt == 0.0} {set newdv $::FOLdv_default} elseif { $::FOLopt > 0.0} {set newdv $::FOLopt} else {set newdv $::FOLam}
if {$newdv == 0.0} {set newdv $::FOLdv_default}
if {$newdv != $::FOLdv} { set ::FOLdv $newdv }
if {[string is double -strict $::FOLam]} {
set ::FOLamdv [expr {round(100.0 * $::FOLam / $::FOLdv)}]
} else { set ::FOLamdv "\[No Data\]"
}
}
#end ::FOLdv_change
}
set ::FOLnew_dv {
proc ::FOLnew_dv {args} {
if {[string is double -strict $::FOLam]} {
set ::FOLamdv [expr {round(100.0 * $::FOLam / $::FOLdv)}]
} else { set ::FOLamdv "\[No Data\]"
}
if {[string is double -strict $::FOLrm]} {
set ::FOLrmdv [expr {round(100.0 * $::FOLrm / $::FOLdv)}]
} else { set ::FOLrmdv "\[No Data\]"
}
if {[string is double -strict $::FOLvf]} {
set ::FOLvfdv [expr {round(100.0 * $::FOLvf / $::FOLdv)}]
} else { set ::FOLvfdv "\[No Data\]"
}
}
#end ::FOLnew_dv
}
set ::FOLnew_rm {
proc ::FOLnew_rm {args} {
if {[string is double -strict $::FOLrm]} {
set ::FOLrmdv [expr {round(100.0 * $::FOLrm / $::FOLdv)}]
} else { set ::FOLrmdv "\[No Data\]"
}
}
#end ::FOLnew_rm
}
set ::FOLnew_vf {
proc ::FOLnew_vf {args} {
if {[string is double -strict $::FOLvf]} {
set ::FOLvfdv [expr {round(100.0 * $::FOLvf / $::FOLdv)}]
} else { set ::FOLvfdv "\[No Data\]"
}
}
#end ::FOLnew_vf
}
set ::VITB12dv_change {
proc ::VITB12dv_change {args} {
if {$::VITB12opt == 0.0} {set newdv $::VITB12dv_default} elseif { $::VITB12opt > 0.0} {set newdv $::VITB12opt} else {set newdv $::VITB12am}
if {$newdv == 0.0} {set newdv $::VITB12dv_default}
if {$newdv != $::VITB12dv} { set ::VITB12dv $newdv }
if {[string is double -strict $::VITB12am]} {
set ::VITB12amdv [expr {round(100.0 * $::VITB12am / $::VITB12dv)}]
} else { set ::VITB12amdv "\[No Data\]"
}
}
#end ::VITB12dv_change
}
set ::VITB12new_dv {
proc ::VITB12new_dv {args} {
if {[string is double -strict $::VITB12am]} {
set ::VITB12amdv [expr {round(100.0 * $::VITB12am / $::VITB12dv)}]
} else { set ::VITB12amdv "\[No Data\]"
}
if {[string is double -strict $::VITB12rm]} {
set ::VITB12rmdv [expr {round(100.0 * $::VITB12rm / $::VITB12dv)}]
} else { set ::VITB12rmdv "\[No Data\]"
}
if {[string is double -strict $::VITB12vf]} {
set ::VITB12vfdv [expr {round(100.0 * $::VITB12vf / $::VITB12dv)}]
} else { set ::VITB12vfdv "\[No Data\]"
}
}
#end ::VITB12new_dv
}
set ::VITB12new_rm {
proc ::VITB12new_rm {args} {
if {[string is double -strict $::VITB12rm]} {
set ::VITB12rmdv [expr {round(100.0 * $::VITB12rm / $::VITB12dv)}]
} else { set ::VITB12rmdv "\[No Data\]"
}
}
#end ::VITB12new_rm
}
set ::VITB12new_vf {
proc ::VITB12new_vf {args} {
if {[string is double -strict $::VITB12vf]} {
set ::VITB12vfdv [expr {round(100.0 * $::VITB12vf / $::VITB12dv)}]
} else { set ::VITB12vfdv "\[No Data\]"
}
}
#end ::VITB12new_vf
}
set ::VITK1dv_change {
proc ::VITK1dv_change {args} {
if {$::VITK1opt == 0.0} {set newdv $::VITK1dv_default} elseif { $::VITK1opt > 0.0} {set newdv $::VITK1opt} else {set newdv $::VITK1am}
if {$newdv == 0.0} {set newdv $::VITK1dv_default}
if {$newdv != $::VITK1dv} { set ::VITK1dv $newdv }
if {[string is double -strict $::VITK1am]} {
set ::VITK1amdv [expr {round(100.0 * $::VITK1am / $::VITK1dv)}]
} else { set ::VITK1amdv "\[No Data\]"
}
}
#end ::VITK1dv_change
}
set ::VITK1new_dv {
proc ::VITK1new_dv {args} {
if {[string is double -strict $::VITK1am]} {
set ::VITK1amdv [expr {round(100.0 * $::VITK1am / $::VITK1dv)}]
} else { set ::VITK1amdv "\[No Data\]"
}
if {[string is double -strict $::VITK1rm]} {
set ::VITK1rmdv [expr {round(100.0 * $::VITK1rm / $::VITK1dv)}]
} else { set ::VITK1rmdv "\[No Data\]"
}
if {[string is double -strict $::VITK1vf]} {
set ::VITK1vfdv [expr {round(100.0 * $::VITK1vf / $::VITK1dv)}]
} else { set ::VITK1vfdv "\[No Data\]"
}
}
#end ::VITK1new_dv
}
set ::VITK1new_rm {
proc ::VITK1new_rm {args} {
if {[string is double -strict $::VITK1rm]} {
set ::VITK1rmdv [expr {round(100.0 * $::VITK1rm / $::VITK1dv)}]
} else { set ::VITK1rmdv "\[No Data\]"
}
}
#end ::VITK1new_rm
}
set ::VITK1new_vf {
proc ::VITK1new_vf {args} {
if {[string is double -strict $::VITK1vf]} {
set ::VITK1vfdv [expr {round(100.0 * $::VITK1vf / $::VITK1dv)}]
} else { set ::VITK1vfdv "\[No Data\]"
}
}
#end ::VITK1new_vf
}
set ::CHOLEdv_change {
proc ::CHOLEdv_change {args} {
if {$::CHOLEopt == 0.0} {set newdv $::CHOLEdv_default} elseif { $::CHOLEopt > 0.0} {set newdv $::CHOLEopt} else {set newdv $::CHOLEam}
if {$newdv == 0.0} {set newdv $::CHOLEdv_default}
if {$newdv != $::CHOLEdv} { set ::CHOLEdv $newdv }
if {[string is double -strict $::CHOLEam]} {
set ::CHOLEamdv [expr {round(100.0 * $::CHOLEam / $::CHOLEdv)}]
} else { set ::CHOLEamdv "\[No Data\]"
}
}
#end ::CHOLEdv_change
}
set ::CHOLEnew_dv {
proc ::CHOLEnew_dv {args} {
if {[string is double -strict $::CHOLEam]} {
set ::CHOLEamdv [expr {round(100.0 * $::CHOLEam / $::CHOLEdv)}]
} else { set ::CHOLEamdv "\[No Data\]"
}
if {[string is double -strict $::CHOLErm]} {
set ::CHOLErmdv [expr {round(100.0 * $::CHOLErm / $::CHOLEdv)}]
} else { set ::CHOLErmdv "\[No Data\]"
}
if {[string is double -strict $::CHOLEvf]} {
set ::CHOLEvfdv [expr {round(100.0 * $::CHOLEvf / $::CHOLEdv)}]
} else { set ::CHOLEvfdv "\[No Data\]"
}
}
#end ::CHOLEnew_dv
}
set ::CHOLEnew_rm {
proc ::CHOLEnew_rm {args} {
if {[string is double -strict $::CHOLErm]} {
set ::CHOLErmdv [expr {round(100.0 * $::CHOLErm / $::CHOLEdv)}]
} else { set ::CHOLErmdv "\[No Data\]"
}
}
#end ::CHOLEnew_rm
}
set ::CHOLEnew_vf {
proc ::CHOLEnew_vf {args} {
if {[string is double -strict $::CHOLEvf]} {
set ::CHOLEvfdv [expr {round(100.0 * $::CHOLEvf / $::CHOLEdv)}]
} else { set ::CHOLEvfdv "\[No Data\]"
}
}
#end ::CHOLEnew_vf
}
set ::FASATdv_change {
proc ::FASATdv_change {args} {
if {[string is double -strict $::FASATam]} {
set ::FASATamdv [expr {round(100.0 * $::FASATam / $::FASATdv)}]
} else { set ::FASATamdv "\[No Data\]"
}
}
#end ::FASATdv_change
}
set ::FASATnew_dv {
proc ::FASATnew_dv {args} {
if {[string is double -strict $::FASATam]} {
set ::FASATamdv [expr {round(100.0 * $::FASATam / $::FASATdv)}]
} else { set ::FASATamdv "\[No Data\]"
}
if {[string is double -strict $::FASATrm]} {
set ::FASATrmdv [expr {round(100.0 * $::FASATrm / $::FASATdv)}]
} else { set ::FASATrmdv "\[No Data\]"
}
if {[string is double -strict $::FASATvf]} {
set ::FASATvfdv [expr {round(100.0 * $::FASATvf / $::FASATdv)}]
} else { set ::FASATvfdv "\[No Data\]"
}
}
#end ::FASATnew_dv
}
set ::FASATnew_rm {
proc ::FASATnew_rm {args} {
if {[string is double -strict $::FASATrm]} {
set ::FASATrmdv [expr {round(100.0 * $::FASATrm / $::FASATdv)}]
} else { set ::FASATrmdv "\[No Data\]"
}
}
#end ::FASATnew_rm
}
set ::FASATnew_vf {
proc ::FASATnew_vf {args} {
if {[string is double -strict $::FASATvf]} {
set ::FASATvfdv [expr {round(100.0 * $::FASATvf / $::FASATdv)}]
} else { set ::FASATvfdv "\[No Data\]"
}
}
#end ::FASATnew_vf
}
set ::FAMSdv_change {
proc ::FAMSdv_change {args} {
if {[string is double -strict $::FAMSam]} {
set ::FAMSamdv [expr {round(100.0 * $::FAMSam / $::FAMSdv)}]
} else { set ::FAMSamdv "\[No Data\]"
}
}
#end ::FAMSdv_change
}
set ::FAMSnew_dv {
proc ::FAMSnew_dv {args} {
if {[string is double -strict $::FAMSam]} {
set ::FAMSamdv [expr {round(100.0 * $::FAMSam / $::FAMSdv)}]
} else { set ::FAMSamdv "\[No Data\]"
}
if {[string is double -strict $::FAMSrm]} {
set ::FAMSrmdv [expr {round(100.0 * $::FAMSrm / $::FAMSdv)}]
} else { set ::FAMSrmdv "\[No Data\]"
}
if {[string is double -strict $::FAMSvf]} {
set ::FAMSvfdv [expr {round(100.0 * $::FAMSvf / $::FAMSdv)}]
} else { set ::FAMSvfdv "\[No Data\]"
}
}
#end ::FAMSnew_dv
}
set ::FAMSnew_rm {
proc ::FAMSnew_rm {args} {
if {[string is double -strict $::FAMSrm]} {
set ::FAMSrmdv [expr {round(100.0 * $::FAMSrm / $::FAMSdv)}]
} else { set ::FAMSrmdv "\[No Data\]"
}
}
#end ::FAMSnew_rm
}
set ::FAMSnew_vf {
proc ::FAMSnew_vf {args} {
if {[string is double -strict $::FAMSvf]} {
set ::FAMSvfdv [expr {round(100.0 * $::FAMSvf / $::FAMSdv)}]
} else { set ::FAMSvfdv "\[No Data\]"
}
}
#end ::FAMSnew_vf
}
set ::FAPUdv_change {
proc ::FAPUdv_change {args} {
if {[string is double -strict $::FAPUam]} {
set ::FAPUamdv [expr {round(100.0 * $::FAPUam / $::FAPUdv)}]
} else { set ::FAPUamdv "\[No Data\]"
}
}
#end ::FAPUdv_change
}
set ::FAPUnew_dv {
proc ::FAPUnew_dv {args} {
if {[string is double -strict $::FAPUam]} {
set ::FAPUamdv [expr {round(100.0 * $::FAPUam / $::FAPUdv)}]
} else { set ::FAPUamdv "\[No Data\]"
}
if {[string is double -strict $::FAPUrm]} {
set ::FAPUrmdv [expr {round(100.0 * $::FAPUrm / $::FAPUdv)}]
} else { set ::FAPUrmdv "\[No Data\]"
}
if {[string is double -strict $::FAPUvf]} {
set ::FAPUvfdv [expr {round(100.0 * $::FAPUvf / $::FAPUdv)}]
} else { set ::FAPUvfdv "\[No Data\]"
}
}
#end ::FAPUnew_dv
}
set ::FAPUnew_rm {
proc ::FAPUnew_rm {args} {
if {[string is double -strict $::FAPUrm]} {
set ::FAPUrmdv [expr {round(100.0 * $::FAPUrm / $::FAPUdv)}]
} else { set ::FAPUrmdv "\[No Data\]"
}
}
#end ::FAPUnew_rm
}
set ::FAPUnew_vf {
proc ::FAPUnew_vf {args} {
if {[string is double -strict $::FAPUvf]} {
set ::FAPUvfdv [expr {round(100.0 * $::FAPUvf / $::FAPUdv)}]
} else { set ::FAPUvfdv "\[No Data\]"
}
}
#end ::FAPUnew_vf
}
set ::CHO_NONFIBdv_change {
proc ::CHO_NONFIBdv_change {args} {
if {[string is double -strict $::CHO_NONFIBam]} {
set ::CHO_NONFIBamdv [expr {round(100.0 * $::CHO_NONFIBam / $::CHO_NONFIBdv)}]
set ::CHO_NONFIBam1 [expr {round($::CHO_NONFIBam)}]
} else {
set ::CHO_NONFIBamdv "\[No Data\]"
set ::CHO_NONFIBam1 "\[No Data\]"
}
}
#end ::CHO_NONFIBdv_change
}
set ::CHO_NONFIBnew_dv {
proc ::CHO_NONFIBnew_dv {args} {
if {[string is double -strict $::CHO_NONFIBam]} {
set ::CHO_NONFIBamdv [expr {round(100.0 * $::CHO_NONFIBam / $::CHO_NONFIBdv)}]
} else { set ::CHO_NONFIBamdv "\[No Data\]"
}
if {[string is double -strict $::CHO_NONFIBrm]} {
set ::CHO_NONFIBrmdv [expr {round(100.0 * $::CHO_NONFIBrm / $::CHO_NONFIBdv)}]
} else { set ::CHO_NONFIBrmdv "\[No Data\]"
}
if {[string is double -strict $::CHO_NONFIBvf]} {
set ::CHO_NONFIBvfdv [expr {round(100.0 * $::CHO_NONFIBvf / $::CHO_NONFIBdv)}]
} else { set ::CHO_NONFIBvfdv "\[No Data\]"
}
}
#end ::CHO_NONFIBnew_dv
}
set ::CHO_NONFIBnew_rm {
proc ::CHO_NONFIBnew_rm {args} {
if {[string is double -strict $::CHO_NONFIBrm]} {
set ::CHO_NONFIBrmdv [expr {round(100.0 * $::CHO_NONFIBrm / $::CHO_NONFIBdv)}]
set ::CHO_NONFIBrm1 [expr {round($::CHO_NONFIBrm)}]
} else {
set ::CHO_NONFIBrmdv "\[No Data\]"
set ::CHO_NONFIBrm1 "\[No Data\]"
}
}
#end ::CHO_NONFIBnew_rm
}
set ::CHO_NONFIBnew_vf {
proc ::CHO_NONFIBnew_vf {args} {
if {[string is double -strict $::CHO_NONFIBvf]} {
set ::CHO_NONFIBvfdv [expr {round(100.0 * $::CHO_NONFIBvf / $::CHO_NONFIBdv)}]
set ::CHO_NONFIBvf1 [expr {round($::CHO_NONFIBvf)}]
} else {
set ::CHO_NONFIBvfdv "\[No Data\]"
set ::CHO_NONFIBvf1 "\[No Data\]"
}
}
#end ::CHO_NONFIBnew_vf
}
set ::LAdv_change {
proc ::LAdv_change {args} {
if {[string is double -strict $::LAam]} {
set ::LAamdv [expr {round(100.0 * $::LAam / $::LAdv)}]
} else { set ::LAamdv "\[No Data\]"
}
}
#end ::LAdv_change
}
set ::LAnew_dv {
proc ::LAnew_dv {args} {
if {[string is double -strict $::LAam]} {
set ::LAamdv [expr {round(100.0 * $::LAam / $::LAdv)}]
} else { set ::LAamdv "\[No Data\]"
}
if {[string is double -strict $::LArm]} {
set ::LArmdv [expr {round(100.0 * $::LArm / $::LAdv)}]
} else { set ::LArmdv "\[No Data\]"
}
if {[string is double -strict $::LAvf]} {
set ::LAvfdv [expr {round(100.0 * $::LAvf / $::LAdv)}]
} else { set ::LAvfdv "\[No Data\]"
}
}
#end ::LAnew_dv
}
set ::LAnew_rm {
proc ::LAnew_rm {args} {
if {[string is double -strict $::LArm]} {
set ::LArmdv [expr {round(100.0 * $::LArm / $::LAdv)}]
} else { set ::LArmdv "\[No Data\]"
}
}
#end ::LAnew_rm
}
set ::LAnew_vf {
proc ::LAnew_vf {args} {
if {[string is double -strict $::LAvf]} {
set ::LAvfdv [expr {round(100.0 * $::LAvf / $::LAdv)}]
} else { set ::LAvfdv "\[No Data\]"
}
}
#end ::LAnew_vf
}
set ::AAdv_change {
proc ::AAdv_change {args} {
if {[string is double -strict $::AAam]} {
set ::AAamdv [expr {round(100.0 * $::AAam / $::AAdv)}]
} else { set ::AAamdv "\[No Data\]"
}
}
#end ::AAdv_change
}
set ::AAnew_dv {
proc ::AAnew_dv {args} {
if {[string is double -strict $::AAam]} {
set ::AAamdv [expr {round(100.0 * $::AAam / $::AAdv)}]
} else { set ::AAamdv "\[No Data\]"
}
if {[string is double -strict $::AArm]} {
set ::AArmdv [expr {round(100.0 * $::AArm / $::AAdv)}]
} else { set ::AArmdv "\[No Data\]"
}
if {[string is double -strict $::AAvf]} {
set ::AAvfdv [expr {round(100.0 * $::AAvf / $::AAdv)}]
} else { set ::AAvfdv "\[No Data\]"
}
}
#end ::AAnew_dv
}
set ::AAnew_rm {
proc ::AAnew_rm {args} {
if {[string is double -strict $::AArm]} {
set ::AArmdv [expr {round(100.0 * $::AArm / $::AAdv)}]
} else { set ::AArmdv "\[No Data\]"
}
}
#end ::AAnew_rm
}
set ::AAnew_vf {
proc ::AAnew_vf {args} {
if {[string is double -strict $::AAvf]} {
set ::AAvfdv [expr {round(100.0 * $::AAvf / $::AAdv)}]
} else { set ::AAvfdv "\[No Data\]"
}
}
#end ::AAnew_vf
}
set ::ALAdv_change {
proc ::ALAdv_change {args} {
if {[string is double -strict $::ALAam]} {
set ::ALAamdv [expr {round(100.0 * $::ALAam / $::ALAdv)}]
} else { set ::ALAamdv "\[No Data\]"
}
}
#end ::ALAdv_change
}
set ::ALAnew_dv {
proc ::ALAnew_dv {args} {
if {[string is double -strict $::ALAam]} {
set ::ALAamdv [expr {round(100.0 * $::ALAam / $::ALAdv)}]
} else { set ::ALAamdv "\[No Data\]"
}
if {[string is double -strict $::ALArm]} {
set ::ALArmdv [expr {round(100.0 * $::ALArm / $::ALAdv)}]
} else { set ::ALArmdv "\[No Data\]"
}
if {[string is double -strict $::ALAvf]} {
set ::ALAvfdv [expr {round(100.0 * $::ALAvf / $::ALAdv)}]
} else { set ::ALAvfdv "\[No Data\]"
}
}
#end ::ALAnew_dv
}
set ::ALAnew_rm {
proc ::ALAnew_rm {args} {
if {[string is double -strict $::ALArm]} {
set ::ALArmdv [expr {round(100.0 * $::ALArm / $::ALAdv)}]
} else { set ::ALArmdv "\[No Data\]"
}
}
#end ::ALAnew_rm
}
set ::ALAnew_vf {
proc ::ALAnew_vf {args} {
if {[string is double -strict $::ALAvf]} {
set ::ALAvfdv [expr {round(100.0 * $::ALAvf / $::ALAdv)}]
} else { set ::ALAvfdv "\[No Data\]"
}
}
#end ::ALAnew_vf
}
set ::EPAdv_change {
proc ::EPAdv_change {args} {
if {[string is double -strict $::EPAam]} {
set ::EPAamdv [expr {round(100.0 * $::EPAam / $::EPAdv)}]
} else { set ::EPAamdv "\[No Data\]"
}
}
#end ::EPAdv_change
}
set ::EPAnew_dv {
proc ::EPAnew_dv {args} {
if {[string is double -strict $::EPAam]} {
set ::EPAamdv [expr {round(100.0 * $::EPAam / $::EPAdv)}]
} else { set ::EPAamdv "\[No Data\]"
}
if {[string is double -strict $::EPArm]} {
set ::EPArmdv [expr {round(100.0 * $::EPArm / $::EPAdv)}]
} else { set ::EPArmdv "\[No Data\]"
}
if {[string is double -strict $::EPAvf]} {
set ::EPAvfdv [expr {round(100.0 * $::EPAvf / $::EPAdv)}]
} else { set ::EPAvfdv "\[No Data\]"
}
}
#end ::EPAnew_dv
}
set ::EPAnew_rm {
proc ::EPAnew_rm {args} {
if {[string is double -strict $::EPArm]} {
set ::EPArmdv [expr {round(100.0 * $::EPArm / $::EPAdv)}]
} else { set ::EPArmdv "\[No Data\]"
}
}
#end ::EPAnew_rm
}
set ::EPAnew_vf {
proc ::EPAnew_vf {args} {
if {[string is double -strict $::EPAvf]} {
set ::EPAvfdv [expr {round(100.0 * $::EPAvf / $::EPAdv)}]
} else { set ::EPAvfdv "\[No Data\]"
}
}
#end ::EPAnew_vf
}
set ::DHAdv_change {
proc ::DHAdv_change {args} {
if {[string is double -strict $::DHAam]} {
set ::DHAamdv [expr {round(100.0 * $::DHAam / $::DHAdv)}]
} else { set ::DHAamdv "\[No Data\]"
}
}
#end ::DHAdv_change
}
set ::DHAnew_dv {
proc ::DHAnew_dv {args} {
if {[string is double -strict $::DHAam]} {
set ::DHAamdv [expr {round(100.0 * $::DHAam / $::DHAdv)}]
} else { set ::DHAamdv "\[No Data\]"
}
if {[string is double -strict $::DHArm]} {
set ::DHArmdv [expr {round(100.0 * $::DHArm / $::DHAdv)}]
} else { set ::DHArmdv "\[No Data\]"
}
if {[string is double -strict $::DHAvf]} {
set ::DHAvfdv [expr {round(100.0 * $::DHAvf / $::DHAdv)}]
} else { set ::DHAvfdv "\[No Data\]"
}
}
#end ::DHAnew_dv
}
set ::DHAnew_rm {
proc ::DHAnew_rm {args} {
if {[string is double -strict $::DHArm]} {
set ::DHArmdv [expr {round(100.0 * $::DHArm / $::DHAdv)}]
} else { set ::DHArmdv "\[No Data\]"
}
}
#end ::DHAnew_rm
}
set ::DHAnew_vf {
proc ::DHAnew_vf {args} {
if {[string is double -strict $::DHAvf]} {
set ::DHAvfdv [expr {round(100.0 * $::DHAvf / $::DHAdv)}]
} else { set ::DHAvfdv "\[No Data\]"
}
}
#end ::DHAnew_vf
}
set ::OMEGA6dv_change {
proc ::OMEGA6dv_change {args} {
if {[string is double -strict $::OMEGA6am]} {
set ::OMEGA6amdv [expr {round(100.0 * $::OMEGA6am / $::OMEGA6dv)}]
} else { set ::OMEGA6amdv "\[No Data\]"
}
}
#end ::OMEGA6dv_change
}
set ::OMEGA6new_dv {
proc ::OMEGA6new_dv {args} {
if {[string is double -strict $::OMEGA6am]} {
set ::OMEGA6amdv [expr {round(100.0 * $::OMEGA6am / $::OMEGA6dv)}]
} else { set ::OMEGA6amdv "\[No Data\]"
}
if {[string is double -strict $::OMEGA6rm]} {
set ::OMEGA6rmdv [expr {round(100.0 * $::OMEGA6rm / $::OMEGA6dv)}]
} else { set ::OMEGA6rmdv "\[No Data\]"
}
if {[string is double -strict $::OMEGA6vf]} {
set ::OMEGA6vfdv [expr {round(100.0 * $::OMEGA6vf / $::OMEGA6dv)}]
} else { set ::OMEGA6vfdv "\[No Data\]"
}
}
#end ::OMEGA6new_dv
}
set ::OMEGA6new_rm {
proc ::OMEGA6new_rm {args} {
if {[string is double -strict $::OMEGA6rm]} {
set ::OMEGA6rmdv [expr {round(100.0 * $::OMEGA6rm / $::OMEGA6dv)}]
} else { set ::OMEGA6rmdv "\[No Data\]"
}
}
#end ::OMEGA6new_rm
}
set ::OMEGA6new_vf {
proc ::OMEGA6new_vf {args} {
if {[string is double -strict $::OMEGA6vf]} {
set ::OMEGA6vfdv [expr {round(100.0 * $::OMEGA6vf / $::OMEGA6dv)}]
} else { set ::OMEGA6vfdv "\[No Data\]"
}
}
#end ::OMEGA6new_vf
}
set ::OMEGA3dv_change {
proc ::OMEGA3dv_change {args} {
if {[string is double -strict $::OMEGA3am]} {
set ::OMEGA3amdv [expr {round(100.0 * $::OMEGA3am / $::OMEGA3dv)}]
} else { set ::OMEGA3amdv "\[No Data\]"
}
}
#end ::OMEGA3dv_change
}
set ::OMEGA3new_dv {
proc ::OMEGA3new_dv {args} {
if {[string is double -strict $::OMEGA3am]} {
set ::OMEGA3amdv [expr {round(100.0 * $::OMEGA3am / $::OMEGA3dv)}]
} else { set ::OMEGA3amdv "\[No Data\]"
}
if {[string is double -strict $::OMEGA3rm]} {
set ::OMEGA3rmdv [expr {round(100.0 * $::OMEGA3rm / $::OMEGA3dv)}]
} else { set ::OMEGA3rmdv "\[No Data\]"
}
if {[string is double -strict $::OMEGA3vf]} {
set ::OMEGA3vfdv [expr {round(100.0 * $::OMEGA3vf / $::OMEGA3dv)}]
} else { set ::OMEGA3vfdv "\[No Data\]"
}
}
#end ::OMEGA3new_dv
}
set ::OMEGA3new_rm {
proc ::OMEGA3new_rm {args} {
if {[string is double -strict $::OMEGA3rm]} {
set ::OMEGA3rmdv [expr {round(100.0 * $::OMEGA3rm / $::OMEGA3dv)}]
} else { set ::OMEGA3rmdv "\[No Data\]"
}
}
#end ::OMEGA3new_rm
}
set ::OMEGA3new_vf {
proc ::OMEGA3new_vf {args} {
if {[string is double -strict $::OMEGA3vf]} {
set ::OMEGA3vfdv [expr {round(100.0 * $::OMEGA3vf / $::OMEGA3dv)}]
} else { set ::OMEGA3vfdv "\[No Data\]"
}
}
#end ::OMEGA3new_vf
}
set ::VITEdv_change {
proc ::VITEdv_change {args} {
if {$::VITEopt == 0.0} {set newdv $::VITEdv_default} elseif { $::VITEopt > 0.0} {set newdv $::VITEopt} else {set newdv $::VITEam}
if {$newdv == 0.0} {set newdv $::VITEdv_default}
if {$newdv != $::VITEdv} { set ::VITEdv $newdv }
if {[string is double -strict $::VITEam]} {
set ::VITEamdv [expr {round(100.0 * $::VITEam / $::VITEdv)}]
} else { set ::VITEamdv "\[No Data\]"
}
}
#end ::VITEdv_change
}
set ::VITEnew_dv {
proc ::VITEnew_dv {args} {
if {[string is double -strict $::VITEam]} {
set ::VITEamdv [expr {round(100.0 * $::VITEam / $::VITEdv)}]
} else { set ::VITEamdv "\[No Data\]"
}
if {[string is double -strict $::VITErm]} {
set ::VITErmdv [expr {round(100.0 * $::VITErm / $::VITEdv)}]
} else { set ::VITErmdv "\[No Data\]"
}
if {[string is double -strict $::VITEvf]} {
set ::VITEvfdv [expr {round(100.0 * $::VITEvf / $::VITEdv)}]
} else { set ::VITEvfdv "\[No Data\]"
}
}
#end ::VITEnew_dv
}
set ::VITEnew_rm {
proc ::VITEnew_rm {args} {
if {[string is double -strict $::VITErm]} {
set ::VITErmdv [expr {round(100.0 * $::VITErm / $::VITEdv)}]
} else { set ::VITErmdv "\[No Data\]"
}
}
#end ::VITEnew_rm
}
set ::VITEnew_vf {
proc ::VITEnew_vf {args} {
if {[string is double -strict $::VITEvf]} {
set ::VITEvfdv [expr {round(100.0 * $::VITEvf / $::VITEdv)}]
} else { set ::VITEvfdv "\[No Data\]"
}
}
#end ::VITEnew_vf
}
set ::GLY_Gdv_change {
proc ::GLY_Gdv_change {args} {
}
#end ::GLY_Gdv_change
}
set ::GLY_Gnew_dv {
proc ::GLY_Gnew_dv {args} {
}
#end ::GLY_Gnew_dv
}
set ::GLY_Gnew_rm {
proc ::GLY_Gnew_rm {args} {
}
#end ::GLY_Gnew_rm
}
set ::GLY_Gnew_vf {
proc ::GLY_Gnew_vf {args} {
}
#end ::GLY_Gnew_vf
}
set ::RETOLdv_change {
proc ::RETOLdv_change {args} {
}
#end ::RETOLdv_change
}
set ::RETOLnew_dv {
proc ::RETOLnew_dv {args} {
}
#end ::RETOLnew_dv
}
set ::RETOLnew_rm {
proc ::RETOLnew_rm {args} {
}
#end ::RETOLnew_rm
}
set ::RETOLnew_vf {
proc ::RETOLnew_vf {args} {
}
#end ::RETOLnew_vf
}
set load_nutr_def {
proc load_nutr_def {args} {
dbmem eval {create temp table ttnutr_def( Nutr_No text, Units text, Tagname text, NutrDesc text, Num_Dec text, SR_Order int)}
dbmem eval {create temp table tnutr_def( Nutr_No int, Units text, Tagname text, NutrDesc text, Num_Dec text, SR_Order int)}
dbmem eval {create table if not exists nutr_def( Nutr_No int primary key, Units text, Tagname text, NutrDesc text, dv_default real, nutopt real)}
dbmem copy fail ttnutr_def NUTR_DEF.txt "^" ""
dbmem eval {BEGIN}
dbmem eval {insert into tnutr_def select trim(Nutr_No, "~"), trim(Units, "~"), trim(Tagname, "~"), trim(NutrDesc, "~"), NULL, NULL from ttnutr_def}
dbmem eval {update tnutr_def set Tagname = 'ADPROT' where Nutr_No = 257}
dbmem eval {update tnutr_def set Tagname = 'VITD_BOTH' where Nutr_No = 328}
dbmem eval {update tnutr_def set Tagname = 'LUT_ZEA' where Nutr_No = 338}
dbmem eval {update tnutr_def set Tagname = 'VITE_ADDED' where Nutr_No = 573}
dbmem eval {update tnutr_def set Tagname = 'VITB12_ADDED' where Nutr_No = 578}
dbmem eval {update tnutr_def set Tagname = 'F22D1T' where Nutr_No = 664}
dbmem eval {update tnutr_def set Tagname = 'F18D2T' where Nutr_No = 665}
dbmem eval {update tnutr_def set Tagname = 'F18D2I' where Nutr_No = 666}
dbmem eval {update tnutr_def set Tagname = 'F22D1C' where Nutr_No = 676}
dbmem eval {update tnutr_def set Tagname = 'F18D3I' where Nutr_No = 856}
dbmem eval {update tnutr_def set Units = 'mcg' where hex(Units) = 'B567'}
dbmem eval {update tnutr_def set Units = 'kc' where Nutr_No = 208}
dbmem eval {update tnutr_def set NutrDesc = 'Protein' where Nutr_No = 203}
dbmem eval {update tnutr_def set NutrDesc = 'Total Fat' where Nutr_No = 204}
dbmem eval {update tnutr_def set NutrDesc = 'Total Carb' where Nutr_No = 205}
dbmem eval {update tnutr_def set NutrDesc = 'Ash' where Nutr_No = 207}
dbmem eval {update tnutr_def set NutrDesc = 'Calories' where Nutr_No = 208}
dbmem eval {update tnutr_def set NutrDesc = 'Starch' where Nutr_No = 209}
dbmem eval {update tnutr_def set NutrDesc = 'Sucrose' where Nutr_No = 210}
dbmem eval {update tnutr_def set NutrDesc = 'Glucose' where Nutr_No = 211}
dbmem eval {update tnutr_def set NutrDesc = 'Fructose' where Nutr_No = 212}
dbmem eval {update tnutr_def set NutrDesc = 'Lactose' where Nutr_No = 213}
dbmem eval {update tnutr_def set NutrDesc = 'Maltose' where Nutr_No = 214}
dbmem eval {update tnutr_def set NutrDesc = 'Ethyl Alcohol' where Nutr_No = 221}
dbmem eval {update tnutr_def set NutrDesc = 'Water' where Nutr_No = 255}
dbmem eval {update tnutr_def set NutrDesc = 'Adj. Protein' where Nutr_No = 257}
dbmem eval {update tnutr_def set NutrDesc = 'Caffeine' where Nutr_No = 262}
dbmem eval {update tnutr_def set NutrDesc = 'Theobromine' where Nutr_No = 263}
dbmem eval {update tnutr_def set NutrDesc = 'Sugars' where Nutr_No = 269}
dbmem eval {update tnutr_def set NutrDesc = 'Galactose' where Nutr_No = 287}
dbmem eval {update tnutr_def set NutrDesc = 'Fiber' where Nutr_No = 291}
dbmem eval {update tnutr_def set NutrDesc = 'Calcium' where Nutr_No = 301}
dbmem eval {update tnutr_def set NutrDesc = 'Iron' where Nutr_No = 303}
dbmem eval {update tnutr_def set NutrDesc = 'Magnesium' where Nutr_No = 304}
dbmem eval {update tnutr_def set NutrDesc = 'Phosphorus' where Nutr_No = 305}
dbmem eval {update tnutr_def set NutrDesc = 'Potassium' where Nutr_No = 306}
dbmem eval {update tnutr_def set NutrDesc = 'Sodium' where Nutr_No = 307}
dbmem eval {update tnutr_def set NutrDesc = 'Zinc' where Nutr_No = 309}
dbmem eval {update tnutr_def set NutrDesc = 'Copper' where Nutr_No = 312}
dbmem eval {update tnutr_def set NutrDesc = 'Fluoride' where Nutr_No = 313}
dbmem eval {update tnutr_def set NutrDesc = 'Manganese' where Nutr_No = 315}
dbmem eval {update tnutr_def set NutrDesc = 'Selenium' where Nutr_No = 317}
dbmem eval {update tnutr_def set NutrDesc = 'Vitamin A' where Nutr_No = 318}
dbmem eval {update tnutr_def set NutrDesc = 'Retinol' where Nutr_No = 319}
dbmem eval {update tnutr_def set NutrDesc = 'Vit. A, RAE' where Nutr_No = 320}
dbmem eval {update tnutr_def set NutrDesc = 'B-Carotene' where Nutr_No = 321}
dbmem eval {update tnutr_def set NutrDesc = 'A-Carotene' where Nutr_No = 322}
dbmem eval {update tnutr_def set NutrDesc = 'A-Tocopherol' where Nutr_No = 323}
dbmem eval {update tnutr_def set NutrDesc = 'Vitamin D' where Nutr_No = 324}
dbmem eval {update tnutr_def set NutrDesc = 'Vitamin D2' where Nutr_No = 325}
dbmem eval {update tnutr_def set NutrDesc = 'Vitamin D3' where Nutr_No = 326}
dbmem eval {update tnutr_def set NutrDesc = 'Vitamin D2+D3' where Nutr_No = 328}
dbmem eval {update tnutr_def set NutrDesc = 'B-Cryptoxanth.' where Nutr_No = 334}
dbmem eval {update tnutr_def set NutrDesc = 'Lycopene' where Nutr_No = 337}
dbmem eval {update tnutr_def set NutrDesc = 'Lutein+Zeaxan.' where Nutr_No = 338}
dbmem eval {update tnutr_def set NutrDesc = 'B-Tocopherol' where Nutr_No = 341}
dbmem eval {update tnutr_def set NutrDesc = 'G-Tocopherol' where Nutr_No = 342}
dbmem eval {update tnutr_def set NutrDesc = 'D-Tocopherol' where Nutr_No = 343}
dbmem eval {update tnutr_def set NutrDesc = 'A-Tocotrienol' where Nutr_No = 344}
dbmem eval {update tnutr_def set NutrDesc = 'B-Tocotrienol' where Nutr_No = 345}
dbmem eval {update tnutr_def set NutrDesc = 'G-Tocotrienol' where Nutr_No = 346}
dbmem eval {update tnutr_def set NutrDesc = 'D-Tocotrienol' where Nutr_No = 347}
dbmem eval {update tnutr_def set NutrDesc = 'Vitamin C' where Nutr_No = 401}
dbmem eval {update tnutr_def set NutrDesc = 'Thiamin' where Nutr_No = 404}
dbmem eval {update tnutr_def set NutrDesc = 'Riboflavin' where Nutr_No = 405}
dbmem eval {update tnutr_def set NutrDesc = 'Niacin' where Nutr_No = 406}
dbmem eval {update tnutr_def set NutrDesc = 'Panto. Acid' where Nutr_No = 410}
dbmem eval {update tnutr_def set NutrDesc = 'Vitamin B6' where Nutr_No = 415}
dbmem eval {update tnutr_def set NutrDesc = 'Folate' where Nutr_No = 417}
dbmem eval {update tnutr_def set NutrDesc = 'Vitamin B12' where Nutr_No = 418}
dbmem eval {update tnutr_def set NutrDesc = 'Choline' where Nutr_No = 421}
dbmem eval {update tnutr_def set NutrDesc = 'Menaquinone-4' where Nutr_No = 428}
dbmem eval {update tnutr_def set NutrDesc = 'Dihydro-K1' where Nutr_No = 429}
dbmem eval {update tnutr_def set NutrDesc = 'Vitamin K1' where Nutr_No = 430}
dbmem eval {update tnutr_def set NutrDesc = 'Folic Acid' where Nutr_No = 431}
dbmem eval {update tnutr_def set NutrDesc = 'Folate, food' where Nutr_No = 432}
dbmem eval {update tnutr_def set NutrDesc = 'Folate, DFE' where Nutr_No = 435}
dbmem eval {update tnutr_def set NutrDesc = 'Betaine' where Nutr_No = 454}
dbmem eval {update tnutr_def set NutrDesc = 'Tryptophan' where Nutr_No = 501}
dbmem eval {update tnutr_def set NutrDesc = 'Threonine' where Nutr_No = 502}
dbmem eval {update tnutr_def set NutrDesc = 'Isoleucine' where Nutr_No = 503}
dbmem eval {update tnutr_def set NutrDesc = 'Leucine' where Nutr_No = 504}
dbmem eval {update tnutr_def set NutrDesc = 'Lysine' where Nutr_No = 505}
dbmem eval {update tnutr_def set NutrDesc = 'Methionine' where Nutr_No = 506}
dbmem eval {update tnutr_def set NutrDesc = 'Cystine' where Nutr_No = 507}
dbmem eval {update tnutr_def set NutrDesc = 'Phenylalanine' where Nutr_No = 508}
dbmem eval {update tnutr_def set NutrDesc = 'Tyrosine' where Nutr_No = 509}
dbmem eval {update tnutr_def set NutrDesc = 'Valine' where Nutr_No = 510}
dbmem eval {update tnutr_def set NutrDesc = 'Arginine' where Nutr_No = 511}
dbmem eval {update tnutr_def set NutrDesc = 'Histidine' where Nutr_No = 512}
dbmem eval {update tnutr_def set NutrDesc = 'Alanine' where Nutr_No = 513}
dbmem eval {update tnutr_def set NutrDesc = 'Aspartic acid' where Nutr_No = 514}
dbmem eval {update tnutr_def set NutrDesc = 'Glutamic acid' where Nutr_No = 515}
dbmem eval {update tnutr_def set NutrDesc = 'Glycine' where Nutr_No = 516}
dbmem eval {update tnutr_def set NutrDesc = 'Proline' where Nutr_No = 517}
dbmem eval {update tnutr_def set NutrDesc = 'Serine' where Nutr_No = 518}
dbmem eval {update tnutr_def set NutrDesc = 'Hydroxyproline' where Nutr_No = 521}
dbmem eval {update tnutr_def set NutrDesc = 'Vit. E added' where Nutr_No = 573}
dbmem eval {update tnutr_def set NutrDesc = 'Vit. B12 added' where Nutr_No = 578}
dbmem eval {update tnutr_def set NutrDesc = 'Cholesterol' where Nutr_No = 601}
dbmem eval {update tnutr_def set NutrDesc = 'Trans Fat' where Nutr_No = 605}
dbmem eval {update tnutr_def set NutrDesc = 'Sat Fat' where Nutr_No = 606}
dbmem eval {update tnutr_def set NutrDesc = '4:0' where Nutr_No = 607}
dbmem eval {update tnutr_def set NutrDesc = '6:0' where Nutr_No = 608}
dbmem eval {update tnutr_def set NutrDesc = '8:0' where Nutr_No = 609}
dbmem eval {update tnutr_def set NutrDesc = '10:0' where Nutr_No = 610}
dbmem eval {update tnutr_def set NutrDesc = '12:0' where Nutr_No = 611}
dbmem eval {update tnutr_def set NutrDesc = '14:0' where Nutr_No = 612}
dbmem eval {update tnutr_def set NutrDesc = '16:0' where Nutr_No = 613}
dbmem eval {update tnutr_def set NutrDesc = '18:0' where Nutr_No = 614}
dbmem eval {update tnutr_def set NutrDesc = '20:0' where Nutr_No = 615}
dbmem eval {update tnutr_def set NutrDesc = '18:1' where Nutr_No = 617}
dbmem eval {update tnutr_def set NutrDesc = '18:2' where Nutr_No = 618}
dbmem eval {update tnutr_def set NutrDesc = '18:3' where Nutr_No = 619}
dbmem eval {update tnutr_def set NutrDesc = '20:4' where Nutr_No = 620}
dbmem eval {update tnutr_def set NutrDesc = '22:6n-3' where Nutr_No = 621}
dbmem eval {update tnutr_def set NutrDesc = '22:0' where Nutr_No = 624}
dbmem eval {update tnutr_def set NutrDesc = '14:1' where Nutr_No = 625}
dbmem eval {update tnutr_def set NutrDesc = '16:1' where Nutr_No = 626}
dbmem eval {update tnutr_def set NutrDesc = '18:4' where Nutr_No = 627}
dbmem eval {update tnutr_def set NutrDesc = '20:1' where Nutr_No = 628}
dbmem eval {update tnutr_def set NutrDesc = '20:5n-3' where Nutr_No = 629}
dbmem eval {update tnutr_def set NutrDesc = '22:1' where Nutr_No = 630}
dbmem eval {update tnutr_def set NutrDesc = '22:5n-3' where Nutr_No = 631}
dbmem eval {update tnutr_def set NutrDesc = 'Phytosterols' where Nutr_No = 636}
dbmem eval {update tnutr_def set NutrDesc = 'Stigmasterol' where Nutr_No = 638}
dbmem eval {update tnutr_def set NutrDesc = 'Campesterol' where Nutr_No = 639}
dbmem eval {update tnutr_def set NutrDesc = 'BetaSitosterol' where Nutr_No = 641}
dbmem eval {update tnutr_def set NutrDesc = 'Mono Fat' where Nutr_No = 645}
dbmem eval {update tnutr_def set NutrDesc = 'Poly Fat' where Nutr_No = 646}
dbmem eval {update tnutr_def set NutrDesc = '15:0' where Nutr_No = 652}
dbmem eval {update tnutr_def set NutrDesc = '17:0' where Nutr_No = 653}
dbmem eval {update tnutr_def set NutrDesc = '24:0' where Nutr_No = 654}
dbmem eval {update tnutr_def set NutrDesc = '16:1t' where Nutr_No = 662}
dbmem eval {update tnutr_def set NutrDesc = '18:1t' where Nutr_No = 663}
dbmem eval {update tnutr_def set NutrDesc = '22:1t' where Nutr_No = 664}
dbmem eval {update tnutr_def set NutrDesc = '18:2t' where Nutr_No = 665}
dbmem eval {update tnutr_def set NutrDesc = '18:2i' where Nutr_No = 666}
dbmem eval {update tnutr_def set NutrDesc = '18:2t,t' where Nutr_No = 669}
dbmem eval {update tnutr_def set NutrDesc = '18:2CLA' where Nutr_No = 670}
dbmem eval {update tnutr_def set NutrDesc = '24:1c' where Nutr_No = 671}
dbmem eval {update tnutr_def set NutrDesc = '20:2n-6c,c' where Nutr_No = 672}
dbmem eval {update tnutr_def set NutrDesc = '16:1c' where Nutr_No = 673}
dbmem eval {update tnutr_def set NutrDesc = '18:1c' where Nutr_No = 674}
dbmem eval {update tnutr_def set NutrDesc = '18:2n-6c,c' where Nutr_No = 675}
dbmem eval {update tnutr_def set NutrDesc = '22:1c' where Nutr_No = 676}
dbmem eval {update tnutr_def set NutrDesc = '18:3n-6c,c,c' where Nutr_No = 685}
dbmem eval {update tnutr_def set NutrDesc = '17:1' where Nutr_No = 687}
dbmem eval {update tnutr_def set NutrDesc = '20:3' where Nutr_No = 689}
dbmem eval {update tnutr_def set NutrDesc = 'TransMonoenoic' where Nutr_No = 693}
dbmem eval {update tnutr_def set NutrDesc = 'TransPolyenoic' where Nutr_No = 695}
dbmem eval {update tnutr_def set NutrDesc = '13:0' where Nutr_No = 696}
dbmem eval {update tnutr_def set NutrDesc = '15:1' where Nutr_No = 697}
dbmem eval {update tnutr_def set NutrDesc = '18:3n-3c,c,c' where Nutr_No = 851}
dbmem eval {update tnutr_def set NutrDesc = '20:3n-3' where Nutr_No = 852}
dbmem eval {update tnutr_def set NutrDesc = '20:3n-6' where Nutr_No = 853}
dbmem eval {update tnutr_def set NutrDesc = '20:4n-6' where Nutr_No = 855}
dbmem eval {update tnutr_def set NutrDesc = '18:3i' where Nutr_No = 856}
dbmem eval {update tnutr_def set NutrDesc = '21:5' where Nutr_No = 857}
dbmem eval {update tnutr_def set NutrDesc = '22:4' where Nutr_No = 858}
dbmem eval {update tnutr_def set NutrDesc = '18:1n-7t' where Nutr_No = 859}
dbmem eval {insert into tnutr_def values(3000,'kc','PROT_KCAL','Protein Calories','',0)}
dbmem eval {insert into tnutr_def values(3001,'kc','FAT_KCAL','Fat Calories','',0)}
dbmem eval {insert into tnutr_def values(3002,'kc','CHO_KCAL','Carb Calories','',0)}
dbmem eval {insert into tnutr_def values(2000,'g','CHO_NONFIB','Non-Fiber Carb','',0)}
dbmem eval {insert into tnutr_def values(2001,'g','LA','LA','',0)}
dbmem eval {insert into tnutr_def values(2002,'g','AA','AA','',0)}
dbmem eval {insert into tnutr_def values(2003,'g','ALA','ALA','',0)}
dbmem eval {insert into tnutr_def values(2004,'g','EPA','EPA','',0)}
dbmem eval {insert into tnutr_def values(2005,'g','DHA','DHA','',0)}
dbmem eval {insert into tnutr_def values(2006,'g','OMEGA6','Omega-6','',0)}
dbmem eval {insert into tnutr_def values(3003,'g','SHORT6','Short-chain Omega-6','',0)}
dbmem eval {insert into tnutr_def values(3004,'g','LONG6','Long-chain Omega-6','',0)}
dbmem eval {insert into tnutr_def values(2007,'g','OMEGA3','Omega-3','',0)}
dbmem eval {insert into tnutr_def values(3005,'g','SHORT3','Short-chain Omega-3','',0)}
dbmem eval {insert into tnutr_def values(3006,'g','LONG3','Long-chain Omega-3','',0)}
dbmem eval {insert into tnutr_def values(2008,'IU','VITE','Vitamin E','',0)}
dbmem eval {insert or ignore into nutr_def select Nutr_No, Units, Tagname, NutrDesc, 0.0, 0.0 from tnutr_def}
dbmem eval {update nutr_def set dv_default = 2000.0 where Tagname = 'ENERC_KCAL'}
dbmem eval {update nutr_def set dv_default = 50.0 where Tagname = 'PROCNT'}
dbmem eval {update nutr_def set dv_default = 65.0 where Tagname = 'FAT'}
dbmem eval {update nutr_def set dv_default = 300.0 where Tagname = 'CHOCDF'}
dbmem eval {update nutr_def set dv_default = 25.0 where Tagname = 'FIBTG'}
dbmem eval {update nutr_def set dv_default = 275.0 where Tagname = 'CHO_NONFIB'}
dbmem eval {update nutr_def set dv_default = 1000.0 where Tagname = 'CA'}
dbmem eval {update nutr_def set dv_default = 1000.0 where Tagname = 'P'}
dbmem eval {update nutr_def set dv_default = 18.0 where Tagname = 'FE'}
dbmem eval {update nutr_def set dv_default = 2400.0 where Tagname = 'NA'}
dbmem eval {update nutr_def set dv_default = 3500.0 where Tagname = 'K'}
dbmem eval {update nutr_def set dv_default = 400.0 where Tagname = 'MG'}
dbmem eval {update nutr_def set dv_default = 15.0 where Tagname = 'ZN'}
dbmem eval {update nutr_def set dv_default = 2.0 where Tagname = 'CU'}
dbmem eval {update nutr_def set dv_default = 2.0 where Tagname = 'MN'}
dbmem eval {update nutr_def set dv_default = 70.0 where Tagname = 'SE'}
dbmem eval {update nutr_def set dv_default = 5000.0 where Tagname = 'VITA_IU'}
dbmem eval {update nutr_def set dv_default = 30.0 where Tagname = 'VITE'}
dbmem eval {update nutr_def set dv_default = 80.0 where Tagname = 'VITK1'}
dbmem eval {update nutr_def set dv_default = 1.5 where Tagname = 'THIA'}
dbmem eval {update nutr_def set dv_default = 1.7 where Tagname = 'RIBF'}
dbmem eval {update nutr_def set dv_default = 20.0 where Tagname = 'NIA'}
dbmem eval {update nutr_def set dv_default = 10.0 where Tagname = 'PANTAC'}
dbmem eval {update nutr_def set dv_default = 2.0 where Tagname = 'VITB6A'}
dbmem eval {update nutr_def set dv_default = 400.0 where Tagname = 'FOL'}
dbmem eval {update nutr_def set dv_default = 6.0 where Tagname = 'VITB12'}
dbmem eval {update nutr_def set dv_default = 60.0 where Tagname = 'VITC'}
dbmem eval {update nutr_def set dv_default = 20.0 where Tagname = 'FASAT'}
dbmem eval {update nutr_def set dv_default = 300.0 where Tagname = 'CHOLE'}
dbmem eval {update nutr_def set dv_default = 400.0 where Tagname = 'VITD'}
dbmem eval {update nutr_def set dv_default = 8.9 where Tagname = 'FAPU'}
dbmem eval {update nutr_def set dv_default = 0.2 where Tagname = 'AA'}
dbmem eval {update nutr_def set dv_default = 3.8 where Tagname = 'ALA'}
dbmem eval {update nutr_def set dv_default = 0.1 where Tagname = 'EPA'}
dbmem eval {update nutr_def set dv_default = 0.1 where Tagname = 'DHA'}
dbmem eval {update nutr_def set dv_default = 4.7 where Tagname = 'LA'}
dbmem eval {update nutr_def set dv_default = 4.0 where Tagname = 'OMEGA3'}
dbmem eval {update nutr_def set dv_default = 4.9 where Tagname = 'OMEGA6'}
dbmem eval {update nutr_def set dv_default = 32.6 where Tagname = 'FAMS'}
dbmem eval {update nutr_def set dv_default = 7.0 where Tagname = 'GLY_G'}
dbmem eval {update nutr_def set dv_default = 900.0 where Tagname = 'RETOL'}
dbmem eval {COMMIT}
dbmem eval {drop table ttnutr_def}
dbmem eval {drop table tnutr_def}
}
#end load_nutr_def
}
set load_fd_group {
proc load_fd_group {args} {
dbmem eval {create temp table tfd_group( FdGrp_Cd text, FdGrp_Desc text)}
dbmem eval {create table if not exists fd_group(FdGrp_Cd int primary key, FdGrp_Desc text)}
dbmem copy fail tfd_group FD_GROUP.txt "^" ""
set carriagereturn "\r"
dbmem eval {insert or replace into fd_group select trim(FdGrp_Cd, "~"), trim(trim(FdGrp_Desc, $carriagereturn), "~") from tfd_group}
dbmem eval {insert or replace into fd_group values (9999, 'Added Recipes')}
dbmem eval {drop table tfd_group}
}
#end load_fd_group
}
set load_food_des1 {
proc load_food_des1 {args} {
dbmem eval {create temp table tfood_des( NDB_No text, FdGrp_Cd text, Long_Desc text, Shrt_Desc text, ComName text, ManufacName text, Survey text, Ref_desc text, Refuse integer, SciName text, N_Factor real, Pro_Factor real, Fat_Factor real, CHO_Factor real)}
dbmem eval {create table if not exists food_des(NDB_No int primary key, FdGrp_Cd int, Long_Desc text, Shrt_Desc text, Ref_desc text, Refuse integer default 0, Pro_Factor real default 4, Fat_Factor real default 9, CHO_Factor real default 4)}
}
#end load_food_des1
}
set load_food_des2 {
proc load_food_des2 {args} {
dbmem copy fail tfood_des FOOD_DES.txt "^" ""
if {[file exists [file join $::LegacyFileDir "FOOD_DES.txt"]]} {
dbmem copy fail tfood_des [file nativename [file join $::LegacyFileDir "FOOD_DES.txt"]] "^" ""
}
dbmem eval {update tfood_des set CHO_Factor = NULL where CHO_Factor = $carriagereturn}
dbmem eval {INSERT OR REPLACE INTO food_des (NDB_No, FdGrp_Cd, Long_Desc, Shrt_Desc, Ref_desc, Refuse, Pro_Factor, Fat_Factor, CHO_Factor) select trim(NDB_No, "~"), trim(FdGrp_Cd, "~"), replace(trim(trim(Long_Desc, "~") || ' (' || trim(SciName, "~") || ')',' ('),' ()',''), upper(substr(trim(Shrt_Desc, "~"),1,1)) || lower(substr(trim(Shrt_Desc, "~"),2)), trim(Ref_desc, "~"), Refuse, Pro_Factor, Fat_Factor, CHO_Factor from tfood_des}
dbmem eval {drop table tfood_des}
dbmem eval {drop index if exists Long_Desc_index}
dbmem eval {create index Long_Desc_index on food_des (Long_Desc)}
dbmem eval {drop index if exists Long_Desc_indexa}
dbmem eval {create index Long_Desc_indexa on food_des (Long_Desc collate nocase asc
)}
dbmem eval {drop view if exists vf}
set ::vfview {CREATE VIEW vf as select n6hufa(SHORT3,SHORT6,LONG3,LONG6,FASAT,FAMS,FATRN,FAPU,ENERC_KCAL,0) as "::FAPU1vf", case when ENERC_KCAL > 0.0 then cast(round(100.0 * PROT_KCAL / ENERC_KCAL) as integer) || ' / ' || cast(round(100.0 * CHO_KCAL / ENERC_KCAL) as integer) || ' / ' || cast(round(100.0 * FAT_KCAL / ENERC_KCAL) as integer) else '0 / 0 / 0' end as "::ENERC_KCAL1vf", food_des.NDB_No as NDB_Novf, Long_Desc, case when Refuse is not null then Refuse || "%" else Refuse end as Refusevf, setRefDesc(Ref_desc)}
dbmem eval {drop view if exists vf}
set ::arview {CREATE VIEW ar as select n6hufa(SHORT3,SHORT6,LONG3,LONG6,FASAT,FAMS,FATRN,FAPU,ENERC_KCAL,0) as "::FAPU1ar", case when ENERC_KCAL > 0.0 then cast(round(100.0 * PROT_KCAL / ENERC_KCAL) as integer) || ' / ' || cast(round(100.0 * CHO_KCAL / ENERC_KCAL) as integer) || ' / ' || cast(round(100.0 * FAT_KCAL / ENERC_KCAL) as integer) else '0 / 0 / 0' end as "::ENERC_KCAL1ar", cast (round(CHO_NONFIB, 0) as int) as "::CHO_NONFIBar1"}
set ::recipe100sql {update recipe set}
dbmem eval {drop view if exists am}
set ::amview {CREATE VIEW am as select format_meal_id(max(meal_id)) as "::LASTMEALam", format_meal_id(min(meal_id)) as "::FIRSTMEALam", min(meal_id) as "::FIRSTMEALts", n6hufa(sum(SHORT3) * meals_per_day / count(meal_id), sum(SHORT6) * meals_per_day / count(meal_id), sum(LONG3) * meals_per_day / count(meal_id), sum(LONG6) * meals_per_day / count(meal_id), sum(FASAT) * meals_per_day / count(meal_id), sum(FAMS) * meals_per_day / count(meal_id), sum(FATRN) * meals_per_day / count(meal_id), sum(FAPU) * meals_per_day / count(meal_id), sum(ENERC_KCAL) * meals_per_day / count(meal_id),0) as "::FAPU1am", case when sum(ENERC_KCAL) * meals_per_day / count(meal_id) > 0.0 then cast(round(100.0 * sum(PROT_KCAL) * meals_per_day / count(meal_id) / (sum(ENERC_KCAL) * meals_per_day / count(meal_id))) as integer) || ' / ' || cast(round(100.0 * sum(CHO_KCAL) * meals_per_day / count(meal_id) / (sum(ENERC_KCAL) * meals_per_day / count(meal_id))) as integer) || ' / ' || cast(round(100.0 * sum(FAT_KCAL) * meals_per_day / count(meal_id) / (sum(ENERC_KCAL) * meals_per_day / count(meal_id))) as integer) else '0 / 0 / 0' end as "::ENERC_KCAL1am"}
dbmem eval {drop view if exists rm}
set ::rmview {CREATE VIEW rm as select n6hufa(SHORT3 * meals_per_day, SHORT6 * meals_per_day, LONG3 * meals_per_day, LONG6 * meals_per_day, FASAT * meals_per_day, FAMS * meals_per_day, FATRN * meals_per_day, FAPU * meals_per_day, ENERC_KCAL * meals_per_day, 0) as "::FAPU1rm", case when ENERC_KCAL * meals_per_day > 0.0 then cast (round(100.0 * PROT_KCAL / ENERC_KCAL) as integer) || ' / ' || cast (round(100.0 * CHO_KCAL / ENERC_KCAL) as integer) || ' / ' || cast (round(100.0 * FAT_KCAL / ENERC_KCAL) as integer) else '0 / 0 / 0' end as "::ENERC_KCAL1rm"}
dbmem eval {update food_des set Shrt_Desc = upper(substr(trim(Long_Desc, "~"),1,1)) || lower(substr(trim(Long_Desc, "~"),2)) where length(Long_Desc) <= 60}
dbmem eval {drop view if exists nut_opts}
set ::nut_optsview {create view nut_opts as select }
dbmem eval {drop view if exists dv_defaults}
set ::dv_defaultsview {create view dv_defaults as select }
dbmem eval {drop view if exists dv}
set ::dvview {create view dv as select }
set food_des_columns [dbmem eval {PRAGMA table_info(food_des)}]
set tagnames [dbmem eval {select Tagname from nutr_def}]
set ::foodjoin {update food_des set }
set ::complete_mealjoin {insert or replace into meals select * from (select meal_date * 100 + meal as meal_id}
set ::update_mealfoods_trigger {CREATE TRIGGER update_mealfoods AFTER UPDATE ON mealfoods BEGIN insert or replace into meals select * from (select meal_date * 100 + meal as meal_id}
set ::insert_mealfoods_trigger {CREATE TRIGGER insert_mealfoods AFTER INSERT ON mealfoods BEGIN insert or replace into meals select * from (select meal_date * 100 + meal as meal_id}
set ::delete_mealfoods_trigger {CREATE TRIGGER delete_mealfoods AFTER DELETE ON mealfoods when (select count(*) from mealfoods where meal_date = OLD.meal_date and meal = OLD.meal) > 0 BEGIN insert or replace into meals select * from (select meal_date * 100 + meal as meal_id}
set ::delete1_mealfoods_trigger {CREATE TRIGGER delete1_mealfoods AFTER DELETE ON mealfoods when (select count(*) from mealfoods where meal_date = OLD.meal_date and meal = OLD.meal) = 0 BEGIN delete from meals where meal_id = OLD.meal_date * 100 + OLD.meal ; end}
set ::am_zero {create view am_zero as select '0 / 0 / 0' as "::ENERC_KCAL1am", '0 / 0' as "::FAPU1am",}
set ::rm_zero {create view rm_zero as select '0 / 0 / 0' as "::ENERC_KCAL1rm", '0 / 0' as "::FAPU1rm",}
set ::vf_zero {create view vf_zero as select '0 / 0 / 0' as "::ENERC_KCAL1vf", '0 / 0' as "::FAPU1vf",}
dbmem eval {drop table if exists meals}
dbmem eval {create table meals (meal_id integer primary key desc)}
foreach tag $tagnames {
dbmem eval "alter table meals add column $tag real default null"
if { $tag ni $food_des_columns } {
dbmem eval "alter table food_des add column $tag real default null"
}
append ::am_zero " 0.0 as \"::${tag}am\","
append ::rm_zero " 0.0 as \"::${tag}rm\","
append ::vf_zero " 0.0 as \"::${tag}vf\","
append ::vfview ", round(${tag} * whectograms,1) as \"::${tag}vf\""
append ::arview ", ${tag} as \"::${tag}ar\""
append ::recipe100sql " ${tag} = ${tag} / \$::RecipeWeight,"
append ::amview ", round(sum(${tag}) * meals_per_day / count(meal_id),1) as \"::${tag}am\""
append ::rmview ", round(${tag} * meals_per_day, 1) as \"::${tag}rm\""
}
dbmem eval {select Tagname, Nutr_No, dv_default from nutr_def} {
append ::complete_mealjoin ", sum($Tagname * mhectograms) as $Tagname"
append ::update_mealfoods_trigger ", sum($Tagname * mhectograms) as $Tagname"
append ::insert_mealfoods_trigger ", sum($Tagname * mhectograms) as $Tagname"
append ::delete_mealfoods_trigger ", sum($Tagname * mhectograms) as $Tagname"
if {$Nutr_No < 1000} {
append ::foodjoin "$Tagname = case when $Tagname is not null and (select Nutr_Val from tnut_data where food_des.NDB_No = tnut_data.NDB_No and tnut_data.Nutr_No = $Nutr_No) is null then $Tagname else (select Nutr_Val from tnut_data where food_des.NDB_No = tnut_data.NDB_No and tnut_data.Nutr_No = $Nutr_No) end, "
}
if {$dv_default != 0.0} {
append ::nut_optsview "(select nutopt from nutr_def where Tagname = '$Tagname') as \"::${Tagname}opt\", "
append ::dv_defaultsview "(select dv_default from nutr_def where Tagname = '$Tagname') as \"::${Tagname}dv_default\", "
append ::dvview "(select dv_default from nutr_def where Tagname = '$Tagname') as \"::${Tagname}dv\", "
append ::arview ", cast (round(100.0 * ${Tagname} / $dv_default , 0) as int) as \"::${Tagname}ardv\" "
}
}
set ::foodjoin [string trimright $::foodjoin]
set ::foodjoin [string trimright $::foodjoin ","]
set ::recipe100sql [string trimright $::recipe100sql ","]
append ::complete_mealjoin { from mealfoods,food_des where mealfoods.NDB_No = food_des.NDB_No group by meal_date,meal)}
append ::update_mealfoods_trigger { from mealfoods,food_des where mealfoods.NDB_No = food_des.NDB_No and meal_date = NEW.meal_date and meal = NEW.meal) ; update weight set whectograms = NEW.mhectograms, Amount = origAmount * NEW.mhectograms / orighectograms where NEW.mhectograms > 0.0 and NDB_No = NEW.NDB_No and Seq = (select min(Seq) from weight where NDB_No = NEW.NDB_No) ; end}
append ::insert_mealfoods_trigger { from mealfoods,food_des where mealfoods.NDB_No = food_des.NDB_No and meal_date = NEW.meal_date and meal = NEW.meal) ; end}
append ::delete_mealfoods_trigger { from mealfoods,food_des where mealfoods.NDB_No = food_des.NDB_No and meal_date = OLD.meal_date and meal = OLD.meal) ; end}
set ::am_zero [string trimright $::am_zero ","]
set ::rm_zero [string trimright $::rm_zero ","]
set ::vf_zero [string trimright $::vf_zero ","]
append ::vfview {, Msre_Desc as Msre_Descvf, cast (round(whectograms * 100.0) as integer) as gramsvf, round(whectograms/0.28349523,1) as ouncesvf, cast (round(ENERC_KCAL*whectograms) as integer) as caloriesvf, round(Amount,1) as Amountvf, 28.349523 as ounce2gram, case when ENERC_KCAL is null or ENERC_KCAL = 0.0 then 0.0 else 100.0/ENERC_KCAL end as cal2gram, 100.0*orighectograms/origAmount as Amount2gram from food_des join weight on food_des.NDB_No = weight.NDB_No and Seq = (select min(Seq) from weight where weight.NDB_No = food_des.NDB_No)}
append ::arview { from recipe}
append ::amview { from (select meals.*, cast (meals_per_day as real) as meals_per_day from meals, options where meal_id <= lastmeal_am limit (select case when defanal_am > 0 then defanal_am else 1000000 end from options))}
append ::rmview { from (select meals.*, cast (meals_per_day as real) as meals_per_day from meals, options where meal_id = lastmeal_rm)}
set ::nut_optsview [string trimright $::nut_optsview " "]
set ::nut_optsview [string trimright $::nut_optsview ","]
set ::dv_defaultsview [string trimright $::dv_defaultsview " "]
set ::dv_defaultsview [string trimright $::dv_defaultsview ","]
set ::dvview [string trimright $::dvview " "]
set ::dvview [string trimright $::dvview ","]
}
#end load_food_des2
}
set load_weight {
proc load_weight {args} {
dbmem eval {create temp table tweight( NDB_No text, Seq text, Amount real, Msre_Desc text, Gm_Wgt real, Num_Data_P int, Std_Dev real)}
dbmem eval {create table if not exists weight( NDB_No int, Seq int, Amount real, Msre_Desc text, whectograms real, origSeq text, origAmount real, orighectograms real, primary key(NDB_No, Seq))}
dbmem copy fail tweight WEIGHT.txt "^" ""
dbmem eval {create temp table tttweight( NDB_No text, Seq text, Amount real, Msre_Desc text, Gm_Wgt real, Num_Data_P int, Std_Dev real)}
if {[file exists [file join $::LegacyFileDir "WEIGHT.txt"]]} {
dbmem copy fail tttweight [file nativename [file join $::LegacyFileDir "WEIGHT.txt"]] "^" ""
}
dbmem eval {create temp table ttweight( NDB_No int, Seq int, Amount real, Msre_Desc text, Gm_Wgt real, Num_Data_P int, Std_Dev real, primary key(NDB_No, Seq))}
dbmem eval {insert or replace into ttweight select trim(NDB_No, "~"), trim(Seq, "~"), Amount, trim(Msre_Desc, "~"), Gm_Wgt, Num_Data_P, Std_Dev from tttweight}
dbmem eval {update ttweight set Seq = 98}
dbmem eval {INSERT OR IGNORE INTO weight select NDB_No, 0, Amount, Msre_Desc, Gm_Wgt / 100.0, Seq, Amount, Gm_Wgt / 100.0 from ttweight}
dbmem eval {drop table tttweight}
dbmem eval {drop table ttweight}
dbmem eval {INSERT OR IGNORE INTO weight select trim(NDB_No, "~") , trim(Seq, "~"), Amount, trim(Msre_Desc, "~"), Gm_Wgt / 100.0, trim(Seq, "~"), Amount, Gm_Wgt / 100.0 from tweight}
dbmem eval {insert or ignore into weight select NDB_No, 99, 100, 'grams', 1, 99, 100, 1 from food_des}
dbmem eval {select NDB_No, origSeq from weight where Seq != origSeq} {
dbmem eval {delete from weight where NDB_No = $NDB_No and Seq = $origSeq}
}
dbmem eval {drop table tweight}
}
#end load_weight
}
set load_nut_data1 {
proc load_nut_data1 {args} {
dbmem eval {create temp table ttnut_data( NDB_No text, Nutr_No text, Nutr_Val real, Num_Data_Pts int, Std_Error real, Src_Cd text, Deriv_Cd text, Ref_NDB_No text, Add_Nutr_Mark text, Num_Studies int, Min real, Max real, DF int, Low_EB real, Up_EB real, Stat_cmt text, AddMod_Date text, CC text)}
dbmem copy fail ttnut_data NUT_DATA.txt "^" ""
if {[file exists [file join $::LegacyFileDir "NUT_DATA.txt"]]} {
dbmem copy fail ttnut_data [file nativename [file join $::LegacyFileDir "NUT_DATA.txt"]] "^" ""
}
}
#end load_nut_data1
}
set load_nut_data2 {
proc load_nut_data2 {args} {
dbmem eval {create temp table tnut_data( NDB_No int, Nutr_No int, Nutr_Val real, primary key(NDB_No, Nutr_No))}
dbmem eval {insert or replace into tnut_data select trim(NDB_No, "~"), trim(Nutr_No, "~"), Nutr_Val from ttnut_data}
dbmem eval {drop table ttnut_data}
}
#end load_nut_data2
}
set load_legacy {
proc load_legacy {args} {
dbmem eval {drop trigger if exists update_mealfoods}
dbmem eval {drop trigger if exists insert_mealfoods}
dbmem eval {drop trigger if exists delete_mealfoods}
dbmem eval {drop trigger if exists delete1_mealfoods}
dbmem eval {create table if not exists options(defanal_am integer default 0, FAPU1 real default 0.0, meals_per_day int default 3, grams int default 1, lastmeal_am integer default 2147123119, lastmeal_rm integer, wltweak integer default 0, wlpolarity integer default 0, autocal integer default 0)}
dbmem eval {create table if not exists mealfoods(meal_date int, meal int, NDB_No int, mhectograms real, primary key(meal_date, meal, NDB_No))}
dbmem eval {create table if not exists archive_mealfoods(meal_date int, meal int, NDB_No int, mhectograms real, meals_per_day integer, primary key(meal_date, meal, NDB_No, meals_per_day))}
dbmem eval {create table if not exists theusual(meal_name text, NDB_No int, PCF text, primary key(meal_name,NDB_No))}
dbmem eval {create table if not exists wlog(weight real, bodyfat real, wldate int, cleardate int, primary key(wldate, cleardate))}
dbmem eval {create temp table toptions(opt int, optval real, nothing text)}
dbmem eval {create temp table tuserfiles (filename text)}
set legacyfiles [glob -nocomplain [file join $::LegacyFileDir "OPTIONS.txt"] [file join $::LegacyFileDir "WLOG.2"]* [file join $::LegacyFileDir "WLOG.txt"] $::LegacyFileDir/*.exp]
foreach file $legacyfiles {
dbmem eval "insert into tuserfiles values ('$file')"
}
dbmem eval {select count(*) as lfcount from tuserfiles} {}
if {$lfcount != 0} {
dbmem eval {select count(*) as count, filename from tuserfiles where filename like '%OPTIONS.txt%'} {
if {$count == 1} {
dbmem copy ignore toptions $filename "^" ""
dbmem eval {select count(*) as optcount from options} {
if {$optcount == 0} {
dbmem eval {update nutr_def set nutopt = case when (select optval from toptions t where nutr_def.Nutr_No = t.opt) != 0.0 then (select optval from toptions t where nutr_def.Nutr_No = t.opt) else nutopt end}
dbmem eval {update options set defanal_am = (select optval from toptions t where t.opt = 1019)}
dbmem eval {update options set grams = (select optval from toptions t where t.opt = 1010)}
dbmem eval {update options set FAPU1 = (select optval from toptions t where t.opt = 1016)}
dbmem eval {update options set wltweak = (select optval from toptions t where t.opt = 1024)}
dbmem eval {update options set wlpolarity = (select optval from toptions t where t.opt = 1025)}
dbmem eval {update options set autocal = (select optval from toptions t where t.opt = 1011)}
dbmem eval {update options set meals_per_day = (select optval from toptions t where t.opt = 1009)}
}
}
}
dbmem eval {select count(*) as count, filename from tuserfiles where filename like '%meal.exp%'} {
if {$count == 1} {
dbmem eval {create temp table tmealfoods (meal_date int, meal int, NDB_No int, grams real)}
dbmem copy replace tmealfoods $filename "^" ""
dbmem eval {insert or replace into mealfoods select meal_date, meal, NDB_No, sum(grams) / 100.0 from tmealfoods group by meal_date,meal,NDB_No}
}
}
dbmem eval {select count(*) as count, filename from tuserfiles where filename like '%theusual.exp%'} {
if {$count == 1} {
dbmem eval {create table if not exists ttheusual(meal_name text, meal_code int, NDB_No int, grams real, primary key(meal_name,NDB_No))}
dbmem copy ignore ttheusual $filename "^" ""
dbmem eval {insert or replace into theusual select meal_name, NDB_No, 'No Auto Portion Control' from ttheusual}
}
}
dbmem eval {create temp table ttwlog(weight real, bodyfat real, wldate int)}
dbmem eval {create temp table twlog(weight real, bodyfat real, wldate int, cleardate int)}
dbmem eval {select filename from tuserfiles where filename like '%WLOG.2%'} {
dbmem copy replace ttwlog $filename " " ""
set cleardate [string range $filename [string last "." $filename]+1 end]
dbmem eval {insert into twlog select weight, bodyfat, wldate, $cleardate from ttwlog}
dbmem eval {insert or replace into wlog select * from twlog}
dbmem eval {delete from ttwlog}
dbmem eval {delete from twlog}
}
dbmem eval {select filename from tuserfiles where filename like('%WLOG.txt%')} {
dbmem copy replace ttwlog $filename " " ""
dbmem eval {insert into ttwlog select weight, bodyfat, wldate from wlog where cleardate is null}
dbmem eval {delete from wlog where cleardate is null}
dbmem eval {insert into wlog select distinct weight, bodyfat, wldate, NULL from ttwlog}
}
}
dbmem eval {drop table if exists toptions}
dbmem eval {drop table if exists ttheusual}
dbmem eval {drop table if exists tuserfiles}
dbmem eval {drop table if exists tmealfoods}
dbmem eval {drop table if exists ttwlog}
dbmem eval {drop table if exists twlog}
}
dbmem eval {create table if not exists sql_statements(sqlname text primary key, sql text)}
dbmem eval {insert or replace into sql_statements values('recipe100',$::recipe100sql)}
dbmem eval {insert or replace into sql_statements values('complete_mealjoin',$::complete_mealjoin)}
set ::complete_mealjoin [dbmem eval {select sql from sql_statements where sqlname = 'complete_mealjoin'}]
dbmem eval {*}$::complete_mealjoin
dbmem eval {insert or replace into sql_statements values('update_mealfoods_trigger',$::update_mealfoods_trigger)}
dbmem eval {insert or replace into sql_statements values('insert_mealfoods_trigger',$::insert_mealfoods_trigger)}
dbmem eval {insert or replace into sql_statements values('delete_mealfoods_trigger',$::delete_mealfoods_trigger)}
dbmem eval {insert or replace into sql_statements values('delete1_mealfoods_trigger',$::delete1_mealfoods_trigger)}
dbmem eval $::update_mealfoods_trigger
dbmem eval $::insert_mealfoods_trigger
dbmem eval $::delete_mealfoods_trigger
dbmem eval $::delete1_mealfoods_trigger
dbmem eval {drop view if exists am_zero; drop view if exists rm_zero; drop view if exists vf_zero}
dbmem eval $::am_zero
dbmem eval $::rm_zero
dbmem eval $::vf_zero
dbmem eval $::vfview
dbmem eval $::amview
dbmem eval $::rmview
dbmem eval $::nut_optsview
dbmem eval $::dv_defaultsview
dbmem eval $::dvview
dbmem eval {drop table if exists recipe}
set recipestr [dbmem eval {select sql from sqlite_master where name = 'food_des'}]
set recipestr [string map {food_des recipe} $recipestr]
dbmem eval {*}$recipestr
dbmem eval {drop view if exists ar}
dbmem eval $::arview
dbmem eval {drop view if exists weightslope}
dbmem eval {drop view if exists fatslope}
dbmem eval {create view weightslope as select ifnull(weightslope,0.0) as "::weightslope", ifnull(round(sumy / n - weightslope * sumx / n,1),0.0) as "::weightyintercept", n as "::weightn" from (select (sumxy - (sumx * sumy / n)) / (sumxx - (sumx * sumx / n)) as weightslope, sumy, n, sumx from (select sum(x) as sumx, sum(y) as sumy, sum(x*y) as sumxy, sum(x*x) as sumxx, n from (select cast (cast (julianday(substr(wldate,1,4) || '-' || substr(wldate,5,2) || '-' || substr(wldate,7,2)) - julianday('now', 'localtime') as int) as real) as x, weight as y, cast ((select count(*) from wlog where cleardate is null) as real) as n from wlog where cleardate is null)))}
dbmem eval {create view fatslope as select ifnull(fatslope,0.0) as "::fatslope", ifnull(round(sumy / n - fatslope * sumx / n,1),0.0) as "::fatyintercept", n as "::fatn" from (select (sumxy - (sumx * sumy / n)) / (sumxx - (sumx * sumx / n)) as fatslope, sumy, n, sumx from (select sum(x) as sumx, sum(y) as sumy, sum(x*y) as sumxy, sum(x*x) as sumxx, n from (select cast (cast (julianday(substr(wldate,1,4) || '-' || substr(wldate,5,2) || '-' || substr(wldate,7,2)) - julianday('now', 'localtime') as int) as real) as x, bodyfat * weight / 100.0 as y, cast ((select count(*) from wlog where ifnull(bodyfat,0.0) > 0.0 and cleardate is null) as real) as n from wlog where ifnull(bodyfat,0.0) > 0.0 and cleardate is null)))}
if {[dbmem eval {select count(*) from options}] == 0} {
dbmem eval {insert into options default values}
}
}
#end load_legacy
}
db eval {BEGIN}
db eval {insert or replace into version values('NUTsqlite 1.9.9.6',NULL)}
db eval {delete from tcl_code}
db eval {insert or replace into tcl_code values('Main',$Main)}
db eval {insert or replace into tcl_code values('InitialLoad',$InitialLoad)}
db eval {insert or replace into tcl_code values('ComputeDerivedValues',$ComputeDerivedValues)}
db eval {insert or replace into tcl_code values('Start_NUT',$Start_NUT)}
db eval {insert or replace into tcl_code values('AmountChangevf',$AmountChangevf)}
db eval {insert or replace into tcl_code values('CalChangevf',$CalChangevf)}
db eval {insert or replace into tcl_code values('CancelSearch',$CancelSearch)}
db eval {insert or replace into tcl_code values('FindFoodrm',$FindFoodrm)}
db eval {insert or replace into tcl_code values('FindFoodrm_later',$FindFoodrm_later)}
db eval {insert or replace into tcl_code values('FindFoodvf',$FindFoodvf)}
db eval {insert or replace into tcl_code values('FindFoodvf_later',$FindFoodvf_later)}
db eval {insert or replace into tcl_code values('FoodChoicerm',$FoodChoicerm)}
db eval {insert or replace into tcl_code values('vf2rm',$vf2rm)}
db eval {insert or replace into tcl_code values('FoodChoicevf',$FoodChoicevf)}
db eval {insert or replace into tcl_code values('FoodChoicevf_alt',$FoodChoicevf_alt)}
db eval {insert or replace into tcl_code values('FoodSearchrm',$FoodSearchrm)}
db eval {insert or replace into tcl_code values('FoodSearchvf',$FoodSearchvf)}
db eval {insert or replace into tcl_code values('GramChangevf',$GramChangevf)}
db eval {insert or replace into tcl_code values('GramChangevfIdle',$GramChangevfIdle)}
db eval {insert or replace into tcl_code values('InitializePersonalOptions',$InitializePersonalOptions)}
db eval {insert or replace into tcl_code values('ChangePersonalOptions',$ChangePersonalOptions)}
db eval {insert or replace into tcl_code values('RefreshWeightLog',$RefreshWeightLog)}
db eval {insert or replace into tcl_code values('ClearWeightLog',$ClearWeightLog)}
db eval {insert or replace into tcl_code values('AcceptNewMeasurements',$AcceptNewMeasurements)}
db eval {insert or replace into tcl_code values('MealfoodDelete',$MealfoodDelete)}
db eval {insert or replace into tcl_code values('MealfoodSetWeight',$MealfoodSetWeight)}
db eval {insert or replace into tcl_code values('MealfoodSetWeightLater',$MealfoodSetWeightLater)}
db eval {insert or replace into tcl_code values('MealfoodWidget',$MealfoodWidget)}
db eval {insert or replace into tcl_code values('NBWamTabChange',$NBWamTabChange)}
db eval {insert or replace into tcl_code values('NBWrmTabChange',$NBWrmTabChange)}
db eval {insert or replace into tcl_code values('NBWarTabChange',$NBWarTabChange)}
db eval {insert or replace into tcl_code values('NBWvfTabChange',$NBWvfTabChange)}
db eval {insert or replace into tcl_code values('NewStoryLater',$NewStoryLater)}
db eval {insert or replace into tcl_code values('NewStory',$NewStory)}
db eval {insert or replace into tcl_code values('NutTabChange',$NutTabChange)}
db eval {insert or replace into tcl_code values('OunceChangevf',$OunceChangevf)}
db eval {insert or replace into tcl_code values('PCF',$PCF)}
db eval {insert or replace into tcl_code values('RefreshMealfoodQuantities',$RefreshMealfoodQuantities)}
db eval {insert or replace into tcl_code values('RecipeSaveAs',$RecipeSaveAs)}
db eval {insert or replace into tcl_code values('RecipeMod1',$RecipeMod1)}
db eval {insert or replace into tcl_code values('RecipeModdv',$RecipeModdv)}
db eval {insert or replace into tcl_code values('RecipeMod',$RecipeMod)}
db eval {insert or replace into tcl_code values('RecipeCancel',$RecipeCancel)}
db eval {insert or replace into tcl_code values('RecipeDone',$RecipeDone)}
db eval {insert or replace into tcl_code values('ServingChange',$ServingChange)}
db eval {insert or replace into tcl_code values('SetDefanal',$SetDefanal)}
db eval {insert or replace into tcl_code values('SetDefanalLater',$SetDefanalLater)}
db eval {insert or replace into tcl_code values('SetMealRange_am',$SetMealRange_am)}
db eval {insert or replace into tcl_code values('SetMPD',$SetMPD)}
db eval {insert or replace into tcl_code values('SwitchToAnalysis',$SwitchToAnalysis)}
db eval {insert or replace into tcl_code values('SwitchToMenu',$SwitchToMenu)}
db eval {insert or replace into tcl_code values('TurnOffTheBubbleMachine',$TurnOffTheBubbleMachine)}
db eval {insert or replace into tcl_code values('auto_cal',$auto_cal)}
db eval {insert or replace into tcl_code values('badPCF',$badPCF)}
db eval {insert or replace into tcl_code values('dropoutvf',$dropoutvf)}
db eval {insert or replace into tcl_code values('format_meal_id',$format_meal_id)}
db eval {insert or replace into tcl_code values('mealchange',$mealchange)}
db eval {insert or replace into tcl_code values('n6hufa',$n6hufa)}
db eval {insert or replace into tcl_code values('recenterscale',$recenterscale)}
db eval {insert or replace into tcl_code values('setPCF',$setPCF)}
db eval {insert or replace into tcl_code values('setRefDesc',$setRefDesc)}
db eval {insert or replace into tcl_code values('tuneinvf',$tuneinvf)}
db eval {insert or replace into tcl_code values('update_am',$update_am)}
db eval {insert or replace into tcl_code values('pbprog',$pbprog)}
db eval {insert or replace into tcl_code values('pbprog1',$pbprog1)}
db eval {insert or replace into tcl_code values('theusualPopulateMenu',$theusualPopulateMenu)}
db eval {insert or replace into tcl_code values('theusualAdd',$theusualAdd)}
db eval {insert or replace into tcl_code values('theusualSave',$theusualSave)}
db eval {insert or replace into tcl_code values('theusualSaveNew',$theusualSaveNew)}
db eval {insert or replace into tcl_code values('theusualNewName',$theusualNewName)}
db eval {insert or replace into tcl_code values('theusualDelete',$theusualDelete)}
db eval {insert or replace into tcl_code values('monoright',$monoright)}
db eval {insert or replace into tcl_code values('rank2vf',$rank2vf)}
db eval {insert or replace into tcl_code values('rm2vf',$rm2vf)}
db eval {insert or replace into tcl_code values('changedv_vitmin',$changedv_vitmin)}
db eval {insert or replace into tcl_code values('Main_alt',$Main_alt)}
db eval {insert or replace into tcl_code values('drawClock',$drawClock)}
db eval {insert or replace into tcl_code values('stundenZeigerAuf',$stundenZeigerAuf)}
db eval {insert or replace into tcl_code values('minutenZeigerAuf',$minutenZeigerAuf)}
db eval {insert or replace into tcl_code values('sekundenZeigerAuf',$sekundenZeigerAuf)}
db eval {insert or replace into tcl_code values('showTime',$showTime)}
db eval {insert or replace into tcl_code values('InitialLoad_alt_GUI',$InitialLoad_alt_GUI)}
db eval {insert or replace into tcl_code values('pbprog_threaded',$pbprog_threaded)}
db eval {insert or replace into tcl_code values('pbprog1_threaded',$pbprog1_threaded)}
db eval {insert or replace into tcl_code values('Start_NUT_alt_GUI',$Start_NUT_alt_GUI)}
db eval {insert or replace into tcl_code values('opt_change',$opt_change)}
db eval {insert or replace into tcl_code values('SetMealBase',$SetMealBase)}
db eval {insert or replace into tcl_code values('GO_change',$GO_change)}
db eval {insert or replace into tcl_code values('get_procs_from_db',$get_procs_from_db)}
db eval {insert or replace into tcl_code values('::PROCNTdv_change',$::PROCNTdv_change)}
db eval {insert or replace into tcl_code values('::PROCNTnew_dv',$::PROCNTnew_dv)}
db eval {insert or replace into tcl_code values('::PROCNTnew_rm',$::PROCNTnew_rm)}
db eval {insert or replace into tcl_code values('::PROCNTnew_vf',$::PROCNTnew_vf)}
db eval {insert or replace into tcl_code values('::FATdv_change',$::FATdv_change)}
db eval {insert or replace into tcl_code values('::FATnew_dv',$::FATnew_dv)}
db eval {insert or replace into tcl_code values('::FATnew_rm',$::FATnew_rm)}
db eval {insert or replace into tcl_code values('::FATnew_vf',$::FATnew_vf)}
db eval {insert or replace into tcl_code values('::CHOCDFdv_change',$::CHOCDFdv_change)}
db eval {insert or replace into tcl_code values('::CHOCDFnew_dv',$::CHOCDFnew_dv)}
db eval {insert or replace into tcl_code values('::CHOCDFnew_rm',$::CHOCDFnew_rm)}
db eval {insert or replace into tcl_code values('::CHOCDFnew_vf',$::CHOCDFnew_vf)}
db eval {insert or replace into tcl_code values('::ENERC_KCALdv_change',$::ENERC_KCALdv_change)}
db eval {insert or replace into tcl_code values('::ENERC_KCALnew_dv',$::ENERC_KCALnew_dv)}
db eval {insert or replace into tcl_code values('::ENERC_KCALnew_rm',$::ENERC_KCALnew_rm)}
db eval {insert or replace into tcl_code values('::ENERC_KCALnew_vf',$::ENERC_KCALnew_vf)}
db eval {insert or replace into tcl_code values('::FIBTGdv_change',$::FIBTGdv_change)}
db eval {insert or replace into tcl_code values('::FIBTGnew_dv',$::FIBTGnew_dv)}
db eval {insert or replace into tcl_code values('::FIBTGnew_rm',$::FIBTGnew_rm)}
db eval {insert or replace into tcl_code values('::FIBTGnew_vf',$::FIBTGnew_vf)}
db eval {insert or replace into tcl_code values('::CAdv_change',$::CAdv_change)}
db eval {insert or replace into tcl_code values('::CAnew_dv',$::CAnew_dv)}
db eval {insert or replace into tcl_code values('::CAnew_rm',$::CAnew_rm)}
db eval {insert or replace into tcl_code values('::CAnew_vf',$::CAnew_vf)}
db eval {insert or replace into tcl_code values('::FEdv_change',$::FEdv_change)}
db eval {insert or replace into tcl_code values('::FEnew_dv',$::FEnew_dv)}
db eval {insert or replace into tcl_code values('::FEnew_rm',$::FEnew_rm)}
db eval {insert or replace into tcl_code values('::FEnew_vf',$::FEnew_vf)}
db eval {insert or replace into tcl_code values('::MGdv_change',$::MGdv_change)}
db eval {insert or replace into tcl_code values('::MGnew_dv',$::MGnew_dv)}
db eval {insert or replace into tcl_code values('::MGnew_rm',$::MGnew_rm)}
db eval {insert or replace into tcl_code values('::MGnew_vf',$::MGnew_vf)}
db eval {insert or replace into tcl_code values('::Pdv_change',$::Pdv_change)}
db eval {insert or replace into tcl_code values('::Pnew_dv',$::Pnew_dv)}
db eval {insert or replace into tcl_code values('::Pnew_rm',$::Pnew_rm)}
db eval {insert or replace into tcl_code values('::Pnew_vf',$::Pnew_vf)}
db eval {insert or replace into tcl_code values('::Kdv_change',$::Kdv_change)}
db eval {insert or replace into tcl_code values('::Knew_dv',$::Knew_dv)}
db eval {insert or replace into tcl_code values('::Knew_rm',$::Knew_rm)}
db eval {insert or replace into tcl_code values('::Knew_vf',$::Knew_vf)}
db eval {insert or replace into tcl_code values('::NAdv_change',$::NAdv_change)}
db eval {insert or replace into tcl_code values('::NAnew_dv',$::NAnew_dv)}
db eval {insert or replace into tcl_code values('::NAnew_rm',$::NAnew_rm)}
db eval {insert or replace into tcl_code values('::NAnew_vf',$::NAnew_vf)}
db eval {insert or replace into tcl_code values('::ZNdv_change',$::ZNdv_change)}
db eval {insert or replace into tcl_code values('::ZNnew_dv',$::ZNnew_dv)}
db eval {insert or replace into tcl_code values('::ZNnew_rm',$::ZNnew_rm)}
db eval {insert or replace into tcl_code values('::ZNnew_vf',$::ZNnew_vf)}
db eval {insert or replace into tcl_code values('::CUdv_change',$::CUdv_change)}
db eval {insert or replace into tcl_code values('::CUnew_dv',$::CUnew_dv)}
db eval {insert or replace into tcl_code values('::CUnew_rm',$::CUnew_rm)}
db eval {insert or replace into tcl_code values('::CUnew_vf',$::CUnew_vf)}
db eval {insert or replace into tcl_code values('::MNdv_change',$::MNdv_change)}
db eval {insert or replace into tcl_code values('::MNnew_dv',$::MNnew_dv)}
db eval {insert or replace into tcl_code values('::MNnew_rm',$::MNnew_rm)}
db eval {insert or replace into tcl_code values('::MNnew_vf',$::MNnew_vf)}
db eval {insert or replace into tcl_code values('::SEdv_change',$::SEdv_change)}
db eval {insert or replace into tcl_code values('::SEnew_dv',$::SEnew_dv)}
db eval {insert or replace into tcl_code values('::SEnew_rm',$::SEnew_rm)}
db eval {insert or replace into tcl_code values('::SEnew_vf',$::SEnew_vf)}
db eval {insert or replace into tcl_code values('::VITA_IUdv_change',$::VITA_IUdv_change)}
db eval {insert or replace into tcl_code values('::VITA_IUnew_dv',$::VITA_IUnew_dv)}
db eval {insert or replace into tcl_code values('::VITA_IUnew_rm',$::VITA_IUnew_rm)}
db eval {insert or replace into tcl_code values('::VITA_IUnew_vf',$::VITA_IUnew_vf)}
db eval {insert or replace into tcl_code values('::VITDdv_change',$::VITDdv_change)}
db eval {insert or replace into tcl_code values('::VITDnew_dv',$::VITDnew_dv)}
db eval {insert or replace into tcl_code values('::VITDnew_rm',$::VITDnew_rm)}
db eval {insert or replace into tcl_code values('::VITDnew_vf',$::VITDnew_vf)}
db eval {insert or replace into tcl_code values('::VITCdv_change',$::VITCdv_change)}
db eval {insert or replace into tcl_code values('::VITCnew_dv',$::VITCnew_dv)}
db eval {insert or replace into tcl_code values('::VITCnew_rm',$::VITCnew_rm)}
db eval {insert or replace into tcl_code values('::VITCnew_vf',$::VITCnew_vf)}
db eval {insert or replace into tcl_code values('::THIAdv_change',$::THIAdv_change)}
db eval {insert or replace into tcl_code values('::THIAnew_dv',$::THIAnew_dv)}
db eval {insert or replace into tcl_code values('::THIAnew_rm',$::THIAnew_rm)}
db eval {insert or replace into tcl_code values('::THIAnew_vf',$::THIAnew_vf)}
db eval {insert or replace into tcl_code values('::RIBFdv_change',$::RIBFdv_change)}
db eval {insert or replace into tcl_code values('::RIBFnew_dv',$::RIBFnew_dv)}
db eval {insert or replace into tcl_code values('::RIBFnew_rm',$::RIBFnew_rm)}
db eval {insert or replace into tcl_code values('::RIBFnew_vf',$::RIBFnew_vf)}
db eval {insert or replace into tcl_code values('::NIAdv_change',$::NIAdv_change)}
db eval {insert or replace into tcl_code values('::NIAnew_dv',$::NIAnew_dv)}
db eval {insert or replace into tcl_code values('::NIAnew_rm',$::NIAnew_rm)}
db eval {insert or replace into tcl_code values('::NIAnew_vf',$::NIAnew_vf)}
db eval {insert or replace into tcl_code values('::PANTACdv_change',$::PANTACdv_change)}
db eval {insert or replace into tcl_code values('::PANTACnew_dv',$::PANTACnew_dv)}
db eval {insert or replace into tcl_code values('::PANTACnew_rm',$::PANTACnew_rm)}
db eval {insert or replace into tcl_code values('::PANTACnew_vf',$::PANTACnew_vf)}
db eval {insert or replace into tcl_code values('::VITB6Adv_change',$::VITB6Adv_change)}
db eval {insert or replace into tcl_code values('::VITB6Anew_dv',$::VITB6Anew_dv)}
db eval {insert or replace into tcl_code values('::VITB6Anew_rm',$::VITB6Anew_rm)}
db eval {insert or replace into tcl_code values('::VITB6Anew_vf',$::VITB6Anew_vf)}
db eval {insert or replace into tcl_code values('::FOLdv_change',$::FOLdv_change)}
db eval {insert or replace into tcl_code values('::FOLnew_dv',$::FOLnew_dv)}
db eval {insert or replace into tcl_code values('::FOLnew_rm',$::FOLnew_rm)}
db eval {insert or replace into tcl_code values('::FOLnew_vf',$::FOLnew_vf)}
db eval {insert or replace into tcl_code values('::VITB12dv_change',$::VITB12dv_change)}
db eval {insert or replace into tcl_code values('::VITB12new_dv',$::VITB12new_dv)}
db eval {insert or replace into tcl_code values('::VITB12new_rm',$::VITB12new_rm)}
db eval {insert or replace into tcl_code values('::VITB12new_vf',$::VITB12new_vf)}
db eval {insert or replace into tcl_code values('::VITK1dv_change',$::VITK1dv_change)}
db eval {insert or replace into tcl_code values('::VITK1new_dv',$::VITK1new_dv)}
db eval {insert or replace into tcl_code values('::VITK1new_rm',$::VITK1new_rm)}
db eval {insert or replace into tcl_code values('::VITK1new_vf',$::VITK1new_vf)}
db eval {insert or replace into tcl_code values('::CHOLEdv_change',$::CHOLEdv_change)}
db eval {insert or replace into tcl_code values('::CHOLEnew_dv',$::CHOLEnew_dv)}
db eval {insert or replace into tcl_code values('::CHOLEnew_rm',$::CHOLEnew_rm)}
db eval {insert or replace into tcl_code values('::CHOLEnew_vf',$::CHOLEnew_vf)}
db eval {insert or replace into tcl_code values('::FASATdv_change',$::FASATdv_change)}
db eval {insert or replace into tcl_code values('::FASATnew_dv',$::FASATnew_dv)}
db eval {insert or replace into tcl_code values('::FASATnew_rm',$::FASATnew_rm)}
db eval {insert or replace into tcl_code values('::FASATnew_vf',$::FASATnew_vf)}
db eval {insert or replace into tcl_code values('::FAMSdv_change',$::FAMSdv_change)}
db eval {insert or replace into tcl_code values('::FAMSnew_dv',$::FAMSnew_dv)}
db eval {insert or replace into tcl_code values('::FAMSnew_rm',$::FAMSnew_rm)}
db eval {insert or replace into tcl_code values('::FAMSnew_vf',$::FAMSnew_vf)}
db eval {insert or replace into tcl_code values('::FAPUdv_change',$::FAPUdv_change)}
db eval {insert or replace into tcl_code values('::FAPUnew_dv',$::FAPUnew_dv)}
db eval {insert or replace into tcl_code values('::FAPUnew_rm',$::FAPUnew_rm)}
db eval {insert or replace into tcl_code values('::FAPUnew_vf',$::FAPUnew_vf)}
db eval {insert or replace into tcl_code values('::CHO_NONFIBdv_change',$::CHO_NONFIBdv_change)}
db eval {insert or replace into tcl_code values('::CHO_NONFIBnew_dv',$::CHO_NONFIBnew_dv)}
db eval {insert or replace into tcl_code values('::CHO_NONFIBnew_rm',$::CHO_NONFIBnew_rm)}
db eval {insert or replace into tcl_code values('::CHO_NONFIBnew_vf',$::CHO_NONFIBnew_vf)}
db eval {insert or replace into tcl_code values('::LAdv_change',$::LAdv_change)}
db eval {insert or replace into tcl_code values('::LAnew_dv',$::LAnew_dv)}
db eval {insert or replace into tcl_code values('::LAnew_rm',$::LAnew_rm)}
db eval {insert or replace into tcl_code values('::LAnew_vf',$::LAnew_vf)}
db eval {insert or replace into tcl_code values('::AAdv_change',$::AAdv_change)}
db eval {insert or replace into tcl_code values('::AAnew_dv',$::AAnew_dv)}
db eval {insert or replace into tcl_code values('::AAnew_rm',$::AAnew_rm)}
db eval {insert or replace into tcl_code values('::AAnew_vf',$::AAnew_vf)}
db eval {insert or replace into tcl_code values('::ALAdv_change',$::ALAdv_change)}
db eval {insert or replace into tcl_code values('::ALAnew_dv',$::ALAnew_dv)}
db eval {insert or replace into tcl_code values('::ALAnew_rm',$::ALAnew_rm)}
db eval {insert or replace into tcl_code values('::ALAnew_vf',$::ALAnew_vf)}
db eval {insert or replace into tcl_code values('::EPAdv_change',$::EPAdv_change)}
db eval {insert or replace into tcl_code values('::EPAnew_dv',$::EPAnew_dv)}
db eval {insert or replace into tcl_code values('::EPAnew_rm',$::EPAnew_rm)}
db eval {insert or replace into tcl_code values('::EPAnew_vf',$::EPAnew_vf)}
db eval {insert or replace into tcl_code values('::DHAdv_change',$::DHAdv_change)}
db eval {insert or replace into tcl_code values('::DHAnew_dv',$::DHAnew_dv)}
db eval {insert or replace into tcl_code values('::DHAnew_rm',$::DHAnew_rm)}
db eval {insert or replace into tcl_code values('::DHAnew_vf',$::DHAnew_vf)}
db eval {insert or replace into tcl_code values('::OMEGA6dv_change',$::OMEGA6dv_change)}
db eval {insert or replace into tcl_code values('::OMEGA6new_dv',$::OMEGA6new_dv)}
db eval {insert or replace into tcl_code values('::OMEGA6new_rm',$::OMEGA6new_rm)}
db eval {insert or replace into tcl_code values('::OMEGA6new_vf',$::OMEGA6new_vf)}
db eval {insert or replace into tcl_code values('::OMEGA3dv_change',$::OMEGA3dv_change)}
db eval {insert or replace into tcl_code values('::OMEGA3new_dv',$::OMEGA3new_dv)}
db eval {insert or replace into tcl_code values('::OMEGA3new_rm',$::OMEGA3new_rm)}
db eval {insert or replace into tcl_code values('::OMEGA3new_vf',$::OMEGA3new_vf)}
db eval {insert or replace into tcl_code values('::VITEdv_change',$::VITEdv_change)}
db eval {insert or replace into tcl_code values('::VITEnew_dv',$::VITEnew_dv)}
db eval {insert or replace into tcl_code values('::VITEnew_rm',$::VITEnew_rm)}
db eval {insert or replace into tcl_code values('::VITEnew_vf',$::VITEnew_vf)}
db eval {insert or replace into tcl_code values('::GLY_Gdv_change',$::GLY_Gdv_change)}
db eval {insert or replace into tcl_code values('::GLY_Gnew_dv',$::GLY_Gnew_dv)}
db eval {insert or replace into tcl_code values('::GLY_Gnew_rm',$::GLY_Gnew_rm)}
db eval {insert or replace into tcl_code values('::GLY_Gnew_vf',$::GLY_Gnew_vf)}
db eval {insert or replace into tcl_code values('::RETOLdv_change',$::RETOLdv_change)}
db eval {insert or replace into tcl_code values('::RETOLnew_dv',$::RETOLnew_dv)}
db eval {insert or replace into tcl_code values('::RETOLnew_rm',$::RETOLnew_rm)}
db eval {insert or replace into tcl_code values('::RETOLnew_vf',$::RETOLnew_vf)}
db eval {insert or replace into tcl_code values('load_nutr_def',$load_nutr_def)}
db eval {insert or replace into tcl_code values('load_fd_group',$load_fd_group)}
db eval {insert or replace into tcl_code values('load_food_des1',$load_food_des1)}
db eval {insert or replace into tcl_code values('load_food_des2',$load_food_des2)}
db eval {insert or replace into tcl_code values('load_weight',$load_weight)}
db eval {insert or replace into tcl_code values('load_nut_data1',$load_nut_data1)}
db eval {insert or replace into tcl_code values('load_nut_data2',$load_nut_data2)}
db eval {insert or replace into tcl_code values('load_legacy',$load_legacy)}
db eval {COMMIT}
package require Tk
wm geometry . 1x1
set appSize 0.0
set ::magnify [expr {[winfo vrootheight .] / 711.0}]
if {[string is double -strict $appSize] && $appSize > 0.0} {
set ::magnify [expr {$::magnify * $appSize}]
}
if {$appSize == 0.0} {set ::magnify 1.0}
foreach font [font names] {
font configure $font -size [expr {int($::magnify * [font configure $font -size]
)}]
}
set i [font measure TkDefaultFont -displayof . " TransMonoenoic "]
set ::column18 [expr {int(round($i / 3.0))}]
set ::column15 [expr {int(round(2.0 * $i / 5.0))}]
option add *Dialog.msg.wrapLength [expr {400 * $::magnify}]
option add *Dialog.dtl.wrapLength [expr {400 * $::magnify}]
db eval {select max(version) as "::version" from version} { }
tk_messageBox -type ok -title "updateNUT.tcl Completion" -message "There\'s a signpost up ahead.\n\nNext stop: ${::version}"
exit 0
nutdoc.html 0000644 0000000 0000000 00000110456 13123014504 011736 0 ustar root root Content-type: text/html
NUTsqlite Documentation
nut
Section: (1)
Updated: 2014.06.14
Index
Return to Main Contents
NAME
nut - analyze meals with the USDA Nutrient Database
SYNOPSIS
nut.tcl
DESCRIPTION
NUT
allows you to record what you eat and analyze your meals for nutrient
composition.
Nutrient levels are expressed
as a percentage of the DV or Daily Value,
the familiar standard of food labeling in the United States.
The essential fatty acids, Omega-6 and Omega-3, are not currently mentioned in
these standards, and a reference value has been supplied.
NUT
uses Tcl/Tk to create an SQLite database that holds its own code,
the
USDA Nutrient Database for Standard Reference,
and your personal data for meals, recipes, and weight logs.
INSTALLATION and LOAD of USDA Database:
If your desktop system does not have Tcl/Tk available, download and install the free
(community) version of ActiveTcl from
http://www.activestate.com/.
Download the full ascii version of the USDA Nutrient Database,
available from
http://www.ars.usda.gov/nutrientdata
or from
http://nut.sourceforge.net,
and unzip it in some directory.
Run "updateNUT.tcl", an executable included in the
NUT
distribution, in the same directory where you put the USDA database.
This script will load your new
NUT
database with the
NUT
code.
After this step, run "nut.tcl" to start
NUT.
Initially,
NUT
will see the USDA tables and load them as well as
any legacy files from previous versions
of
NUT.
After these steps, both "updateNUT.tcl" and the USDA files are not
required and can be deleted.
"nut.tcl" can start the program with
a different location for
the
NUT
database and a different location for legacy files.
These changes are easily made by editing "nut.tcl".
In addition, a value can be changed in "nut.tcl" to make the program usable
on screens with a high resolution.
NUT
will check how many pixels you have and create a font/window combination
that is always legible. Change the "appSize" variable in "nut.tcl"
to between 0.7 (small) and 1.3 (almost fullscreen) to magnify the default Tk
font and window sizes appropriately.
OVERVIEW of PROGRAM
A typical session with
NUT
begins with a glance at "Analyze Meals" to see the daily
averages from the
last few meals.
Normally, one analyzes more than one day but less than two weeks to
get a fairly recent overview of nutritional quality and adherence to plan.
"Record Meals & Recipes" is where meals are planned or else simply recorded if
unplanned.
A slider can either be moved directly or else clicked
on the
left or right to move backward or forward to get to the
current meal.
A simple "Food Search" entry brings up the foods in the
database and if one is selected, it is immediately added to the meal.
A major feature of NUT is to be able to associate meal foods
with automatic portion control for various nutrients so you can more easily plan meals
that are both nutritionally complete and in accord with
your personal regimen.
This function also allows you to save a "meal" as a recipe to be added to
the USDA database, or to designate a meal as a Customary Meal for easier data
entry later.
"View Foods" shows comprehensive nutrient listings for each food,
in serving sizes as described by the USDA nutrient database. Any of these
serving sizes can be scaled and easily added to a meal, and
NUT
remembers your preferred serving sizes.
"Personal Options" allows the nutrient standards to be changed. These
personal standards are customized and the rest of the program follows
these standards.
It is unlikely that the straight "Daily Value", a high-carb, low-fat diet
with an absolute minimum of protein, will be optimal for you, so you can try different program settings, experiment to see how you feel when eating different ways, and thus gradually find the style of eating that
is your personal optimum.
In addition, there is a facility to record weight and
bodyfat percentages daily and see a linear extrapolation of the trend so
that you do not have to wait weeks to know how a new strategy is
working.
NUT will also automatically move calories up and down by gradual increments in order to keep lean mass up and
fat mass down with the Calorie Auto-Set feature.
Whenever you press a nutrient button you go to a screen that describes
"The Story" for that nutrient. This includes various lists of foods
sorted to help you find the nutrients you need.
ANALYZE MEALS
Meal analysis is always a daily rate of intake and not a sum. For instance,
if you eat 2000 calories a day and analyze a week of meals, the analysis
reports 2000 calories, not 14,000. Likewise, if you eat three meals a day and
2000 calories a day and analyze a single meal of 667 calories,
the analysis reports 100% of calories, not
33% of calories.
Think of
NUT
meal analysis
as a speedometer, not an odometer.
The range of meals shown on the screen controls many other functions in the
program as it not only sets the range for showing food lists, but
also the exact Daily Values used in portion control. Therefore, if you
want automatic portion control to be as accurate as possible, analyzing
just one meal while you are planning meals is best, although it is
not required most of the time--just when you are changing strategies, such as from high-carb to low-carb.
The spin button controlling how many consecutive meals to analyze can be selected and cleared with a backspace to speed up making large changes.
A very large value will resolve to all the meals
in the database, but do remember, if automatic portion control is in effect, there will be a lot of processing to get all of the program functions into sync because portion control always needs to reanalyze all meals until it is sure the requirements are properly met.
RECORD MEALS & RECIPES
For the program analysis to come out right you must record
all the meals the program is set for.
For instance, if
NUT
is set for three meals a day, and
you eat more than three, combine them into three; if you eat less than three,
record some minimal item such as an ounce of water for each missing meal.
In this way, even if you take breaks from recording,
NUT
will report fairly accurate daily averages and just concatenate over the
breaks; but otherwise
NUT
will wrongly weight the meals as a wrong percentage of a day.
When the program first starts, there is a button to "Delete all Meals and
Set Meals per Day". Although meals are deleted from view, they are
actually archived, so that if you return to the current number of meals per
day, the meals will return to the active database. If meal planning is not your
forte, or if your meal schedules are highly irregular, set
NUT
to 1 meal per day and record a daily running total of all foods eaten.
To actually record a meal, first determine if the slider in the upper left
corner of the screen shows the correct meal; if not, click on the left or right
of the slider to nudge it one meal at a time in the right direction until
the correct meal is showing. Then click on the "Food Search" entry area to
open up the search screen. Type a part of a food name and all the foods that
match will be shown below as you type. Select one with a click and it will
be added to the meal.
You can specify quantities in either gram or ounce weights by adjusting the
spin button, or by clicking on the food to open up "View Foods" so you can
choose a serving size based on cups or some other volume measurement,
but you can also let
NUT
set the quantity with "Auto Portion Control". To achieve portion control
based on calories, it is necessary to choose each of a protein, fat, and
non-fiber carb food (unless some of these macronutrients are set to
"Adjust to my meals"). But in addition, if you have noticed that
you rarely achieve the "Daily Value" for some of the vitamins and minerals,
they can also be chosen as "Auto Portion Control" nutrients. For instance,
you
could use Panto. Acid Auto Portion Control on something like mushrooms or avocado to
make sure you get some of this vitamin. In this manner, with a combination
of portion-controlled foods and non-portion-controlled foods, you can plan a meal
that exactly meets your nutrition goals while hopefully being something you
really want to eat.
When the Auto Portion Control algorithm is running, the "Food Search" entry
area turns into an indeterminate progress bar and the food quantities flip
around as they find the best possible solution.
The more "Auto Portion Control" selections you make, the more complicated
the process of finding the answer becomes, some combinations become
impossible, and some combinations might send the algorithm off the deep end,
in that it never completes.
Perhaps later
versions of
NUT
will have a better way to predict what is going to happen. For the time
being, if you need a complicated solution using many portion-controlled
foods,
be ready to blow away the window
running
NUT
and start over if it doesn't work. And if a Tcl error message dialog appears, just click "OK", because the error
is a transient consequence of an unexpected set of foods that cannot be
portion controlled to the selected specification.
These problems will be rare occurrences as
NUT
is able to recognize many combinations of foods and portion-control
settings that are not compatible.
When you have a good meal planned and think you may want to repeat it, use
the Customary Meals feature to save the meal. Later, when you want something
similar, add the customary meal to the new meal you are planning. If you
add the same meal more than once, you don't double the foods, but you can
refresh the Automatic Portion Control easily by adding the meal again.
Likewise, you can save the meal multiple times without duplicating the meal
foods. Customary Meals can always be adapted to whatever you are going to
have, by adding and deleting foods as required, and by changing quantities.
Record a recipe in exactly the same way as a meal, but press the "Save as
a Recipe" button to add your recipe as a new food to the USDA database. Then,
fill in the blanks with the recipe name, the number of servings, any volume measurement you want to use to measure a serving, such as cups, teaspoons or pieces, etc., and if you
know the weight of a serving after preparation, the recipe will be adjusted
for water gained or lost in preparation. Furthermore, you will be presented
with the complete nutrient screens so you can adjust the nutrient values. This allows you to create a "recipe" that is actually just a processed food or food supplement, where the real ingredients are similar to the processed food or
maybe just some water,
but you are changing the nutrient information to match the label on
a product.
On these recipe nutrient screens, the "Daily Value"
percentages are the standard 2000
calorie values, not any modifications you may have made from
"Personal Options", so that they will match the nutrition labels; however,
nutrient values can always be entered in grams. When you "Save" this new recipe, it becomes just like any other food in the database.
A non-obvious use for recipes is to add a new serving size to an
existing food to make portion control easier. Take one of my favorites, a
roasted chicken wing. The meat weighs 34 grams in an average wing
but there is 40% refuse, meaning
that the wing weighed on the bone comes to almost 57 grams (34 / 0.6). So, you can make
a recipe that is just a duplicate of the food with a slightly different name,
but with a serving unit of "grams weighed with refuse" and the number of serving
units in one serving is 56.67.
Then, at mealtime, if you need strict portion control, you go
to "View Foods" and set a number of servings corresponding to the weight of
the wings on the bone and add it to the meal, and only the weight of the meat
shows up in the meal.
Yet another use for "Save as a Recipe": Use it to quickly delete an entire meal,
and then cancel the recipe.
VIEW FOODS
Here's where you can check out the whole nutritional record for a food based
on whatever serving size you want to see represented. Notice that many
processed foods have very brief summaries of nutrients with many "[No Data]"
entries. When added to meals, "[No Data]" is treated as a zero, and since
nutrient values for specific foods vary considerably, analyses are always
approximate and not nearly as precise as
NUT
seems to suggest.
Additional information on this screen includes refuse percentages and
descriptions that can
help in visualizing how much food is required, and serving sizes can be
computed by calorie level as well as by weight.
PERSONAL OPTIONS
In the simplest case, you are just typing the number of grams of some nutrient
that you want to ingest daily, or else clicking an option that
will automatically set the value for you. Because the spinbuttons move so
slowly, for a big change you usually will select the old value with the mouse, backspace it out,
and type the new value you want. All of NUT is hooked together internally,
so if your changes impact automatic portion control, there will be lots of
activity to get the meal and its analyses all in sync and save everything to
the database.
"Adjust to my meals" is the setting if you don't care what the value for a
nutrient should be, or if you do care, but you manage the
value by different means.
For instance, if you are eating low-carb, and you always plan meals to have
minimal carbohydrate, "Adjust to my meals" means you don't have to hit a
particular carb target and yet everything will mesh properly as if you had
set a carb target that was exactly equal to what is in your meals.
Either "Total Fat" or "Non-Fiber Carb" can be set to "Balance of Calories" and
sometimes this option will automatically appear if required in order to meet
the Calorie requirement.
The options for polyunsaturated fat and the "Omega-6/3 Balance" target
select reference values (there are no "Daily Values" for these) based
on Dr. William Lands' empirical equation for the percentages of Omega-6
and Omega-3 fatty acids in tissue phospholipids based on diet. What this
means is that the actual gram weights of Omega-6 vs. Omega-3 are not a very
good indicator of what your body does with the fatty acids because the
individual fatty acids have different "strengths" as they compete for
conversion to the forms that make up the cell membrane and get chosen at
random to provide a signal that is either strong or weak in its effect
on inflammation, blood clotting, etc. Further information about this
biochemistry is on the
NUT
site at
http://nut.sourceforge.net/.
(Following is a description of the rightmost column on the screen that concerns
the weight log. At some lower screen resolutions, this column can be partially occluded. However, if you move the mouse
over the imaginary line between the program settings and the weight log columns,
there will appear a double arrow that you can click and drag to the left to
bring the weight log column into full view.)
NUT
records daily weight and bodyfat percentage measurements
and uses linear regression to filter out the random noise and show the actual
trend. Are you gaining mostly fat mass or losing mostly lean mass? This
feature can tell you if you have a bathroom scale that
can read bodyfat percentage.
The weight measurement is free of units, so pounds, kilos, or even stone will
work. Although
NUT
reports its findings with high precision, realize that the numbers are not
absolutely true, but you are concerned with the trends the numbers represent, so that you can modify your nutrition
strategy.
For example, if total weight is fairly constant but lean mass is going down and
fat mass is going up, would a little more protein
or less carbohydrate solve the problem? or would it make it worse?
To use the feature, weigh yourself once a day at some appointed time and
enter the weight and bodyfat numbers; then click on "Accept New Measurements".
NUT
will only accept one set of measurements per day, but there is no harm in missing a
day because the feature runs every day whether you add a measurement or not.
Think of each new set of measurements as a small correction to the equation to get
a truer picture where you are going, and that's how you tell if it is working,
because its predictions eventually do seem to be about right.
Weight loss gurus often advise against daily weighing because they are afraid
you will freak out on days weight goes up. But
NUT
uses linear regression to remove the noise of daily measurement error and
produce a clear signal which way the weight is trending, and the more daily
samples, the stronger the signal. This way you can find out more quickly that a
particular strategy just isn't working. Also, you can become more aware of
weight loss strategies that work by reducing lean mass instead of fat mass.
Calorie "Auto-Set" means that you will eat according to the calorie level that
NUT
shows and also record your weight and bodyfat percentage daily.
NUT
can then determine how best to move the calorie level so that gains in
lean mass and loss of fat mass are possible. A cycle begins when there are two weight/bodyfat data points recorded.
NUT
will move calories by a maximum of 20 calories a day.
If both lean mass and fat mass are trending down,
NUT
raises calories and starts a new cycle; if both lean mass and fat mass are trending up,
NUT
lowers calories and starts a new cycle. When fat mass is trending up and lean mass is trending
down,
NUT starts a new cycle without changing calories.
A cycle which begins with lean mass going up and fat mass going down is allowed to continue as long as the favorable trend prevails. The last set of
measurements is always retained for a quick start to the next cycle which means
that whenever the weight log is cleared, you see "1 data point so far..."
If you are not using the Calorie Auto-Set
feature, you can clear the weight log whenever you like; the usual reason would
be that you have started a new strategy and therefore want to see the new
trend. For instance, I tend to make five to seven days of measurements, check the numbers, move calories up or down as required, and then clear the weight log when I am trying to find the right calorie level for my latest experiment. The last weight log entry is again retained after clearing the weight log to enable a quicker start to the next cycle of logging.
THE STORY
When you click on a yellow nutrient button, you are taken to a tab that
expounds the nutrient's story. The screen features a list of
foods sorted from most to least of the nutrient of interest, and a simple graph of intake during the current analysis period that you set in "Analyze Meals".
The food lists can be queried in multiple ways. The basic queries are by
weight, by calories, by an approximate serving, and by weight of food in the
analyzed daily meals, but the results can be modified to only look at a
single food group.
If you get a white screen after the "wristwatch" cursor changes back to
normal, that means there are
no foods that meet the criteria. For instance, if I look at "Foods Ranked
per Daily Recorded Meals" and the food group "Breakfast Cereals" but I have
eaten no breakfast cereal, I will get a white screen.
If a food from the list looks interesting, click on it so it will open up in "View Foods".
USING THE SQLITE DATABASE APART FROM NUT
This is an advanced topic that will be expanded as I receive questions
about it. The SQLite3 database can be queried independently of the use of
NUT
and indeed, that is one reason I wrote this version of the software.
However, I doubt that knowledge of SQL is widespread, so first I will give
an example of a question I asked my database: What date did I have the
greatest amount of lean mass and how much was it?
The table we will use is "wlog", and first we are curious about the schema,
or what data is in "wlog". For this example, I will use the "sqlite3" commands
that come with SQLite, but any third-party software for querying SQLite will
work.
I start up the software with the command "sqlite3 nut.sqlite" and get the
output:
SQLite version 3.7.13 2012-06-11 02:05:22
Enter ".help" for instructions
Enter SQL statements terminated with a ";"
sqlite>
If I need to be reminded what table I am looking for, I ask to see a list of all the
tables:
sqlite> .tables
am fd_group recipe vf
am_zero food_des rm vf_zero
ar mealfoods rm_zero weight
archive_mealfoods meals sql_statements weightslope
dv nut_opts tcl_code wlog
dv_defaults nutr_def theusual
fatslope options version
(It should be noted that some of the views require Tcl procedures and thus can't
be queried apart from
NUT.)
Now I ask what data is in the "wlog" table by asking to see the "schema":
sqlite> .schema wlog
CREATE TABLE wlog(weight real, bodyfat real, wldate int, cleardate int, primary key(wldate, cleardate));
This is the exact SQL that created the wlog table.
Now I ask "what is the most lean mass I have had?"
sqlite> select max(weight - weight * bodyfat / 100) as leanmass from wlog;
125.1486
(Don't be shocked if you think this is too low; I am not a bodybuilder
or a big guy.)
Now I ask, "what was the date I had this much lean mass?"
sqlite> select wldate from wlog where weight - weight * bodyfat / 100 = (select max(weight - weight * bodyfat / 100) from wlog);
20110706
Increasing lean mass is great, but as the sole measure of body
composition
it leads to obesity; decreasing fat mass is great,
but as the sole measure of body composition it leads to frailty.
What we need is an equation which increases in value as body
composition improves.
Perhaps the simplest is lean mass minus fat mass, or in other words, what is the "spread" between the lean mass and the fat mass quantities:
sqlite> select wldate, round(weight - weight * bodyfat / 100, 1) as leanmass, round(weight * bodyfat / 100, 1) as fatmass, round(weight - 2 * weight * bodyfat / 100, 1) as bodycomp from wlog group by wldate;
20150603|122.9|34.3|88.7
20150605|123.4|33.2|90.2
20150606|122.9|34.1|88.9
20150607|123.2|33.2|90.1
20150608|123.7|33.1|90.6
20150609|123.2|33.8|89.5
20150610|123.6|33.1|90.6
20150611|124.0|33.4|90.7
20150612|124.0|33.4|90.7
20150613|123.9|33.1|90.7
20150614|123.6|33.0|90.5
20150615|123.9|32.3|91.5
20150616|123.9|32.5|91.3
20150617|124.2|32.4|91.8
20150618|124.8|32.8|92.0
20150619|125.3|32.3|93.0
Now, let's turn to a different task. I've created a bad recipe and I want to
delete it from the database. First, I find the record in the food_des table and
ask to see "NDB_No", the primary key for foods:
sqlite> select NDB_No, Long_Desc from food_des where Long_Desc like '%ramen jello%';
99008|Ramen jello toast, artisanal, with gelatin from pastured pork
When I know the NDB_No, I can delete the food record from food_des and any
associated weight records from weight:
sqlite> delete from food_des where NDB_No = 99008;
sqlite> delete from weight where NDB_No = 99008;
Hopefully you will never need to do this, but it is possible that
automatic portion control could write a completely awry meal that
NUT
is unable to analyze when it tries to come up. The only recourse
then is to delete the meal
from the database using the meal_date and meal number like this:
sqlite> delete from mealfoods where meal_date = 20150413 and meal = 3;
If the previous strategy then fails again when a meal is reloaded, it
probably means the weight table has recorded some impossible weight.
For instance, if you have determined there is more spinach in the meal
than molecules in the universe, this command will fix it:
sqlite> update weight set Amount = origAmount, whectograms = orighectograms where NDB_No = 11457;
Although you can update some of the
NUT
data manually as in the previous examples,
do note that if you update nutrient values in the food_des
table, your updates will not propagate to the
existing meals in the meals table unless you reload the
USDA nutrient database, this as a consequence of the table joins done at load time to
improve performance at
runtime.
Now a question which was difficult to answer with the legacy
NUT
program but fairly easy to answer with SQL. I was buying the most expensive
eggs because they had more Omega-3, but decided to use cheaper eggs and just
take a little more fish oil. What date did I change over? First, I need the
NDB_No of the expensive eggs:
sqlite> select NDB_No, Long_Desc from food_des where Long_Desc like '%egg%' and Long_Desc like '%organic%';
99010|Egg,yolk,raw,fresh,organic,brown,omega3,trader joe's
99011|Egg,whole,cooked,hard-boiled,organic,brn,omega3,trader joe's
I want to see just the raw yolks, and I want to query the "mealfoods" table,
which holds the exact foods and quantities for each meal.
I know mealfoods has a "meal_date" in addition to the NDB_No,
so here's how I see the latest date I
ate the expensive egg yolks:
sqlite> select max(meal_date) from mealfoods where NDB_No = 99010;
20140423
Here's something you frugalvores might be interested in. I added a table called "cost":
sqlite> .schema cost
CREATE TABLE cost (NDB_No int primary key, cost real, store text);
The actual cost column is dollars per 100 grams of food and after I figure out the NDB_No for the food I set it with an insert command like this:
sqlite> select NDB_No, Long_Desc from food_des where Long_Desc like '%romaine%';
11251|Lettuce, cos or romaine, raw (Lactuca sativa var. logifolia)
sqlite> insert into cost values (11251, 0.25841296, 'Smart & Final');
This says that 100 grams of romaine lettuce costs about $0.25 when bought from Smart & Final.
Here's how I find my actual cost per day for the last week:
sqlite> select meal_date, round(sum(mhectograms * cost),2) from mealfoods natural join food_des natural join cost group by meal_date order by meal_date desc limit 7;
20150224|10.32
20150223|10.16
20150222|10.74
20150221|10.04
20150220|10.84
20150219|10.6
20150218|10.84
A "natural join" means you don't have to specify the columns you are using for
a join between tables, and the database has been set up so that natural joins
will
work most of the time to get useful results.
If I want to see the previous query every day but it is too much of a drag to
type it in every time, I can create a view:
sqlite> create view weeklycost as select meal_date, round(sum(mhectograms * cost),2) from mealfoods natural join food_des natural join cost group by meal_date order by meal_date desc limit 7;
sqlite> select * from weeklycost;
20150224|10.32
20150223|10.16
20150222|10.74
20150221|10.04
20150220|10.84
20150219|10.6
20150218|10.84
Here's how I find which of the foods I buy is the cheapest source of copper (see below for how I know the copper column is named "CU"):
sqlite> select Shrt_Desc, cost / CU as val from cost natural join food_des where val is not null order by val limit 1;
Seeds, sunflower seed kernels, dried (helianthus annuus)|0.332843857072932
In the same vein, although not joinable to the other tables because it
allows non-food items, if I need
a shopping list:
sqlite> .schema shopping
CREATE TABLE shopping (n integer primary key, item text);
sqlite> insert into shopping values (null, 'radishes');
sqlite> insert into shopping values (null, 'salmon');
sqlite> select * from shopping;
1|radishes
2|salmon
Now a food question relevant to ketogenic diets: How do the lettuces rate for
maximum potassium per gram of non-fiber carb?
sqlite> select NDB_No, Shrt_Desc, round(K / CHO_NONFIB) as val from food_des where Long_Desc like 'Lettuce%' order by val desc;
11250|Lettuce,butterhead (incl boston&bibb types),raw|211.0
11251|Lettuce, cos or romaine, raw (lactuca sativa var. logifolia)|208.0
11257|Lettuce, red leaf, raw (lactuca sativa var. crispa)|138.0
11253|Lettuce, green leaf, raw (lactuca sativa var. crispa)|124.0
11252|Lettuce,iceberg (incl crisphead types),raw|80.0
I've been experimenting with coconut oil on my ketogenic diet.
Sometimes I feel I've been having too much and I cut back and other
times I feel I could use more, so I increase it, but I do not have any
idea what amount of coconut oil per meal has seemed satisfactory most
of the time. I know the NDB_No is 4047, so what I am going to do is
to make a list of how much coconut oil I had per meal for the various
days and then count the occurences of each amount of coconut oil, to
see what were my most popular amounts of coconut oil per meal.
The first column is ounces of coconut oil and the second column is a count of the
days when I had that much. I can see that 1.1 ounces per meal (a little over 2
tablespoons) was my most common dosage per meal:
sqlite> select val, count(meal_date) as ct from (select meal_date, round(sum(mhectograms / .2835 / 3.0),1) as val from mealfoods where NDB_No = 4047 group by meal_date order by val) group by val order by ct;
0.1|1
0.3|1
0.2|3
0.4|3
0.9|3
1.4|4
0.6|5
1.7|6
0.7|7
1.5|7
0.5|10
1.3|11
1.6|11
0.8|14
1.2|18
1.0|19
1.1|27
If you're interested in Omega-3 fatty acids, here's a view that does the
computation that
NUT
uses, and then we can answer the question "What (supposedly)
was the percentage of Omega-6 in my tissue phospholipids
during the summer of 2014?"
sqlite> .schema n6hufacalc
CREATE VIEW n6hufacalc as select meal_id, 100.0 / (1.0 + 0.0441 / (900 * SHORT6 / ENERC_KCAL) * (1.0 + (900 * SHORT3 / ENERC_KCAL) / 0.0555 + (900 * LONG3 / ENERC_KCAL) / 0.005 + (900 * (FASAT + FAMS + FAPU - SHORT6 - LONG6 - SHORT3 - LONG3) / ENERC_KCAL) / 5.0 + (900 * SHORT6 / ENERC_KCAL) / 0.175)) + 100.0 / (1.0 + 0.7 / (900 * LONG6 / ENERC_KCAL) * (1.0 + (900 * LONG3 / ENERC_KCAL) / 3.0)) as n6hufa from meals;
sqlite> select round(avg(n6hufa)) from n6hufacalc where meal_id between 2014060000 and 2014090000;
57.0
One of the users wanted a food journal in a particular format. It looked
simple but the SQL was surprisingly complicated:
qlite> select id || group_concat(' ' || food) from (select cast(substr(meal_date, 5, 2) as int) || '/' || cast(substr(meal_date, 7) as int) || ' ' || case when meal = 1 then 'breakfast:' when meal = 2 then 'lunch:' else 'dinner:' end as id, token1 || ' ' || case when commapos = 0 then token2 else substr(token2, 1, commapos - 1) end as food from (select meal_date, meal, token1, token2, instr(token2, ',') as commapos from (select meal_date, meal, trim(substr(Long_Desc, 1, instr(Long_Desc, ',')), ',') as token1, trim(substr(Long_Desc, instr(Long_Desc, ',')), ', ') as token2 from mealfoods natural join food_des where meal_date > 20170621))) group by id;
6/22 breakfast: Cheese cheddar, Oil coconut, Spinach raw (Spinacia oleracea), Tomatoes red, Nuts almonds, Beverages coffee, Fish sardine, Snacks pork skins, Cocoa dry powder, Oil flaxseed, Egg yolk, Chicken liver, Mushrooms brown, Artichokes (globe or french), Pork fresh, Beef ground
6/22 lunch: Cheese cheddar, Oil coconut, Brussels sprouts raw (Brassica oleracea (Gemmifera Group)), Spinach raw (Spinacia oleracea), Tomatoes red, Nuts almonds, Beverages coffee, Snacks pork skins, Cocoa dry powder, Oil flaxseed, Egg yolk, Chicken liver, Mushrooms brown, Pork fresh, Chicken broilers or fryers, Beef ground
The next query concerns how non-fiber carb has varied in my diet, but I
need to explain a few technicalities first. If you compare the
NUT
tables to the USDA tables, you can see that
NUT
doesn't have the USDA's "nut_data" table which contains the nutrient values.
This is because the food_des and meals tables have columns that contain the
nutrient values, and these columns are named after the corresponding "Tagname"
column in the table nutr_def, the nutrient definitions. For instance:
sqlite> select Tagname, NutrDesc from nutr_def where NutrDesc = 'Non-Fiber Carb';
CHO_NONFIB|Non-Fiber Carb
So, "CHO_NONFIB" is the "Non-Fiber Carb" column in both food_des and meals.
The meals table contains the nutrient values for each meal; think of it as
the sum of the foods in the mealfoods table grouped by each meal. But while
mealfoods has a "meal_date" and "meal" column to identify a meal, the meals
table has a single "meal_id" column which concatenates both meal_date and meal
into a single 10-digit long integer:
sqlite> select max(meal_id) from meals;
2014100701
This is meal #1 from October 7, 2014.
Using integer division using whole numbers only, I can divide to get just the
year and month like this:
sqlite> select max(meal_id) / 10000 from meals;
201410
So now here's the query to answer the question "What was my average non-fiber
carb intake each month?" Since I eat three meals a day and each meal is a
third of a day, I need to also multiply the average by three:
sqlite> select meal_id / 10000, avg(CHO_NONFIB) * 3 from meals group by meal_id / 10000;
201310|304.619325085423
201311|308.119947531993
201312|291.772580603746
201401|324.492761802168
201402|293.357125842871
201403|226.452908082339
201404|334.078889083876
201405|346.338731816916
201406|175.230665453905
201407|53.8261328350621
201408|20.2894606139836
201409|17.1093763102545
201410|20.3265642461782
To tie it all together, let's join this result to the wlog table to answer the question "How did my lean mass vary with these monthly
carb levels?" Because I am joining on a customized date representation, I can't use a
natural join, and I have to spell out the whole syntax for joins to specify what is going to be equal to what:
sqlite> select m.meal_id / 10000, avg(m.CHO_NONFIB) * 3, avg(w.weight - w.weight * w.bodyfat / 100) from meals m join wlog w on m.meal_id / 10000 = w.wldate / 100 group by m.meal_id / 10000;
201310|304.619325085423|120.8396
201311|308.119947531993|119.149733333333
201312|291.772580603746|119.1654
201401|324.492761802168|118.737
201402|293.357125842871|120.5744
201403|226.452908082338|119.601716666667
201404|334.078889083877|119.731470942857
201406|175.230665453906|119.888532336954
201407|53.8261328350628|118.202843122581
201408|20.2894606139832|119.118116129033
201409|17.1093763102544|119.682223076924
201410|20.3265642461782|120.523828571428
sqlite> .quit
FILES
nut.sqlite All personal data, the USDA Nutrient Database, and Tcl scripts
updateNUT.tcl Tcl script to create or update the NUT code in the database
nut.tcl Tcl script to start the NUTsqlite program
AUTHOR
Jim Jozwiak (jozwiak@gmail.com)
http://nut.sourceforge.net/
COPYING
Copyright (C) 1996-2017 by Jim Jozwiak.
Index
- NAME
-
- SYNOPSIS
-
- DESCRIPTION
-
- FILES
-
- AUTHOR
-
- COPYING
-
This document was created by
man2html,
using the manual pages.
Time: 19:56:09 GMT, June 13, 2014
nut.tcl 0000755 0000000 0000000 00000005211 13105447001 011063 0 ustar root root #!/bin/sh
# the next line restarts using tclsh \
exec tclsh "$0" "$@"
# NUT nutrition software
# Copyright (C) 1996-2017 by Jim Jozwiak.
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
#
# beginning of easy user changes
#
# DiskDB is the location of your NUTsqlite database
set DiskDB nut.sqlite
# LegacyFileDir is the directory where NUT-20.0 or before put its files
set LegacyFileDir "~/.nutdb"
# appSize is a factor to create fonts and windows that match screen resolution.
# 0.0 works well on Windows and the Mac, but on Linux,
# appSizes between 0.7 and 1.3 go between small to almost fullscreen
# and look the same at all screen resolutions when you don't have a
# resolution-independent window manager.
set appSize 0.0
# Do you need to cd to the right directory before the program starts?
# If so, edit and uncomment the following line:
# cd /home/jim/src/nut
#
# end of easy user changes
#
package require sqlite3
sqlite3 db $DiskDB
db timeout 10000
if {[catch { db eval {select code from tcl_code where name = 'Main'} { } }]} {
package require Tk
set ::magnify [expr {[winfo vrootheight .] / 711.0}]
if {[string is double -strict $appSize] && $appSize > 0.0} {
set ::magnify [expr {$::magnify * $appSize}]
}
if {$appSize == 0.0} {set ::magnify 1.0}
foreach font [font names] {
font configure $font -size [expr {int($::magnify * [font configure $font -size])}]
}
option add *Dialog.msg.wrapLength [expr {400 * $::magnify}]
option add *Dialog.dtl.wrapLength [expr {400 * $::magnify}]
tk_messageBox -type ok -title "NUTsqlite" -message "Run the \"updateNUT.tcl\" script before the first invocation of NUT in order to create the SQLite database with its code inside it. The \"updateNUT.tcl\" script is distributed with \"nut.tcl\" from http://nut.sourceforge.net and you will also have to download the USDA Nutrient Database from the same webpage. After this, \"updateNUT.tcl\" is not required for anything and can be deleted, and then you run \"nut.tcl\" to start NUTsqlite."
exit 0
} else {
eval $code
}
nuticon.xpm 0000644 0000000 0000000 00000005017 12427230376 011772 0 ustar root root /* XPM */
static const char *nuticon[] = {
/* width height num_colors chars_per_pixel */
" 55 40 4 1",
/* colors */
". c #000000",
"# c #5454ff",
"a c #ff0000",
"b c #ff00ff",
/* pixels */
"#######################################################",
"##########.......##########################aaaaaaa#####",
"##########aaaaaaa##########################aaaaaaa#####",
"##########aaaaaaa##########################aaaaaaa#####",
"#########aaaaaaaa##########################aaaaaaaa####",
"#########aaaaaaaa#########################.aaaaaaaa####",
"#########aaaaaaaa.########################aaaaaaaaa####",
"#########aaaaaaaaa########################aaaaaaaaa####",
"########.aaaaaaaaa########################aaaaaaaaa####",
"########aaaaaaaaaa########################aaaaaaaaa.###",
"########aaaaaaaaaa########################aaaaaaaaaa###",
"########aaaaaaaaaa#######################.aaaaaaaaaa###",
"########aaaaaaaaaaa######################aaaaaaaaaaa###",
"#######aaaaaaaaaaaa######################aaaaaaaaaaa###",
"#######aaaaaaaaaaaa######################aaaaaaaaaaa###",
"#######aaaaaaaaaaaa######################aaaaaaaaaaa.##",
"#######aaaaaaaaaaaa######################aaaaaaaaaaaa##",
"#######aaaaaaaaaaaa.####################aaaaaaaaaaaaa##",
"######aaaaaaaaaaaaaa####################aaaaaaaaaaaaa##",
"######aaaaaaaaaaaaaa####################aaaaaaaaaaaaa##",
"######aaaaaaaaaaaaaa####################aaaaaaaaaaaaa##",
"######aaaaaaaaaaaaaa####################aaaaaaaaaaaaa.#",
"#####aaaaaaaaaaaaaaa###################.aaaaaaaaaaaaaa#",
"#####aaaaaaaaaaaaaaaa##################aaaaaaaaaaaaaaa#",
"#####aaaaaaaaaaaaaaaa##################aaaaaaaaaaaaaaa#",
"#####aaaaaaaaaaaaaaaa##################aaaaaaaaaaaaaaa#",
"####.aaaaaaaaaaaaaaaa##################aaaaaaaaaaaaaaa.",
"####aaaaaaaaaaaaaaaaa##################aaaaaaaaaaaaaaaa",
"####aaaaaaaaaaaaaaaaa#################.aaaaaaaaaaaaaaaa",
"####aaaaaaaaaaaaaaaaa.################aaaaaaaaaaaaaaaaa",
"####aaaaaaaaaaaaaaaaaa################aaaaaaaaaaaaaaaaa",
"###.aaaaaaaaaaaaaaaaaa################aaaaaaaaaaaaaaaaa",
"######################abbbbbbbbbbbbbba#################",
"######################abbbbbbbbbbbbbba#################",
"######################abbbbbbbbbbbbbb.#################",
"#######################bbbbbbbbbbbbbb##################",
"#######################bbbbbbbbbbbbbb##################",
"#######################bbbbbbbbbbbbbb##################",
"#######################bbbbbbbbbbbbbb##################",
"#######################################################"
};