The Hacker's Diet®Eat Watch® for the Palm Computing® Platformby John Walker |
But that was then, and this is now (2000). Never did I imagine when writing the original macros that Microsoft's unique blend of incompetence and contempt for their customers' investment would cause those macros (like virtually every other Excel macro package all around the world, except for the most trivial) to break on almost every successive release of Excel, all along the tedious, tear-drenched trudge from Excel 2.1 to Excel 2000; that ever steepening spiral into the foul pit of intellectual corruption from the days of "386 Enhanced Mode" to the era of the talking paper clip.
But I digress. Due numerous experiences with shoddy quality and incessant incompatibilities in Microsoft products, in 1996 I abandoned all new software development for that platform. But the computer tools for The Hacker's Diet remained wedded to Excel, a proprietary platform which history had proven notoriously shaky and likely to continue to degrade since Microsoft abandoned the macro language in which I developed the tools in favour of an even worse one based on Visual Basic. Today, Microsoft provides little or no documentation of or support for the original macro language in current releases of Excel.
With a PalmPilot version of the Eat Watch, there's no need to keep a paper log at all! If you're a proper geek like myself, your PalmPilot is never far from reach (just like a slide rule in days of yore), especially since it, unlike the slide rule, can serve as an alarm clock. What could be simpler? Get up, weigh yourself, write the weight into the PalmPilot and get instant feedback, including an up to date chart. The ability to synchronise data on the handheld with your desktop computer allows backing up log data against the inevitable day the dog eats your PalmPilot or some other mishap befalls it, and having the data on the desktop allows deploying an application there which produces permanent logs and charts in HTML, an open standard which can be examined with any Web browser or even (if you're particularly vain and/or proud of your progress), posted on a Web site!
Just a simple matter of programming...months pass....et voilà! Like most Palm applications, the Eat Watch is organised into a collection of forms, each of which is discussed in the following sections. The program contains a number of Palm-style shortcuts and gimmicks to reduce the number of taps and characters you have to write; they are highlighted in the text with the icon.
When you enter a weight and close the field (by writing Return or tapping in a different field) the trend is calculated for that day and the Variance (difference between today's weight and the trend) appears in the "Var" field, positive if the weight is above the trend, negative if below. Weight and variance are displayed to one decimal place for kilograms and pounds. When stones (a predominantly British unit of weight equal to 14 pounds) are chosen as the weight unit, weight is shown in stones and pounds separated by a space; for example, a weight of 152 pounds would appear as "10 12". No decimal places are shown for pound weights accompanying stones but you may enter them when making log entries. When you display the log in pounds or kilograms, you'll see the decimals. When weight is set to stones, variance continues to be shown in pounds--a variance of one or more stones would indicate something seriously amiss! You can enter weight with up to two decimal places (one when using stones), but it's rare to find a scale which shows weight to a resolution better than 100 grams, nor are such tiny increments in daily weight at all relevant to achieving and maintaining your weight goal.
If you're following the exercise program presented in The Hacker's Diet, use the "Rung" field to record which rung on the exercise ladder you completed that day. You can use the Flag ("Flg") field to mark any recurrent event you're interested in keeping track of on an ongoing basis, for example, whether you found the time for a game of tennis or had an ice cream snack before turning in for the night. The "Comments" field can be used record any text you like (up to 80 characters, just like a punch card). In this example the user observes that on the 23rd and 24th of September she was in Paris, explaining the missing weight and exercise entries as well as, perhaps, the positive variance recorded upon her return.
The navigation arrows at the top right of the form permit you to scroll to prior and subsequent months (if any). In the example, the month displayed is the current month and hence only the previous month button is shown. Tapping the "Year" button at the bottom displays the Year View form which provides quick navigation to other months and years in the database. The "Chart" button shows a weight, trend, and exercise chart along with a trend analysis for the month. The "Trend" button displays longer-term trend analyses.
To duplicate the previous nonblank item in a column, write a period in
the field (just "tap-tap" with the stylus followed by a return).
This is handy for entering exercise rung entries, which change
infrequently and rarely at all once you've reached your goal. If you use
the comments field to note when you're out of town, you can just
double tap when you're in the same place as the day before.
If you must enter a comment consisting of a single period, just write
a space after it.
Abbreviated Weight Entry. Weight generally changes little from day to day, but if your scale reads to the nearest 100 or 200 grams (or the equivalent in pounds), a given day's weight will rarely be identical to that of the day preceding. This limits the utility of the field copying trick discussed in the last paragraph. The monthly log form permits you to abbreviate weight entries which differ slightly from the last. If you write the decimal character (period or comma, as selected on the Formats page of the Preferences application) followed by a single digit, the previous weight entry will be copied with the decimal digit replaced by the digit you wrote. For example, if yesterday's weight was 73.8 kg and you write ".6", today's weight will be entered as 73.6 kg. Similarly, writing a single digit followed by the decimal character and a second digit copies the previous weight, replacing its units and decimal place with those you entered. If yesterday you weighed 158.2 pounds and today you tipped the scale at a mere 157.9, you need only write "7.9" to enter today's weight. If the decimal place is zero, you need not write it--simply write the units digit followed by the decimal character.
When the weight unit is set to stones you may use the abbreviations
Previous Weight | You Write | New Weight |
---|---|---|
11 9 | 6. | 11 6 |
11 6 | 4.8 | 11 5 |
10 11 | 2. | 10 12 |
10 11 | 9. | 10 9 |
10 9 | 10.2 | 10 10 |
If you haven't yet written in today's weight, writing a number into
the Graffiti area opens today's Weight field for editing and places
the character into it. Thus you can enter the weight without having
to first tap in the field. You can also open today's weight field for
editing by tapping the "Today" button when no weight has been
entered for the day.
Tapping the heading of the "Rung" column takes you directly to the
Exercise Ladder reference form, showing the
daily exercises for your current rung. When you've completed the
exercises, tap the "Record" button on that form to fill in today's
rung field and return to the log form.
Would you like to see your weight in different units than the one
you've chosen for your logs in the
Preferences form? Tap the Menu button to the left
of the Graffiti area, drop down the View menu and tap the unit
you wish: Kilograms, Pounds, or Stones. The log will be re-displayed
in the chosen unit and you can, if you wish, make additional entries
in that unit (handy when visiting a country where
a different unit is prevalent and you don't want to convert every
day's weight by hand). The chosen display unit is also used
by the Chart or Trend
Analysis forms, both of which may be reached from the View menu.
Changing the display unit only affects how weight is displayed
and entered: entries in the log continue to be kept in the
"Log Unit" you've selected on the Preferences form.
The View menu also permits direct navigation to the
calendar-like Year View form,
a list of all years for which logs
exist, an exhaustive list of logs by
year and month,
the exercise ladder reference,
and the diet calculator.
The Chart menu allows you to display
historical charts of various
durations.
If you've enabled "Protect Log Entries" in the
Preferences form (enabled by default,
and recommended), nonblank log entries for days prior to
the current date and entries for dates in the future are
protected against being opened for editing by accidental taps;
taps in them are ignored. If you discover an error in a past
entry and wish to correct it, you could use the Edit menu to
display the Preferences form, turn off protection, correct
the entry, then enable protection again, but that's a bit tedious,
and you might forget to turn protection back on after correcting
the error. Instead, you can temporarily disable protection for
a prior (but not future) date simply by tapping twice in
succession in its day and weekday field at the left of the
table; the field is inverted to indicate the day is unlocked.
You can then tap any single field of that day for
editing and correct the entry. When you close the field,
protection is restored for the day and its label is
redrawn non-inverted. (If you need to correct more than one
item in a day's entry, simply unlock it as many times as
required.)
If the monthly log contains any entries in the exercise Rung column, a dotted line is plotted showing daily exercise level (blank for any day the Rung is not filled in) with a Rung scale from 1 to 48 at the right of the chart. The scale is adjusted so the last rung in the chart is explicitly labeled.
If the month displayed is within or after the conclusion of a diet plan created by the Diet Calculator, and the user has indicated the plan should appear in the chart, the plan is drawn as a dashed line, with dates after the end of the plan shown as a horizontal dashed line at the plan's goal weight. By comparing the actual trend as it evolves with the plan, you can evaluate your progress toward the goal. After arriving at the goal, the constant goal weight provides a reference for evaluating the subsequent evolution of the trend.
You can navigate to earlier and later months by tapping the navigation buttons at the upper right of the form (in this case the user is viewing the most recent month in the database so only the previous month button is shown). The "Log" button returns you to the log for the month shown in the chart, while the "Year" button displays the Year View of that containing the chart.
Menus similar to those in the Monthly Log permit direct navigation from a monthly chart to other forms.
Tap on a day within the chart to display the log for that month with
the day you tapped on visible in the log.
Historical charts covering a 30 day interval differ from Monthly Charts in that the latter always show days of a single month, while 30 day historical charts display a 30 day period which may span month boundaries. In the early days of a month a 30 day historical chart may give you a better perspective on the evolution of the trend than a monthly chart which only shows a handful of days. 30 day historical charts plot weight and flag entries as "floats and sinkers" in the same form as monthly charts, but these are excluded from longer-term charts in which they would create such clutter as to render them useless. Over periods of a quarter or longer, only the trend really matters anyway.
Historical charts displayed from the Monthly Log or Chart forms cover a period ending on the last day of the month or today's date if the current month is displayed and not yet completed. You can navigate to earlier and later periods in the database by tapping the left and right arrows at the right in the title bar. If the present chart contains the first or last date present in the logs, the arrow buttons will not appear. The duration of the chart is shown both by the title and by the box checked at the bottom right of the form. Tapping a different duration box shows a chart of that duration ending at the same date as the present chart. (When a chart of the entire database is shown, none of the duration buttons are checked, but you may still tap them to select different duration charts ending at the current date.)
The "Year" button shows the Year View form to provide quick navigation to other months and years in the database. The "Today" button displays the Monthly Log with today's date scrolled into view, and the "Trend" button shows the trend analysis form. Menus provide navigation to all the other forms.
Tapping within the chart area displays the
Monthly Log
for the date you tapped.
The calculations required to fit a trend to the log data are substantial and take a while--about 12 seconds on a Palm IIIx. If there aren't enough monthly logs in the database to compute the trend for a given period, its row in the Trend Analysis form is left blank.
The "Today" button takes you back to the monthly log entry for the
current day, while the "Done" button returns you to the top of the
current Monthly Log.
The Diet Calculator is displayed from the View menu of the Monthly Log, Monthly Chart, or Historical Charts forms. When you first display the Diet Calculator, the daily calorie balance is set to -500 calories per day (which results in the loss of about a pound per week, as discussed in the book), and the initial weight to the most recent trend value, rounded to the nearest whole number. Weights are shown in the display unit selected in the Preferences form, and may be changed by tapping the units shown to the right of the form title. The initial goal weight is arbitrarily set to 5 kilograms or 10 pounds less than the starting weight; adjust this to your personal weight goal. The default starting date of the diet is the current date; The "Weeks to go" and "Months to go" fields will then show the duration of the diet and the "End date" when you may expect to achieve the goal weight.
This form is fully associative--you may change any quantity and the form will recalculate the others accordingly. Setting the daily calorie balance adjusts the weight change per week, duration, and end date of the diet. The calorie balance should be negative if you wish to lose weight and positive if your intention is to gain weight. You may change the initial weight and goal weight to any values you wish, which adjusts the desired weight change and recomputes the duration of the diet. If you change the desired weight change, the goal weight is modified to reflect the new difference from the initial weight and the diet duration recalculated. Changing the start date adjusts the end date based on the estimated duration of the diet. Adjusting the weight change per week, weeks or months to go, or the end date modifies the daily calorie balance to achieve the desired weight change in the specified period of time.
The values you specify in the Diet Calculator are saved and reappear when you return to the Diet Calculator. If you check the "Show plan in chart" box, the course of the planned diet is shown as a dashed line in the Monthly Chart displays for the duration of the diet and subsequently as a horizontal dashed line representing your weight maintenance goal. If you find this distracting, simply uncheck the box. The Done button takes you back to the current month's log.
To plot the goal weight in charts without the sloping diet
plan, set the initial and goal weights to the same value and the
start date before the first month in the log.
The Palm tools include a concise exercise ladder table. There's no need to keep a print-out of the table from the book, and you'll always have the table at hand even when you're on the road. No description of the exercises is given; if you're doing them every day, as recommended, the column headings will suffice. For more details, consult the exercise chapter in the book.
You can display the exercise ladder by choosing it from the View menu of the Monthly Log form or by writing its shortcut letter "E", but it's easier by far to just tap the title of the "Rung" column in the Monthly Log form, which brings you directly here. Once the exercise ladder is displayed, scroll to your current rung and tap it--it changes to bold type and when you return to the form it will automatically be scrolled into view.
After you've completed the exercises for a given a day,
tap the "Record" button; it will enter the current rung, shown
in bold, into the "Rung" field in today's log entry and
take you back to the Monthly Log
form with today scrolled into view.
The "Today" button returns you to the
Monthly Log item for the current date.
The "Chart"
button shows a weight, trend, and exercise chart along with
a trend analysis for the month. The
"Trend" button displays longer-term
trend analyses.
The "Today" button returns you to the Monthly Log item for the current date; the "Years" button displays the Year List form.
To enter historical data for months in the past not present in
the database, navigate to the year and tap the month you wish
to create (which will be shown in normal type, as it is not
yet in the database). An alert pops up which asks you
whether you wish to create a new blank log for the month
you tapped; choosing "Yes" creates the log and displays it
in the Monthly Log form.
To view a list of each and every monthly log in the
database, tap the "Months" button.
The "Trend" button displays the Trend
Analysis form; the "Today" button returns you to the
Monthly Log showing today's date.
The trend at the start of a month depends upon the trend at the end of the preceding month, and so on all the way back to the first month in the database. Because trend computation is a computationally intensive task for a handheld platform, the Eat Watch application stores the trend carried forward from the previous month with the log data for each month, avoiding the need to compute the trend for previous months except in unusual situations (for example, if you import a CSV file containing data for a month in the past, or enter or modify data for a prior month). This is all handled automatically.
These stored trend values are "fragile" in the sense that if a
hardware or software error should manage to clobber the trend,
it will result in incorrect trend and variance computation for
all entries for the month, and there's no direct way to enter
the correct trend carry forward to replace the bad value. To
guard against such an eventuality, Eat Watch provides the
ability to completely recompute all trends from the fundamental
log entries. To perform this, drop down the "Special" menu
(available only on the Month List form) and tap "Recompute
Trend". The title of the form changes to "Recomputing Trend -
Wait" while the computation is in progress, then returns to the
normal "Monthly Logs" title when it is complete. This
recomputation can take a while--a minute or more for a decade's
worth of logs. You'll probably never need to use this
feature, but it's there just in case.
If you've marked log data private in the
Preferences form, Find will search Eat Watch
logs only if private records are not marked hidden by the Security
application.
Let's assume you've exported your Excel log for the year 1997 into a file named weight97.csv. Now you need to embed that file in a Palm database so the Eat Watch application can digest it. The PDBMake desktop utility, available for downloading from this site, allows you accomplish this. From the command line, navigate to the directory in which you've placed the .csv file and enter the command:
pdbmake -a -c HkDt -t Wcsv -n weight97 weight97.csv
If your .csv file has a name other than weight97.csv, enter that name after the -n option and as the input file name which follows it. Be careful to enter the -c and -t option arguments exactly as shown above including upper and lower case (Palm developers will recognise these as the creator code and database type, which an application uses to identify files belonging to it.)
If all goes well, you'll now have a weight97.pdb (or whatever you called it) in the directory containing the original CSV file which consists of the contents of the CSV file embedded line by line as successive records in the database. (If you'd like to look inside this or other Palm database and application files, download a copy of the Palmdump desktop utility from this site.)
Now use your desktop installer utility to copy the .pdb file to the Palm desktop install directory and HotSync your handheld to the desktop. This will transfer the database containing the CSV file to the handheld. When the HotSync is complete, launch the Eat Watch application. Whenever launched, it checks for CSV files transferred since it was last run. If one or more are present, the CSV Import form is automatically displayed. This form reads each CSV file in succession, adding valid entries to the handheld log database. A progress display shows the CSV file currently being imported (the name you gave after the -n option when you ran PDBmake) and the line in the file. After completing each CSV file, it is deleted from memory in the handheld. You can import as many different CSV files as you like in one session as long as there is enough free memory on the handheld to store them and you remember to give each file a different name with the PDBmake -n option so they don't delete one another when they're installed. When all CSV files have been imported, the "Cancel" button changes to "Done" which, when pressed, takes you to the Year List form from which you can navigate to examine the logs you've just imported.
- Date
- Complete date of the entry, which may be expressed in any of the following forms, using July 20th, 1999 for the examples:
Format Example(s) ISO 8601 1999-07-20 European 20.07.1999 20.7.99 North America 7/20/1999 07/20/99
Leading zeroes may be supplied or omitted in all formats. Two-digit year numbers 70 or greater are interpreted as 1970-1999 while those 69 or less denote 2000-2069. Any line in the CSV file which does not begin with a valid date in one of these formats is silently ignored. This allows processing CSV files which contain headings or other material in addition to log entries. Dates need not be in ascending order, but CSV importing is faster if all the entries for a given month appear as a block of consecutive lines.
- Weight
- Daily weight, as a decimal number. Decimal places beyond two are truncated (not rounded). If no weight was recorded for the day, this field may be blank. Weights are stored in the log using the Log unit you've chosen in the Preferences. If you need to import a log recorded in different units, you must convert it to the log unit on the handheld before importing it.
- Exercise Rung
- Rung in the exercise program completed for this day. This is a whole number between 1 and 48 (this is validated and the log entry ignored if outside this range--you can't use this field as an arbitrary number), or blank if you're not using the program or didn't exercise that day.
- Flag
- This field sets the "Flag" checkbox in the Monthly Log, which you can use to record any significant daily yes or no item (for example, did you work out at the gym that day, or have pizza for lunch?). If the field is blank or the first character is "0" the flag is not set; any other value sets it.
- Comment
- This field supplies arbitrary text to appear in the comment field in the day's Monthly Log entry. Comments are limited to 80 characters, with longer comments in the CSV file truncated to this length. If the comment contains a comma, you must enclose the comment field in double quotes ("). To include a quote within a quoted comment, use two adjacent quotes. Within a quoted comment you can use "\" followed by three octal digits to insert an arbitrary character or "\\" to include a backslash itself.
If you view your weight and exercise log as something worth keeping as a memoir of your own progress toward, and maintenance of, your personal weight and fitness goals, you'll feel better knowing there's a backup on your desktop computer and its own backup media every time Rover looks enviously at your Palm and drools a little when you're paying attention to it rather than petting (or better yet, feeding) your Best Friend.
After performing a HotSync with the Eat Watch application installed, you'll find a binary copy of your log database on the handheld as a Months-HkDt.PDB file in the Backup directory of the Palm user name assigned to the handheld. For a typical installation on a Windows machine for user "Bugbert", the file might be found at:
C:\Palm\Bugbert\Backup\Months-HkDt.PDB
When Rover is caught, flagrante delicto, with the shattered remains of your Palm and fixes you with a slobbery grin and blames it on the cat, it's nice to know you've only lost any log entries you made since the last HotSync; you need only re-install the Eat Watch application and your backed-up database and you're back in business. Of course, bad things befall desktop computers as well, so be sure you regularly back up that machine to removable media (ideally kept off-site periodically, in case of catastrophe such as fire or a bad asteroid day) so you can restore it should the need arise. (Machines at Fourmilab are backed up nightly to DLT tape on a backup server, with full dumps of each performed every Friday which are stored off-site and kept forever. All Web site content is backed up nightly to two local backup servers configured to take over should the principal Web server fail, and across the Net to a mirror site located in the other hemisphere as a hedge against Really Bad Days. "Paranoid!", you exclaim. Damn straight, and I always appreciate compliments--got any more?)
Now that there's a copy of your Eat Watch log database on the desktop, updated every time you HotSync, it almost cries out, read me, read me! Indeed...read on to discover how to use HDread to export data from the backup of your handheld's log database in a variety of formats, including illustrated log and chart documents you can view with any graphical Web browser. HDread can also export handheld databases in comma-separated value (CSV) format, which most spreadsheets and database programs can read. You can dump the CSV output from HDread with the csvread utility, whose source code includes everything you need to build your own analysis programs to process the Eat Watch databases.
Documentation for HDread follows, in Unix manual page style.
NAMEHDread - export Palm Eat Watch database to desktop database files SYNOPSIShdread [ -c -d -h -j -u -v -x ] [ -o ocsvfile ] [ -p hrfile ] infile DESCRIPTIONHDread exports Eat Watch Palm databases (Months-HkDt.pdb) files in a variety of formats, including illustrated HTML which can be viewed with any graphical Web browser. OPTIONS
FILESIf YYYY is the year and MM the month, CSV files written by the -c option are named YYYY-MM.csv. HTML output from the -h option generates log and chart files named YYYY-MM.html and YYYY-MM.gif, respectively, which are linked to an index file named calendar.html. All -c and -h option output files are created in the current directory. BUGSSome folks will undoubtedly natter that a stand-alone, command-line conversion program is a dinosaur in the age of conduit plug-ins and graphical user interfaces. But consider, you already have a powerful graphical interface tool on your computer--the very Web browser you're using to read this document! By exporting log data as HTML, with accompanying charts in GIF images, HDread allows you to use your browser, with which you're already familiar, to view the log data on the desktop, instead of having to learn another special-purpose application. Further, since HDread is written in portable C, it can be made to run on almost any computer and operating system--even those for which Palm Computing provides no conduit support. As long as you can physically transfer the Months-HkDt.PDB database to your computer (tools for accomplishing this task exist for most variants of Unix and other widely-used operating systems), HDread and a Web browser are all you need on the desktop side. SEE ALSOpalmdump(1), fopen(3) |
Documentation for csvread follows, in Unix manual page style.
NAMEcsvread - print Palm Eat Watch database exported in CSV format SYNOPSIScsvread [ -u ] [ ofile ] DESCRIPTIONcsvread reads CSV files containing data exported from Eat Watch databases by HDread and prints them in a primate-readable format. OPTIONS
FILESOutput is written to the specified ofile. If no ofile is given, output is written to standard output. BUGSNone. SEE ALSOfopen(3), HDread(1) |
Use any Zip utility to extract the contents of this archive, eatwatch.prc, a PalmOS executable resource file. Use your desktop Palm application installer to mark this file for installation on your handheld, then HotSync the handheld to the desktop, which will install the application on the handheld. (The precise details of this process vary from one desktop client to another--consult the documentation for the one you're using if you need additional information on how to install applications.)Download Eat Watch 1.11 for PalmOS
When you go back to the Application Launcher, you should
see the Eat Watch icon shown to the right. If you don't
see it, you may have to scroll it into view and/or switch
to the "Unfiled" category into which new applications are
placed. Tap the Eat Watch icon to launch the application. The
first time it's launched, you'll see the
Preferences form; use the list items to choose
the weight unit in which you'd like to store and view your log
entries (you should set both to the unit in which your scale at
home uses--you can change the display unit when you travel
to a region where a different unit is commonplace). When you tap
OK, a blank log for the current month is shown with today's
date scrolled into view; this is the view you'll see from now on
when you launch Eat Watch. If you have existing logs kept with
a different application, you can now use the
CSV import facility to transfer them to
your handheld.
Source code is supplied as a Zipped archive containing subdirectories. When you unzip, be sure to specify the option which preserves directory structure in the archive. Otherwise the directory tree will be flattened and none of the definition files included will work. You're welcome to use this source code in any way you like, but absolutely no support is provided; you're entirely on your own.Download Eat Watch 1.11 Source Code for PalmOS
Download HTML Log Icon Images
Source code is supplied as a Zipped archive without any subdirectories. Source files use the Unix end-of-line convention (line feed without carriage return); most DOS/Windows C compilers accept such files without problems, but if your compiler is picky you may have to convert them to DOS carriage return / line feed format. Unix users should examine the Makefile and set the C compiler and options suitably for their system. The Windows version was built using Monkey C: Microsoft Visual C 5.0 (with "service pack" 3 installed). The archive contains Monkey C "workspace" (.dsw) and "project" (.dsp) for this compiler. Microsoft being Microsoft, all bets are off if you use these files with a later version of the compiler. If you're using a different compiler, you'll have to create a make file or IDE project definition by hand--refer to the Unix Makefile for a list of which components are included in each program. You're welcome to use this source code in any way you like, but absolutely no support is provided; you're entirely on your own.Download Eat Watch Desktop Utilities Source Code