Commit 1b6ed632 authored by Andreas Tille's avatar Andreas Tille
Browse files

New upstream version 2.0.4

parent 8db86df6
Loading
Loading
Loading
Loading
+31 −0
Original line number Diff line number Diff line
2018-06-22 NUTsqlite-2.0.4 released.

2018-06-22 Found a bug in RecipeDone.  100 gram weight record was wrong.

2018-06-17 NUTsqlite-2.0.3 released.

2018-06-17 Load of USDA database is leaving a carriage return and tilde at the
           end of each food group.  Fixed in proc load_fd_group.  Also updated
           GUI to show correct percentages of carbs and fat in new Daily Values.

2018-06-10 NUTsqlite-2.0.2 released.

2018-06-10 Windows 10 user "Darwin" found some code in proc FoodChoicevf which
           which doesn't work right on his operating system.  It's a thread
           problem in conjunction with the tcl/sqlite interface.

2018-06-07 NUTsqlite-2.0.1 released.

2018-06-07 Procedure which clears the weight log was not updated to match
           bigNUT, so I fixed ClearWeightLog.

2018-05-30 NUTsqlite-2.0 released.

2018-05-30 It looks and acts pretty much the same, but it's a new program made
           up of snippets of the old program stitched together in a new way.
           bigNUT is the back-end, the GUI is threaded, and the performance is
           superb.  All computations and logic are now done by SQLite rather
           than Tcl.  bigNUT uses triggers to keep all the data for the display
           up-to-date, so that Tcl only translates user commands into SQL and
           then retrieves all relevant data to refresh the GUI as necessary.

2017-06-26 NUTsqlite-1.9.9.6 released.

2017-06-20 Multiple changes:  special commented-out code to make it easier to
+39 −37
Original line number Diff line number Diff line
<PRE>
NUT nutrition software
Copyright (C) 1996-2017 by Jim Jozwiak.
Copyright (C) 1996-2018 by Jim Jozwiak.

   NUT is nutrition software to record what you eat and analyze your meals for
   nutrient composition.  Besides the usual features of nutrition software, NUT
@@ -9,15 +10,11 @@ Copyright (C) 1996-2017 by Jim Jozwiak.
   also offers a well-organized presentation of the nutrients that can help you
   learn human nutrition by simply playing with the software.

   The advantage of using NUTsqlite is that the database is portable across
   disparate operating systems and can be queried independently of the NUTsqlite
   application by using common SQLite tools.  The exact code that runs the
   application is in the database itself, so there is no version incompatibility
   if you move the database to a different system or decide to update the USDA
   tables.  And unlike the legacy implementation of NUT, NUTsqlite preserves
   enough of the previous USDA databases to always retain referential integrity
   among the relational tables such as in the case where the USDA deletes a food
   that you ate in some earlier meal.
   NUTsqlite-2.x offers better performance with a newly structured SQLite 
   database that features fully normalized relational tables.  In addition,
   the database itself is functional even without the graphical user interface,
   so it can be used on any device that presents a shell and has sqlite3
   installed.

INSTALLATION of NUTsqlite

@@ -34,40 +31,45 @@ INSTALLATION of NUTsqlite
   separate directory, so you need to move all these files to the single 
   directory you are going to use.

3) Run "updateNUT.tcl" to create or upgrade the NUT code in the SQLite database
   that runs the application.  If upgrading, you have to be in the same
   directory as the "nut.sqlite" file, or else you have to modify
   "updateNUT.tcl" on line 24 to provide the full path to the "nut.sqlite" file.
3) Run "./updateNUT.tcl" to create or upgrade the NUT code in the SQLite
   database that runs the application.  If upgrading, you have to be in the same
   directory as the "nut.db" file, or else you have to modify
   "updateNUT.tcl" on line 24 to provide the full path to the "nut.db" file.
   After this step, "updateNUT.tcl" is not required for anything and can be
   deleted.  Unlike the legacy implementation of NUT, updating the NUT code is
   independent of updating the USDA database, although it is certainly possible
   that the USDA could change the format of their tables so that a later version
   of "updateNUT.tcl" would be required in order to read their tables or display
   deleted.  Updating the NUT code with "updateNUT.tcl" is independent of
   updating the USDA database, although it is certainly possible that the USDA
   could change the format of their tables so that a later version of
   "updateNUT.tcl" would be required in order to read their tables or display
   new nutrients.  The main idea is that your personal data is permanent even
   though the application code and USDA tables can change as necessary.

