Chapter 7. Adding recipes

Table of Contents

7.1. When to use recipes
7.2. Creating a recipe
7.2.1. Creating a recipes file and its root element
7.2.2. Creating the recipe element
7.2.3. Setting the yield of a recipe
7.2.4. Setting the ingredients of a recipe
7.2.5. Setting the available units for a recipe
7.3. Using recipes
7.4. Validation of Recipes XML files

So far, you know how to add your own foods to Pantry. However, to add a food, you have to know what its nutrient content is. If you have a food that is a mixture of several different foods, then making a recipe can help. You'll learn how to do that in this chapter.

7.1. When to use recipes

The basic building block of Pantry is the food. Each food has traits, nutrient content, and available units. In Pantry, you can combine several foods into one single food using recipes. Thus, for example, you can combine corn meal, flour, water, baking powder, sugar, salt, and eggs using a recipe. The result will be a single food that you can call corn bread. This new food will have traits, available units, and nutrients, just like any other food in Pantry.

After you create a recipe in Pantry, Pantry knows only the traits, available units, and nutrients of your new food. For example, after you create your corn bread recipe, Pantry does not know what the ingredients of corn bread are. It knows only the traits and the nutrient breakdown of corn bread. You can then use corn bread just as you would use any other food. Because a recipe is a combination of other foods, each ingredient in the recipe must come from an existing Pantry file.

Sometimes using a recipe is overkill. For example, say you have a few foods that you always eat together in a certain quantity. It can be much quicker and easier to simply give these foods a common group trait. For example, I often eat two ounces of cold cereal with one cup of milk. I could create a recipe for these foods. Instead, I have simply added both of these foods to my quick file, and I have changed the group trait of both foods to Cereal and Milk. Then, when I want to record in my diary that I have eaten these two foods, I simply issue ab -g 'cereal and milk'.

Thus you will find recipes most useful in two instances. First, recipes are handy if you have several foods that you wish to combine into one food. Then the nutrient breakdown of all the foods will appear together in your reports. Second, you have to use recipes if you wish take several foods, combine them, and subdivide the results. For example, if I wanted to eat an entire 9x9-inch dish of corn bread, perhaps I could treat corn bread in Pantry the same way I record my cereal and milk. However, because I want to divide the corn bread into multiple portions and eat them separately, I must use a recipe.