4) Run "nut.tcl" to run NUT.  If you are using a launcher and cannot specify the
   working directory, you will have to modify "nut.tcl" on line 27 to specify
   the full path to "nut.sqlite".  When "nut.tcl" runs initially, it will load
   the USDA files and any legacy files that exist in your .nutdb directory,
   including all your meals if you have just run the legacy NUT console program
   which dumps meals in a manner that can be read from Tcl.  After NUT performs
   the initial database load, the USDA files can be deleted and NUT will not
   load any more files until it detects a new USDA database in the directory
   from which NUT is running.  All "nut.tcl" really does is to start Tcl and
   cause Tcl to run the code in the SQLite database.  Because the code in the
   database does not have to be interpreted until required, there may also be
   better performance from the application.
   Mac users should do this step from "Terminal" or else modify "updateNUT.tcl"
   adding a line to "cd" to the directory to be used.

5) If you prefer NUTsqlite to the legacy implementation, the directory ".nutdb"
   can be deleted so it will not be loaded again when you next wish to update
   the USDA database.  Alternately, you can simply modify line 26 of "nut.tcl"
   to look for some non-existent directory as the legacy directory.  Another
   easy change to "nut.tcl" is the location of the SQLite database file.  There
   is also a variable "appSize" that can control the size of the window and
   fonts when set between approximately 0.7 to 1.3.
4) If you are using a launcher and cannot specify the working directory, you
   will have to modify "nut.tcl" on line 27 to specify the full path to
   "nut.db".  This is especially important for Mac users.

   Another easy change to "nut.tcl" is the location of the SQLite database file.
   There is also a variable "appSize" that can control the size of the window
   and fonts for Linux users when set between approximately 0.7 to 1.3.  
   Windows and Mac users should leave the value of appSize at 0.0 unless they
   have determined the Linux GUI can work well with their system.

5) Run "nut.tcl" to run NUT.  When "nut.tcl" runs initially, it will load
   the USDA files and any personal data that exists in the NUTsqlite version 1
   database, nut.sqlite.  After NUT performs the initial database load, the USDA
   files can be deleted and NUT will not load any more files until it detects a
   new USDA database in the directory from which NUT is running.  All "nut.tcl"
   really does is to start Tcl and cause Tcl to run the code in the SQLite 
   database.  Because the code in the database does not have to be interpreted
   until required, there may also be better performance from the application.

6) The legacy file "nut.sqlite" will no longer be used.  The new database name
   is "nut.db" and often has two auxiliary files that must not be deleted
   because to do so corrupts the database.

Jim Jozwiak
http://nut.sourceforge.net
jozwiak@gmail.com
</PRE>
+34 −0
Original line number Diff line number Diff line
/*
  Custom script to add next meal automatically.  Invoke it thus:
	.read nextmeal.sqlite3
	.read sequence.sqlite3
  This is something NUTsqlite can't do, complicated meal ordering with
  automatic changes to personal options!
*/

begin;

update mealfoods set nutr_no = null;
update options set defanal_am = (select case when defanal_am >= 45 then 45 when o.currentmeal = lastmeal then defanal_am + 1 else defanal_am end from options o, am_analysis_header);

with newcm (meal_id) as (
 with cm1 (base, meal) as (
  with cm (base, meal) as (
@@ -16,12 +21,14 @@ with newcm (meal_id) as (
 )
update options set currentmeal = (select meal_id from newcm);

with meal_name (mn) as (
 with meal (m) as (
  select currentmeal % 100 from options
  )
 select case when m = 1 then 'BC' when m = 2 then 'DC' else 'SC' end from meal
drop view if exists z_mn;
create temp view z_mn as
 with meal (m, mod2) as (
  select options.currentmeal % 100, maxmeal % 2 from options, am_analysis_header
  )
insert into currentmeal select NDB_No, Gm_Wgt, NutrDesc from theusual where meal_name = (select mn from meal_name);
 select case when mod2 = 0 then case when m = 1 then 'K Breakfast' when m = 2 then 'K Dinner' else 'K Supper' end else case when m = 1 then 'K Breakfast' when m = 2 then 'K Dinner' else 'K Supper' end end as mn, m from meal;

insert into currentmeal select NDB_No, Gm_Wgt, NutrDesc from theusual where meal_name = (select mn from z_mn);
drop view z_mn;

commit;
+36 −0
Original line number Diff line number Diff line
/*
  Custom script to add next meal automatically.  Invoke it thus:
	.read sequence.sqlite3
  This is something NUTsqlite can't do, complicated meal ordering with
  automatic changes to personal options!
*/

begin;

with newcm (meal_id) as (
 with cm1 (base, meal) as (
  with cm (base, meal) as (
   select currentmeal / 100, currentmeal % 100 from options
   )
  select case when meal = 3 then date(substr(base, 1, 4) || '-' || substr(base, 5, 2) || '-' || substr(base, 7, 2), '+1 day') else substr(base, 1, 4) || '-' || substr(base, 5, 2) || '-' || substr(base, 7, 2) end, case when meal = 3 then 1 else meal + 1 end from cm
  )
 select cast( substr(base, 1, 4) || substr(base, 6, 2) || substr(base, 9, 2) as int) * 100 + meal from cm1
 )
update options set currentmeal = (select meal_id from newcm);
update options set defanal_am = 1;

drop view if exists z_mn;
create temp view z_mn as
 with meal (m) as (
  select currentmeal % 100 from options
  )
 select case when m = 1 then 'R Breakfast' when m = 2 then 'KC Dinner' else 'R Supper' end as mn, m from meal;

insert into currentmeal select NDB_No, Gm_Wgt, NutrDesc from theusual where meal_name = (select mn from z_mn);

update nutr_def set nutopt = 0.0 where NutrDesc = 'Total Fat';
-- update nutr_def set nutopt = case when (select m from z_mn) in (1, 3) then 125.0 else 140.0 end where NutrDesc = 'Protein';

	with temp (meal2nfc) as (select sum(Nutr_Val * Gm_Wgt / 100.0) from mealfoods join nut_data nd using (NDB_No) where nd.Nutr_No = 2000 and meal_id = (select max(meal_id) from mealfoods where meal_id % 100 = 2)) update nutr_def set nutopt = case when (select m from z_mn) in (1, 3) then (180.0 - (select meal2nfc from temp)) * 1.5 else -1 end where NutrDesc = 'Non-Fiber Carb';

commit;
+35 −0
Original line number Diff line number Diff line
/*
  Custom script to add next meal automatically.  Invoke it thus:
	.read sequence.sqlite3
  This is something NUTsqlite can't do, complicated meal ordering with
  automatic changes to personal options!
*/

begin;

with newcm (meal_id) as (
 with cm1 (base, meal) as (
  with cm (base, meal) as (
   select currentmeal / 100, currentmeal % 100 from options
   )
  select case when meal = 3 then date(substr(base, 1, 4) || '-' || substr(base, 5, 2) || '-' || substr(base, 7, 2), '+1 day') else substr(base, 1, 4) || '-' || substr(base, 5, 2) || '-' || substr(base, 7, 2) end, case when meal = 3 then 1 else meal + 1 end from cm
  )
 select cast( substr(base, 1, 4) || substr(base, 6, 2) || substr(base, 9, 2) as int) * 100 + meal from cm1
 )
update options set currentmeal = (select meal_id from newcm);

update nutr_def set nutopt = -1 where nutrdesc = 'Total Fat';
update nutr_def set nutopt = 0.0 where nutrdesc = 'Non-Fiber Carb';
update options set defanal_am = case when defanal_am >= 45 then 45 else defanal_am + 1 end;

drop view if exists z_mn;
create temp view z_mn as
 with meal (m, mod2) as (
  select options.currentmeal % 100, maxmeal % 2 from options, am_analysis_header
  )
 select case when mod2 = 0 then case when m = 1 then 'R Breakfast' when m = 2 then 'R Dinner' else 'R Supper' end else case when m = 1 then 'P Breakfast' when m = 2 then 'P Dinner' else 'P Supper' end end as mn from meal;

insert into currentmeal select NDB_No, Gm_Wgt, NutrDesc from theusual where meal_name = (select mn from z_mn);
drop view z_mn;

commit;
Loading